From: Sage Weil Date: Sat, 29 Sep 2012 08:14:58 +0000 (-0700) Subject: mds: fix fd leak in dumper X-Git-Tag: v0.54~167 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=e9f350f144aeff1727c0770416830895ea18cb44;p=ceph.git mds: fix fd leak in dumper CID 717084: Resource leak (RESOURCE_LEAK) At (6): Handle variable "fd" going out of scope leaks the handle. Signed-off-by: Sage Weil --- diff --git a/src/mds/Dumper.cc b/src/mds/Dumper.cc index d68df50f0e34..793625581dc4 100644 --- a/src/mds/Dumper.cc +++ b/src/mds/Dumper.cc @@ -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; }