You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by ji...@apache.org on 2014/06/03 16:51:44 UTC

svn commit: r1599593 - in /httpd/httpd/trunk: docs/log-message-tags/next-number server/listen.c

Author: jim
Date: Tue Jun  3 14:51:44 2014
New Revision: 1599593

URL: http://svn.apache.org/r1599593
Log:
Don't try to assume the value of SO_REUSEPORT...

Modified:
    httpd/httpd/trunk/docs/log-message-tags/next-number
    httpd/httpd/trunk/server/listen.c

Modified: httpd/httpd/trunk/docs/log-message-tags/next-number
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/log-message-tags/next-number?rev=1599593&r1=1599592&r2=1599593&view=diff
==============================================================================
--- httpd/httpd/trunk/docs/log-message-tags/next-number (original)
+++ httpd/httpd/trunk/docs/log-message-tags/next-number Tue Jun  3 14:51:44 2014
@@ -1 +1 @@
-2638
+2639

Modified: httpd/httpd/trunk/server/listen.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/listen.c?rev=1599593&r1=1599592&r2=1599593&view=diff
==============================================================================
--- httpd/httpd/trunk/server/listen.c (original)
+++ httpd/httpd/trunk/server/listen.c Tue Jun  3 14:51:44 2014
@@ -41,7 +41,7 @@ AP_DECLARE_DATA ap_listen_rec *ap_listen
 AP_DECLARE_DATA ap_listen_rec **mpm_listen = NULL;
 AP_DECLARE_DATA int enable_default_listener = 1;
 AP_DECLARE_DATA int num_buckets = 1;
-AP_DECLARE_DATA int have_so_reuseport = 1;
+AP_DECLARE_DATA int have_so_reuseport = 0;
 
 static ap_listen_rec *old_listeners;
 static int ap_listenbacklog;
@@ -129,23 +129,28 @@ static apr_status_t make_sock(apr_pool_t
     ap_sock_disable_nagle(s);
 #endif
 
-#ifndef SO_REUSEPORT
-#define SO_REUSEPORT 15
+#ifdef SO_REUSEPORT
+    {
+      int thesock;
+      apr_os_sock_get(&thesock, s);
+      if (setsockopt(thesock, SOL_SOCKET, SO_REUSEPORT, (void *)&one, sizeof(int)) < 0) {
+          /* defined by not valid? */
+          if (errno == ENOPROTOOPT) {
+              have_so_reuseport = 0;
+          } /* Check if SO_REUSEPORT is supported by the running Linux Kernel.*/
+          else {
+              ap_log_perror(APLOG_MARK, APLOG_CRIT, stat, p, APLOGNO(02638)
+                      "make_sock: for address %pI, apr_socket_opt_set: (SO_REUSEPORT)",
+                       server->bind_addr);
+              apr_socket_close(s);
+              return errno;
+          }
+      }
+      else {
+          have_so_reuseport = 1;
+      }
+    }
 #endif
-    int thesock;
-    apr_os_sock_get(&thesock, s);
-    if (setsockopt(thesock, SOL_SOCKET, SO_REUSEPORT, (void *)&one, sizeof(int)) < 0) {
-        if (errno == ENOPROTOOPT) {
-            have_so_reuseport = 0;
-        } /* Check if SO_REUSEPORT is supported by the running Linux Kernel.*/
-        else {
-            ap_log_perror(APLOG_MARK, APLOG_CRIT, stat, p, APLOGNO()
-                    "make_sock: for address %pI, apr_socket_opt_set: (SO_REUSEPORT)",
-                     server->bind_addr);
-            apr_socket_close(s);
-            return errno;
-        }
-     }
 
     if (do_bind_listen) {
 #if APR_HAVE_IPV6
@@ -774,7 +779,6 @@ AP_DECLARE(apr_status_t) ap_duplicate_li
             apr_sockaddr_info_get(&sa, hostname, APR_UNSPEC, port, 0, p);
             duplr->bind_addr = sa;
             duplr->next = NULL;
-            apr_socket_t *temps = duplr->sd;
             if ((stat = apr_socket_create(&duplr->sd, duplr->bind_addr->family,
                                           SOCK_STREAM, 0, p)) != APR_SUCCESS) {
                 ap_log_perror(APLOG_MARK, APLOG_CRIT, 0, p, APLOGNO()