Skip to content

Commit

Permalink
Loop over FDs if close_range fails.
Browse files Browse the repository at this point in the history
  • Loading branch information
simonvik authored and dridi committed Oct 16, 2023
1 parent 01908a7 commit 2c38ba0
Showing 1 changed file with 6 additions and 7 deletions.
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

0 comments on commit 2c38ba0

Please sign in to comment.