1
0
mirror of https://github.com/systemd/systemd.git synced 2024-10-31 07:51:21 +03:00

Revert "Add variant of close_all_fds() that does not allocate and use it in freeze()"

This reverts commit cbcf371abc.
This commit is contained in:
Lennart Poettering 2021-07-29 16:34:45 +02:00
parent eef5ebec97
commit e7e7c07c50
3 changed files with 6 additions and 9 deletions

View File

@ -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)

View File

@ -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);

View File

@ -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 (;;) {