[ARVADOS] created: ae34fb3db3c082d529a3e9a75698094409d70321
git at public.curoverse.com
git at public.curoverse.com
Thu May 14 16:08:16 EDT 2015
at ae34fb3db3c082d529a3e9a75698094409d70321 (commit)
commit ae34fb3db3c082d529a3e9a75698094409d70321
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date: Thu May 14 16:02:43 2015 -0400
5748: Fix leaks in GetBlock error handling and PutBlock use of GetBlock where
buffers were not being returned to the buffer pool.
diff --git a/services/keepstore/bufferpool.go b/services/keepstore/bufferpool.go
index 373bfc7..0b216d7 100644
--- a/services/keepstore/bufferpool.go
+++ b/services/keepstore/bufferpool.go
@@ -39,6 +39,8 @@ func (p *bufferPool) Get(size int) []byte {
}
func (p *bufferPool) Put(buf []byte) {
- p.Pool.Put(buf)
- <-p.limiter
+ if buf != nil {
+ p.Pool.Put(buf)
+ <-p.limiter
+ }
}
diff --git a/services/keepstore/handlers.go b/services/keepstore/handlers.go
index cf5dfca..7c9ae64 100644
--- a/services/keepstore/handlers.go
+++ b/services/keepstore/handlers.go
@@ -514,6 +514,7 @@ func GetBlock(hash string, update_timestamp bool) ([]byte, error) {
if !os.IsNotExist(err) {
log.Printf("GetBlock: reading %s: %s\n", hash, err)
}
+ bufs.Put(buf)
continue
}
// Check the file checksum.
@@ -525,6 +526,7 @@ func GetBlock(hash string, update_timestamp bool) ([]byte, error) {
log.Printf("%s: checksum mismatch for request %s (actual %s)\n",
vol, hash, filehash)
error_to_caller = DiskHashError
+ bufs.Put(buf)
continue
}
if error_to_caller == DiskHashError {
@@ -536,6 +538,7 @@ func GetBlock(hash string, update_timestamp bool) ([]byte, error) {
error_to_caller = GenericError
log.Printf("%s: Touch %s failed: %s",
vol, hash, error_to_caller)
+ bufs.Put(buf)
continue
}
}
@@ -586,6 +589,7 @@ func PutBlock(block []byte, hash string) error {
// so there is nothing special to do if err != nil.
//
if oldblock, err := GetBlock(hash, true); err == nil {
+ defer bufs.Put(oldblock)
if bytes.Compare(block, oldblock) == 0 {
// The block already exists; return success.
return nil
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list