Enable accept filter only once
authorFabian Keil <fk@fabiankeil.de>
Mon, 26 Jun 2017 12:12:55 +0000 (12:12 +0000)
committerFabian Keil <fk@fabiankeil.de>
Mon, 26 Jun 2017 12:12:55 +0000 (12:12 +0000)
Previously Privoxy would (attempt to) enable it before
each accept call which isn't necessary.

Sponsored by: Robert Klemme

jbsockets.c
jcc.c

index fef395a..765aafb 100644 (file)
@@ -1,4 +1,4 @@
-const char jbsockets_rcs[] = "$Id: jbsockets.c,v 1.145 2017/06/08 13:04:56 fabiankeil Exp $";
+const char jbsockets_rcs[] = "$Id: jbsockets.c,v 1.146 2017/06/26 12:11:12 fabiankeil Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/jbsockets.c,v $
@@ -1377,20 +1377,6 @@ int accept_connection(struct client_state * csp, jb_socket fds[])
 #else
    do
    {
-#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);
    } while (afd < 0 && errno == EINTR);
    if (afd < 0)
diff --git a/jcc.c b/jcc.c
index 6e952c7..734e717 100644 (file)
--- a/jcc.c
+++ b/jcc.c
@@ -1,4 +1,4 @@
-const char jcc_rcs[] = "$Id: jcc.c,v 1.461 2017/06/26 12:09:56 fabiankeil Exp $";
+const char jcc_rcs[] = "$Id: jcc.c,v 1.462 2017/06/26 12:10:31 fabiankeil Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/jcc.c,v $
@@ -4210,6 +4210,20 @@ static void bind_ports_helper(struct configuration_spec * config,
       if (config->hport[i])
       {
          sockets[i] = bind_port_helper(config->haddr[i], config->hport[i]);
+#if defined(FEATURE_ACCEPT_FILTER) && defined(SO_ACCEPTFILTER)
+         if (config->enable_accept_filter && sockets[i] != JB_INVALID_SOCKET)
+         {
+            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(sockets[i], SOL_SOCKET, SO_ACCEPTFILTER, &af_options,
+                  sizeof(af_options)))
+            {
+               log_error(LOG_LEVEL_ERROR,
+                  "Enabling accept filter for socket %d failed: %E", sockets[i]);
+            }
+         }
+#endif
       }
       else
       {