]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: fix fd leak in dumper
authorSage Weil <sage@inktank.com>
Sat, 29 Sep 2012 08:14:58 +0000 (01:14 -0700)
committerSage Weil <sage@inktank.com>
Sat, 29 Sep 2012 08:14:58 +0000 (01:14 -0700)
CID 717084: Resource leak (RESOURCE_LEAK)
At (6): Handle variable "fd" going out of scope leaks the handle.

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

index d68df50f0e34906aff1474d133cf4d1d8a5b50c3..793625581dc40bd2a8d9e5c2b9b04bb88837e8b4 100644 (file)
@@ -170,8 +170,10 @@ void Dumper::undump(const char *dump_file)
 
   char buf[200];
   int r = safe_read(fd, buf, sizeof(buf));
-  if (r < 0)
+  if (r < 0) {
+    TEMP_FAILURE_RETRY(::close(fd));
     return;
+  }
 
   long long unsigned start, len;
   sscanf(strstr(buf, "start offset"), "start offset %llu", &start);
@@ -232,6 +234,7 @@ void Dumper::undump(const char *dump_file)
     left -= l;
   }
 
+  TEMP_FAILURE_RETRY(::close(fd));
   cout << "done." << std::endl;
 }