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 committed Sep 22, 2023
1 parent c041cdc commit af04219
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions lib/libvarnish/vsub.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,8 @@
#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
# include <dirent.h>
#ifndef HAVE_CLOSEFROM
#include <dirent.h>
#endif

#include "vdef.h"
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 af04219

Please sign in to comment.