]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Really fix solaris -HUP problem with slack dup of sockets. Undo prior
authorRoy T. Fielding <fielding@apache.org>
Mon, 4 Aug 1997 05:42:45 +0000 (05:42 +0000)
committerRoy T. Fielding <fielding@apache.org>
Mon, 4 Aug 1997 05:42:45 +0000 (05:42 +0000)
change and move ap_slack after all of the rest of the socket initialization,
which apparently is needed for SO_REUSEADDR to survive the dup on Solaris.
Also block SIGHUP and SIGUSR1 during restart on all platforms.

PR: 832
Submitted by: Dean Gaudet
Reviewed by: Roy Fielding

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/1.3@78889 13f79535-47bb-0310-9956-ffa450edef68

APACHE_1_2_X/src/main/http_main.c

index 50824f80875f187991f70213bc67978d26062f8a..11193da7a556c577b494bddcb96429554161b128 100644 (file)
@@ -1971,32 +1971,6 @@ int make_child(server_rec *server_conf, int child_num)
     return 0;
 }
 
-
-static void sock_bind (int s, const struct sockaddr_in *server)
-{
-#ifdef MPE
-/* MPE requires CAP=PM and GETPRIVMODE to bind to ports less than 1024 */
-    if (ntohs(server->sin_port) < 1024) GETPRIVMODE();
-#endif
-    if(bind(s, (struct sockaddr *)server,sizeof(struct sockaddr_in)) == -1)
-    {
-        perror("bind");
-#ifdef MPE
-        if (ntohs(server->sin_port) < 1024) GETUSERMODE();
-#endif
-       if (server->sin_addr.s_addr != htonl(INADDR_ANY))
-           fprintf(stderr,"httpd: could not bind to address %s port %d\n",
-                   inet_ntoa(server->sin_addr), ntohs(server->sin_port));
-       else
-           fprintf(stderr,"httpd: could not bind to port %d\n",
-                   ntohs(server->sin_port));
-        exit(1);
-    }
-#ifdef MPE
-    if (ntohs(server->sin_port) < 1024) GETUSERMODE();
-#endif
-}
-
 static int make_sock(pool *pconf, const struct sockaddr_in *server)
 {
     int s;
@@ -2008,13 +1982,16 @@ static int make_sock(pool *pconf, const struct sockaddr_in *server)
         exit(1);
     }
 
-#ifdef SOLARIS2
-    sock_bind (s, server);
-#endif
-       
+    /* Solaris (probably versions 2.4, 2.5, and 2.5.1 with various levels
+     * of tcp patches) has some really weird bugs where if you dup the
+     * socket now it breaks things across SIGHUP restarts.  It'll either
+     * be unable to bind, or it won't respond.
+     */
+#ifndef SOLARIS2
     s = ap_slack(s, AP_SLACK_HIGH);
 
     note_cleanups_for_fd(pconf, s); /* arrange to close on exec or restart */
+#endif
     
 #ifndef MPE
 /* MPE does not support SO_REUSEADDR and SO_KEEPALIVE */
@@ -2061,11 +2038,34 @@ static int make_sock(pool *pconf, const struct sockaddr_in *server)
        }
     }
 
-#ifndef SOLARIS2
-    sock_bind (s, server);
+#ifdef MPE
+/* MPE requires CAP=PM and GETPRIVMODE to bind to ports less than 1024 */
+    if (ntohs(server->sin_port) < 1024) GETPRIVMODE();
+#endif
+    if(bind(s, (struct sockaddr *)server,sizeof(struct sockaddr_in)) == -1)
+    {
+        perror("bind");
+#ifdef MPE
+        if (ntohs(server->sin_port) < 1024) GETUSERMODE();
+#endif
+       if (server->sin_addr.s_addr != htonl(INADDR_ANY))
+           fprintf(stderr,"httpd: could not bind to address %s port %d\n",
+                   inet_ntoa(server->sin_addr), ntohs(server->sin_port));
+       else
+           fprintf(stderr,"httpd: could not bind to port %d\n",
+                   ntohs(server->sin_port));
+        exit(1);
+    }
+#ifdef MPE
+    if (ntohs(server->sin_port) < 1024) GETUSERMODE();
 #endif
-
     listen(s, 512);
+
+#ifdef SOLARIS2
+    s = ap_slack(s, AP_SLACK_HIGH);
+
+    note_cleanups_for_fd(pconf, s); /* arrange to close on exec or restart */
+#endif
     return s;
 }
 
@@ -2291,6 +2291,8 @@ void standalone_main(int argc, char **argv)
        }
 
        /* we've been told to restart */
+        signal (SIGHUP, SIG_IGN);
+        signal (SIGUSR1, SIG_IGN);
 
        if (one_process) {
            /* not worth thinking about */