]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
filstore: fix leak of fd in write error paths
authorSage Weil <sage@inktank.com>
Sat, 29 Sep 2012 01:14:24 +0000 (18:14 -0700)
committerSage Weil <sage@inktank.com>
Sat, 29 Sep 2012 01:14:24 +0000 (18:14 -0700)
CID 717095: Resource leak (RESOURCE_LEAK)
At (13): Handle variable "fd" going out of scope leaks the handle.

Signed-off-by: Sage Weil <sage@inktank.com>
src/os/FileStore.cc

index 2c5e33d28117bd1509e35bb3f1784a044ee2fc34..b4e3018ebc58bb2758e8f7e54374e1856488eabc 100644 (file)
@@ -3208,11 +3208,13 @@ int FileStore::_write(coll_t cid, const hobject_t& oid,
   if (actual < 0) {
     r = -errno;
     dout(0) << "write lseek64 to " << offset << " failed: " << cpp_strerror(r) << dendl;
+    TEMP_FAILURE_RETRY(::close(fd));
     goto out;
   }
   if (actual != (int64_t)offset) {
     dout(0) << "write lseek64 to " << offset << " gave bad offset " << actual << dendl;
     r = -EIO;
+    TEMP_FAILURE_RETRY(::close(fd));
     goto out;
   }