]> 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)
committerSamuel Just <sam.just@inktank.com>
Sun, 3 Aug 2014 19:47:10 +0000 (12:47 -0700)
This prevents an fd leak when maybe_inject_failure() throws an exception.

Signed-off-by: Sage Weil <sage@redhat.com>
(cherry picked from commit 3ec9a42b470422b1fe72b6294d82d9efcaca7f53)

src/os/LFNIndex.cc

index faeb243b6532e5dd157180135ab46b8a99ee80dc..e017f83a2c467165ec3fb6aded2ef449daaf9113 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;