]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
tools: Close the fd before returning in Dumper 2943/head
authorGreg Farnum <gfarnum@redhat.com>
Fri, 14 Nov 2014 22:28:25 +0000 (14:28 -0800)
committerGreg Farnum <gfarnum@redhat.com>
Fri, 14 Nov 2014 22:28:25 +0000 (14:28 -0800)
CID 1251577
CID 717084

Signed-off-by: Greg Farnum <gfarnum@redhat.com>
src/tools/cephfs/Dumper.cc

index c8e7f8468528fba5903060dd072a862e73ac1376..536fb5d9d25c537dcd77e1d30a74e137c36637a3 100644 (file)
@@ -113,6 +113,7 @@ int Dumper::dump(const char *dump_file)
     r = safe_write(fd, buf, sizeof(buf));
     if (r) {
       derr << "Error " << r << " (" << cpp_strerror(r) << ") writing journal file header" << dendl;
+      ::close(fd);
       return r;
     }
 
@@ -189,12 +190,14 @@ int Dumper::undump(const char *dump_file)
   if (trimmed_pos > start) {
     derr << std::hex << "Invalid header (trimmed 0x" << trimmed_pos
       << " > expire 0x" << start << std::dec << dendl;
+    ::close(fd);
     return -EINVAL;
   }
 
   if (start > write_pos) {
     derr << std::hex << "Invalid header (expire 0x" << start
       << " > write 0x" << write_pos << std::dec << dendl;
+    ::close(fd);
     return -EINVAL;
   }
 
@@ -231,6 +234,7 @@ int Dumper::undump(const char *dump_file)
   r = header_cond.wait();
   if (r != 0) {
     derr << "Failed to write header: " << cpp_strerror(r) << dendl;
+    ::close(fd);
     return r;
   }
 
@@ -274,6 +278,7 @@ int Dumper::undump(const char *dump_file)
     r = write_cond.wait();
     if (r != 0) {
       derr << "Failed to write header: " << cpp_strerror(r) << dendl;
+      ::close(fd);
       return r;
     }