From: Sage Weil Date: Mon, 21 Jul 2014 20:45:21 +0000 (-0700) Subject: os/LFNIndex: use FDCloser for fsync_dir X-Git-Tag: v0.84~71^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=3ec9a42b470422b1fe72b6294d82d9efcaca7f53;p=ceph.git os/LFNIndex: use FDCloser for fsync_dir This prevents an fd leak when maybe_inject_failure() throws an exception. Signed-off-by: Sage Weil --- diff --git a/src/os/LFNIndex.cc b/src/os/LFNIndex.cc index c021668f15921..1e11a30903083 100644 --- a/src/os/LFNIndex.cc +++ b/src/os/LFNIndex.cc @@ -171,9 +171,9 @@ int LFNIndex::fsync_dir(const vector &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;