Add a helper to close fd's when we leave scope. This is important when
injecting failures by throwing exceptions.
Signed-off-by: Sage Weil <sage@redhat.com>
(cherry picked from commit
a320c260a9e088ab0a4ea3d5298c06a2d077de37)
}
}
+// Helper to close fd's when we leave scope. This is useful when used
+// in combination with RetryException, thrown by the above.
+struct FDCloser {
+ int fd;
+ FDCloser(int f) : fd(f) {}
+ ~FDCloser() {
+ VOID_TEMP_FAILURE_RETRY(::close(fd));
+ }
+};
+
+
/* Public methods */
void LFNIndex::set_ref(ceph::shared_ptr<CollectionIndex> ref)