From 94fee997204d439abfd642be20a7e33df5979342 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Mon, 21 Jul 2014 13:45:21 -0700 Subject: [PATCH] os/LFNIndex: use FDCloser for fsync_dir This prevents an fd leak when maybe_inject_failure() throws an exception. Signed-off-by: Sage Weil (cherry picked from commit 3ec9a42b470422b1fe72b6294d82d9efcaca7f53) --- src/os/LFNIndex.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/os/LFNIndex.cc b/src/os/LFNIndex.cc index faeb243b6532e..e017f83a2c467 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; -- 2.39.5