Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loop over FDs if close_range fails. #3989

Merged
merged 1 commit into from
Oct 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions lib/libvarnish/vsub.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@
#include <stdlib.h> // Solaris closefrom(3c)
#include <string.h>
#include <unistd.h> // BSD/Linux close_range(2)
#ifdef HAVE_WORKING_CLOSE_RANGE
#elif HAVE_CLOSEFROM
#else
#ifndef HAVE_CLOSEFROM
# include <dirent.h>
#endif

Expand All @@ -67,13 +65,14 @@ VSUB_closefrom(int fd)

assert(fd >= 0);

#ifdef HAVE_WORKING_CLOSE_RANGE
AZ(close_range(fd, ~0U, 0));
return;
#elif HAVE_CLOSEFROM
#ifdef HAVE_CLOSEFROM
closefrom(fd);
return;
#else
# ifdef HAVE_WORKING_CLOSE_RANGE
if (close_range(fd, ~0U, 0) == 0)
return;
# endif
char buf[128];
int i, maxfd = 0;
DIR *d;
Expand Down