From: Greg Farnum Date: Fri, 14 Nov 2014 22:28:25 +0000 (-0800) Subject: tools: Close the fd before returning in Dumper X-Git-Tag: v0.90~79^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b10bd19f345c49a9ab3cca420fd5af5662e92c79;p=ceph.git tools: Close the fd before returning in Dumper CID 1251577 CID 717084 Signed-off-by: Greg Farnum --- diff --git a/src/tools/cephfs/Dumper.cc b/src/tools/cephfs/Dumper.cc index c8e7f846852..536fb5d9d25 100644 --- a/src/tools/cephfs/Dumper.cc +++ b/src/tools/cephfs/Dumper.cc @@ -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; }