]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Restarts were hosed after the APR changes because we were opening
authorManoj Kasichainula <manoj@apache.org>
Fri, 24 Sep 1999 22:01:21 +0000 (22:01 +0000)
committerManoj Kasichainula <manoj@apache.org>
Fri, 24 Sep 1999 22:01:21 +0000 (22:01 +0000)
sockets even when we had them open already. So, for now, add an "active"
flag that indicates whether the socket stored in the listen_rec is an
actual open socket yet.

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

include/ap_listen.h
server/listen.c

index ab3fe43700c05dd51e4e5c845a6ad638462713c4..229aaf4a3519275446b1e9e58d257d47375594f4 100644 (file)
@@ -64,6 +64,7 @@ typedef struct ap_listen_rec ap_listen_rec;
 struct ap_listen_rec {
     ap_listen_rec *next;
     ap_socket_t *sd;
+    int active;
 /* more stuff here, like which protocol is bound to the port */
 };
 
index 125d2dc88c355eb0debb96678a51f39ea7763bd5..32f5b1d7a7ff87d27df31b501449f156233df2e0 100644 (file)
@@ -134,6 +134,7 @@ static ap_status_t make_sock(ap_context_t *p, ap_listen_rec *server)
     }
 
     server->sd = s;
+    server->active = 1;
     return APR_SUCCESS;
 }
 
@@ -144,6 +145,7 @@ static ap_status_t close_listeners_on_exec(void *v)
 
     for (lr = ap_listeners; lr; lr = lr->next) {
        ap_close_socket(lr->sd);
+       lr->active = 0;
     }
     return APR_SUCCESS;
 }
@@ -171,7 +173,9 @@ static void alloc_listener(char *addr, unsigned int port)
     }
 
     /* this has to survive restarts */
+    /* XXX - We need to deal with freeing this structure properly. */
     new = malloc(sizeof(ap_listen_rec));
+    new->active = 0;
     if (ap_create_tcp_socket(NULL, &new->sd) != APR_SUCCESS) {
         ap_log_error(APLOG_MARK, APLOG_CRIT, NULL,
                  "make_sock: failed to get a socket for %s", addr);
@@ -189,7 +193,7 @@ int ap_listen_open(ap_context_t *pconf, unsigned port)
     ap_listen_rec *lr;
     ap_listen_rec *next;
     int num_open;
-    ap_status_t stat;
+
     /* allocate a default listener if necessary */
     if (ap_listeners == NULL) {
        alloc_listener(APR_ANYADDR, port ? port : DEFAULT_HTTP_PORT);
@@ -197,15 +201,21 @@ int ap_listen_open(ap_context_t *pconf, unsigned port)
 
     num_open = 0;
     for (lr = ap_listeners; lr; lr = lr->next) {
-       stat = make_sock(pconf, lr);
-       if (stat == APR_SUCCESS) {
+       if (lr->active) {
            ++num_open;
        }
+       else {
+           if (make_sock(pconf, lr) == APR_SUCCESS) {
+               ++num_open;
+               lr->active = 1;
+           }
+       }
     }
 
     /* close the old listeners */
     for (lr = old_listeners; lr; lr = next) {
        ap_close_socket(lr->sd);
+       lr->active = 0;
        next = lr->next;
 /*     free(lr);*/
     }