]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: fd: Use closefrom() as my_closefrom() if supported.
authorOlivier Houchard <ohouchard@haproxy.com>
Mon, 25 Feb 2019 13:26:54 +0000 (14:26 +0100)
committerOlivier Houchard <cognet@ci0.org>
Mon, 25 Feb 2019 15:51:03 +0000 (16:51 +0100)
Add a new option, USE_CLOSEFROM. If set, it is assumed the system provides
a closefrom() function, so use it.
It is only implicitely used on FreeBSD for now, it should work on
OpenBSD/NetBSD/DragonflyBSD/Solaris too, but as I have no such system to
test it, I'd rather leave it disabled by default. Users can add USE_CLOSEFROM
explicitely on their make command line to activate it.

Makefile
src/fd.c

index e2c4d17a16f68882c0b50a75700a212f752ecb6a..6c19d3dfe90cb0278f82cd1df33f33c3f6b0059d 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -374,6 +374,7 @@ ifeq ($(TARGET),freebsd)
   USE_LIBCRYPT   = implicit
   USE_THREAD     = implicit
   USE_CPU_AFFINITY= implicit
+  USE_CLOSEFROM  = implicit
 else
 ifeq ($(TARGET),osx)
   # This is for Mac OS/X
@@ -682,6 +683,10 @@ endif
 endif
 endif
 
+ifneq ($(USE_CLOSEFROM),)
+OPTIONS_CFLAGS += -DUSE_CLOSEFROM
+endif
+
 ifneq ($(USE_LUA),)
 check_lua_lib = $(shell echo "int main(){}" | $(CC) -o /dev/null -x c - $(2) -l$(1) 2>/dev/null && echo $(1))
 check_lua_inc = $(shell if [ -d $(2)$(1) ]; then echo $(2)$(1); fi;)
index 314e10fa2fe3b49ca2d50aef52f63937157f9896..581c5aaae8b7c2c5cd292be9b991208f3bec95f8 100644 (file)
--- a/src/fd.c
+++ b/src/fd.c
@@ -468,7 +468,13 @@ void fd_process_cached_events()
        fdlist_process_cached_events(&fd_cache);
 }
 
-#if defined(ENABLE_POLL)
+#if defined(USE_CLOSEFROM)
+void my_closefrom(int start)
+{
+       closefrom(start);
+}
+
+#elif defined(ENABLE_POLL)
 /* This is a portable implementation of closefrom(). It closes all open file
  * descriptors starting at <start> and above. It relies on the fact that poll()
  * will return POLLNVAL for each invalid (hence close) file descriptor passed