Merge pull request #85 from datomia/fix-pool-leak

Fix memory leak
This commit is contained in:
Lei Xue
2019-06-30 18:57:44 +08:00
committed by GitHub
4 changed files with 41 additions and 61 deletions

View File

@@ -23,7 +23,6 @@ import (
"github.com/gostor/gotgt/pkg/api"
"github.com/gostor/gotgt/pkg/util"
"github.com/gostor/gotgt/pkg/util/pool"
log "github.com/sirupsen/logrus"
)
@@ -110,7 +109,7 @@ func bsPerformCommand(bs api.BackingStore, cmd *api.SCSICommand) (err error, key
// TODO
break
case api.READ_6, api.READ_10, api.READ_12, api.READ_16:
rbuf = pool.NewBuffer(int(tl))
rbuf = make([]byte, int(tl))
rbuf, err = bs.Read(int64(offset), tl)
if err != nil && err != io.EOF {
key = MEDIUM_ERROR
@@ -179,7 +178,7 @@ write:
}
verify:
if doVerify {
rbuf = pool.NewBuffer(int(tl))
rbuf = make([]byte, int(tl))
rbuf, err = bs.Read(int64(offset), tl)
if err != nil {
key = MEDIUM_ERROR