Fix accept_filter for GNU/Linux

Rafael Zalamena rafaelfz at taghos.com.br
Wed Sep 2 23:23:40 CEST 2015


Hello,

Varnish cache daemon is not doing 'accept_filter' for the GNU/Linux
version because of HAVE_ACCEPT_FILTER not being defined. Something along
the way broke it, so in order to fix it I have added TCP_DEFER_ACCEPT
detection code to configure.ac to define HAVE_ACCEPT_FILTER and
HAVE_TCP_DEFER_ACCEPT so we can have a fallback of accept_filter on Linux.

Since I didn't see any different use of ACCEPT_FILTER and historicaly no
one used it diferently I kept TCP_DEFER_ACCEPT being a ACCEPT_FILTER
replacement to create a small diff.

diff --git configure.ac configure.ac
index 6c4d5f2..4a50fd8 100644
--- configure.ac
+++ configure.ac
@@ -366,6 +366,19 @@ AC_CHECK_DECL([SO_ACCEPTFILTER],
     ]
 )
 
+AC_CHECK_DECL([TCP_DEFER_ACCEPT],
+    [
+    AC_DEFINE(HAVE_ACCEPT_FILTERS,1,[Define to 1 if you have accept filters]),
+    AC_DEFINE(HAVE_TCP_DEFER_ACCEPT,1,[Define to 1 if you have TCP defer accept])
+    ],
+    ,
+    [
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <netinet/tcp.h>
+    ]
+)
+
 # Older Solaris versions define SO_{RCV,SND}TIMEO, but do not
 # implement them.
 #
diff --git lib/libvarnish/vtcp.c lib/libvarnish/vtcp.c
index 3992555..732c2ea 100644
--- lib/libvarnish/vtcp.c
+++ lib/libvarnish/vtcp.c
@@ -146,6 +146,7 @@ VTCP_hisname(int sock, char *abuf, unsigned alen, char *pbuf, unsigned plen)
 /*--------------------------------------------------------------------*/
 
 #ifdef HAVE_ACCEPT_FILTERS
+#ifndef HAVE_TCP_DEFER_ACCEPT
 
 int
 VTCP_filter_http(int sock)
@@ -160,7 +161,7 @@ VTCP_filter_http(int sock)
 	return (retval);
 }
 
-#elif defined(__linux)
+#else /* HAVE_TCP_DEFER_ACCEPT */
 
 int
 VTCP_filter_http(int sock)
@@ -173,6 +174,7 @@ VTCP_filter_http(int sock)
 	return (retval);
 }
 
+#endif
 #else
 
 int



More information about the varnish-dev mailing list