[7.4] f0cf401c8 Loop over FDs if close_range fails.
Dridi Boukelmoune
dridi.boukelmoune at gmail.com
Mon Oct 16 08:36:06 UTC 2023
commit f0cf401c8da706d837bed40528271b048110a79e
Author: Simon Stridsberg <simon.stridsberg at varnish-software.com>
Date: Fri Sep 22 09:08:47 2023 +0200
Loop over FDs if close_range fails.
diff --git a/lib/libvarnish/vsub.c b/lib/libvarnish/vsub.c
index 27caec46d..c1c1ddfcc 100644
--- a/lib/libvarnish/vsub.c
+++ b/lib/libvarnish/vsub.c
@@ -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
@@ -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;
More information about the varnish-commit
mailing list