From 4a5b06c5d1d3f4e902b8e5999a0c59aaf575e182 Mon Sep 17 00:00:00 2001 From: Mike Yuan Date: Wed, 26 Feb 2025 00:26:57 +0100 Subject: [PATCH] shared/async: introduce asynchronous_close_many() helper --- src/shared/async.c | 7 +++++++ src/shared/async.h | 5 ++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/shared/async.c b/src/shared/async.c index e0c7e7dcaa..acde1b11d7 100644 --- a/src/shared/async.c +++ b/src/shared/async.c @@ -133,6 +133,13 @@ int asynchronous_close(int fd) { return -EBADF; /* return an invalidated fd */ } +void asynchronous_close_many(const int fds[], size_t n_fds) { + assert(fds || n_fds == 0); + + FOREACH_ARRAY(i, fds, n_fds) + asynchronous_close(*i); +} + int asynchronous_rm_rf(const char *p, RemoveFlags flags) { int r; diff --git a/src/shared/async.h b/src/shared/async.h index 2f5bbd51a5..d8604f8746 100644 --- a/src/shared/async.h +++ b/src/shared/async.h @@ -21,7 +21,10 @@ int asynchronous_sync(pid_t *ret_pid); int asynchronous_fsync(int fd, pid_t *ret_pid); + int asynchronous_close(int fd); -int asynchronous_rm_rf(const char *p, RemoveFlags flags); +void asynchronous_close_many(const int fds[], size_t n_fds); DEFINE_TRIVIAL_CLEANUP_FUNC(int, asynchronous_close); + +int asynchronous_rm_rf(const char *p, RemoveFlags flags);