]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/LFNIndex: use FDCloser for fsync_dir
authorSage Weil <sage@redhat.com>
Mon, 21 Jul 2014 20:45:21 +0000 (13:45 -0700)
committerSage Weil <sage@redhat.com>
Wed, 23 Jul 2014 21:48:14 +0000 (14:48 -0700)
This prevents an fd leak when maybe_inject_failure() throws an exception.

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

index c021668f15921dab7e317107601079c0acebd409..1e11a30903083948842259eb2823998ff3e5c70f 100644 (file)
@@ -171,9 +171,9 @@ int LFNIndex::fsync_dir(const vector<string> &path)
   int fd = ::open(get_full_path_subdir(path).c_str(), O_RDONLY);
   if (fd < 0)
     return -errno;
+  FDCloser f(fd);
   maybe_inject_failure();
   int r = ::fsync(fd);
-  VOID_TEMP_FAILURE_RETRY(::close(fd));
   maybe_inject_failure();
   if (r < 0)
     return -errno;