From: Lennart Poettering Date: Thu, 29 Jul 2021 14:34:45 +0000 (+0200) Subject: Revert "Add variant of close_all_fds() that does not allocate and use it in freeze()" X-Git-Tag: v250-rc1~399^2~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e7e7c07c50d980a4494b101a2b1b5e6126c7940f;p=thirdparty%2Fsystemd.git Revert "Add variant of close_all_fds() that does not allocate and use it in freeze()" This reverts commit cbcf371abc328167fa869721c1add4850c793240. --- diff --git a/src/basic/fd-util.c b/src/basic/fd-util.c index 27f651600ec..032f3037895 100644 --- a/src/basic/fd-util.c +++ b/src/basic/fd-util.c @@ -208,7 +208,7 @@ static int get_max_fd(void) { return (int) (m - 1); } -int close_all_fds_full(int except[], size_t n_except, bool allow_alloc) { +int close_all_fds(int except[], size_t n_except) { static bool have_close_range = true; /* Assume we live in the future */ _cleanup_closedir_ DIR *d = NULL; int r = 0; @@ -274,7 +274,7 @@ int close_all_fds_full(int except[], size_t n_except, bool allow_alloc) { /* Fallback for when close_range() is not supported */ opendir_fallback: - d = allow_alloc ? opendir("/proc/self/fd") : NULL; + d = opendir("/proc/self/fd"); if (d) { struct dirent *de; @@ -302,8 +302,8 @@ int close_all_fds_full(int except[], size_t n_except, bool allow_alloc) { return r; } - /* Fallback for when /proc isn't available (for example in chroots) or when we cannot allocate by - * brute-forcing through the file descriptor table. */ + /* Fallback for when /proc isn't available (for example in chroots) by brute-forcing through the file + * descriptor table. */ int max_fd = get_max_fd(); if (max_fd < 0) diff --git a/src/basic/fd-util.h b/src/basic/fd-util.h index 2382d52d40c..ab841b67e00 100644 --- a/src/basic/fd-util.h +++ b/src/basic/fd-util.h @@ -57,10 +57,7 @@ DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(DIR*, closedir, NULL); int fd_nonblock(int fd, bool nonblock); int fd_cloexec(int fd, bool cloexec); -int close_all_fds_full(int except[], size_t n_except, bool allow_alloc); -static inline int close_all_fds(int except[], size_t n_except) { - return close_all_fds_full(except, n_except, true); -} +int close_all_fds(int except[], size_t n_except); int same_fd(int a, int b); diff --git a/src/basic/process-util.c b/src/basic/process-util.c index 38df34e3395..fef0c742c70 100644 --- a/src/basic/process-util.c +++ b/src/basic/process-util.c @@ -1622,7 +1622,7 @@ _noreturn_ void freeze(void) { log_close(); /* Make sure nobody waits for us on a socket anymore */ - (void) close_all_fds_full(NULL, 0, false); + (void) close_all_fds(NULL, 0); /* Let's not freeze right away, but keep reaping zombies. */ for (;;) {