Skip to content
This repository was archived by the owner on Feb 16, 2026. It is now read-only.

Commit 2c38ba0

Browse files
simonvikdridi
authored andcommitted
Loop over FDs if close_range fails.
1 parent 01908a7 commit 2c38ba0

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

lib/libvarnish/vsub.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@
3838
#include <stdlib.h> // Solaris closefrom(3c)
3939
#include <string.h>
4040
#include <unistd.h> // BSD/Linux close_range(2)
41-
#ifdef HAVE_WORKING_CLOSE_RANGE
42-
#elif HAVE_CLOSEFROM
43-
#else
41+
#ifndef HAVE_CLOSEFROM
4442
# include <dirent.h>
4543
#endif
4644

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

6866
assert(fd >= 0);
6967

70-
#ifdef HAVE_WORKING_CLOSE_RANGE
71-
AZ(close_range(fd, ~0U, 0));
72-
return;
73-
#elif HAVE_CLOSEFROM
68+
#ifdef HAVE_CLOSEFROM
7469
closefrom(fd);
7570
return;
7671
#else
72+
# ifdef HAVE_WORKING_CLOSE_RANGE
73+
if (close_range(fd, ~0U, 0) == 0)
74+
return;
75+
# endif
7776
char buf[128];
7877
int i, maxfd = 0;
7978
DIR *d;

0 commit comments

Comments
 (0)