current jbsockets.c, 1.145, 1.146 loadcfg.c, 1.163, 1.164 project.h, 1.221, 1.222

Fabian Keil via ijbswa-commits <[email protected]> Mon, 26 Jun 2017 12:11:15 +0000
Newsgroups gmane.comp.web.privoxy.cvs
Message-ID <[email protected]>
Update of /cvsroot/ijbswa/current
In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv21706

Modified Files:
	jbsockets.c loadcfg.c project.h 
Log Message:
Add an enable-accept-filter directive

Which allows to toggle accept filter support at
run time when compiled with FEATURE_ACCEPT_FILTER
support.

It makes testing more convenient and now that it's
optional we can emit an error message if enabling
the accept filter fails.

Sponsored by: Robert Klemme


Index: project.h
===================================================================
RCS file: /cvsroot/ijbswa/current/project.h,v
retrieving revision 1.221
retrieving revision 1.222
diff -C2 -d -r1.221 -r1.222
*** project.h	29 May 2017 10:02:11 -0000	1.221
--- project.h	26 Jun 2017 12:11:13 -0000	1.222
***************
*** 1352,1355 ****
--- 1352,1358 ----
     size_t receive_buffer_size;
  
+    /** Use accf_http(4) if available */
+    int enable_accept_filter;
+ 
  #ifdef FEATURE_TRUST
  

Index: jbsockets.c
===================================================================
RCS file: /cvsroot/ijbswa/current/jbsockets.c,v
retrieving revision 1.145
retrieving revision 1.146
diff -C2 -d -r1.145 -r1.146
*** jbsockets.c	8 Jun 2017 13:04:56 -0000	1.145
--- jbsockets.c	26 Jun 2017 12:11:12 -0000	1.146
***************
*** 1379,1386 ****
     {
  #if defined(FEATURE_ACCEPT_FILTER) && defined(SO_ACCEPTFILTER)
!       struct accept_filter_arg af_options;
!       bzero(&af_options, sizeof(af_options));
!       strlcpy(af_options.af_name, "httpready", sizeof(af_options.af_name));
!       setsockopt(fd, SOL_SOCKET, SO_ACCEPTFILTER, &af_options, sizeof(af_options));
  #endif
        afd = accept (fd, (struct sockaddr *) &client, &c_length);
--- 1379,1394 ----
     {
  #if defined(FEATURE_ACCEPT_FILTER) && defined(SO_ACCEPTFILTER)
!       if (csp->config->enable_accept_filter)
!       {
!          struct accept_filter_arg af_options;
!          bzero(&af_options, sizeof(af_options));
!          strlcpy(af_options.af_name, "httpready", sizeof(af_options.af_name));
!          if (setsockopt(fd, SOL_SOCKET, SO_ACCEPTFILTER, &af_options,
!             sizeof(af_options)))
!          {
!             log_error(LOG_LEVEL_ERROR,
!                "Enabling accept filter for socket %d failed: %E", fd);
!          }
!       }
  #endif
        afd = accept (fd, (struct sockaddr *) &client, &c_length);

Index: loadcfg.c
===================================================================
RCS file: /cvsroot/ijbswa/current/loadcfg.c,v
retrieving revision 1.163
retrieving revision 1.164
diff -C2 -d -r1.163 -r1.164
*** loadcfg.c	26 Jun 2017 12:09:56 -0000	1.163
--- loadcfg.c	26 Jun 2017 12:11:13 -0000	1.164
***************
*** 143,146 ****
--- 143,147 ----
  #define hash_default_server_timeout      2530089913U /* "default-server-timeout" */
  #define hash_deny_access                 1227333715U /* "deny-access" */
+ #define hash_enable_accept_filter        2909040407U /* "enable-accept-filter" */
  #define hash_enable_edit_actions         2517097536U /* "enable-edit-actions" */
  #define hash_enable_compression          3943696946U /* "enable-compression" */
***************
*** 613,616 ****
--- 614,620 ----
  #endif
     config->trust_x_forwarded_for     = 0;
+ #if defined(FEATURE_ACCEPT_FILTER) && defined(SO_ACCEPTFILTER)
+    config->enable_accept_filter      = 0;
+ #endif
     config->trusted_cgi_referrer      = NULL;
     /*
***************
*** 977,980 ****
--- 981,993 ----
  #endif /* def FEATURE_ACL */
  
+ #if defined(FEATURE_ACCEPT_FILTER) && defined(SO_ACCEPTFILTER)
+ /* *************************************************************************
+  * enable-accept-filter 0|1
+  * *************************************************************************/
+          case hash_enable_accept_filter :
+             config->enable_accept_filter = parse_toggle_state(cmd, arg);
+             break;
+ #endif /* defined(FEATURE_ACCEPT_FILTER) && defined(SO_ACCEPTFILTER) */
+ 
  /* *************************************************************************
   * enable-edit-actions 0|1


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot