]> granicus.if.org Git - apache/commitdiff
Move setup_listeners to listen.c. This renames it to ap_setup_listeners,
authorRyan Bloom <rbb@apache.org>
Mon, 10 Jul 2000 21:37:23 +0000 (21:37 +0000)
committerRyan Bloom <rbb@apache.org>
Mon, 10 Jul 2000 21:37:23 +0000 (21:37 +0000)
and removes the duplicated code from all effected MPMs.  The only this
doesn't touch, is Windows.  That MPM was using a different setup_listeners.
If one of the Windows guys would like to modify the WinNT MPM to use the
same setup_lsiteners, that would be VERY cool.

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

include/ap_listen.h
server/listen.c
server/mpm/beos/beos.c
server/mpm/dexter/dexter.c
server/mpm/mpmt_beos/mpmt_beos.c
server/mpm/mpmt_pthread/mpmt_pthread.c
server/mpm/prefork/prefork.c
server/mpm/spmt_os2/spmt_os2.c

index 011677c439b60289375a58c28c2e929a63013608..729ba5c50bfec4d802f5b424d9875dab43b3b1c0 100644 (file)
@@ -72,7 +72,11 @@ struct ap_listen_rec {
 extern ap_listen_rec *ap_listeners;
 
 void ap_listen_pre_config(void);
+#ifndef WIN32
+int ap_setup_listeners(server_rec *s);
+#else
 int ap_listen_open(process_rec *process, unsigned port);
+#endif
 const char *ap_set_listenbacklog(cmd_parms *cmd, void *dummy, const char *arg);
 const char *ap_set_listener(cmd_parms *cmd, void *dummy, const char *ips);
 const char *ap_set_send_buffer_size(cmd_parms *cmd, void *dummy,
index 4eaa9db997341cfaa2e8877e6c437e532eeaef9a..c0715242c2d99e2abb3474c1ffa519ef101e1481 100644 (file)
@@ -201,7 +201,9 @@ static void alloc_listener(process_rec *process, char *addr, unsigned int port)
     ap_listeners = new;
 }
 
-
+#ifndef WIN32
+static
+#endif
 int ap_listen_open(process_rec *process, unsigned port)
 {
     ap_pool_t *pconf = process->pconf;
@@ -241,6 +243,20 @@ int ap_listen_open(process_rec *process, unsigned port)
     return num_open ? 0 : -1;
 }
 
+#ifndef WIN32
+int ap_setup_listeners(server_rec *s)
+{
+    ap_listen_rec *lr;
+    int num_listeners = 0;
+    if (ap_listen_open(s->process, s->port)) {
+       return 0;
+    }
+    for (lr = ap_listeners; lr; lr = lr->next) {
+        num_listeners++;
+    }
+    return num_listeners;
+}
+#endif
 
 void ap_listen_pre_config(void)
 {
index 13abfa0731d8e731013c7a3c4fe3e0770c79aed1..8f11698cfc9aebb5094611b939c48b827e710598 100644 (file)
@@ -289,19 +289,6 @@ static void set_signals(void)
            ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "sigaction(SIGWINCH)");
 }
 
-static int setup_listeners(server_rec *s)
-{
-    ap_listen_rec *lr;
-    int num_listeners = 0;
-    if (ap_listen_open(s->process, s->port)) {
-       return 0;
-    }
-    for (lr = ap_listeners; lr; lr = lr->next) {
-        num_listeners++;
-    }
-    return num_listeners;
-}
-
 /*****************************************************************
  * Here follows a long bunch of generic server bookkeeping stuff...
  */
@@ -692,7 +679,7 @@ int ap_mpm_run(ap_pool_t *_pconf, ap_pool_t *plog, server_rec *s)
         return 1;
     }
        
-    if ((num_listening_sockets = setup_listeners(ap_server_conf)) < 1) {
+    if ((num_listening_sockets = ap_setup_listeners(ap_server_conf)) < 1) {
         ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ALERT, 0, s,
             "no listening sockets available, shutting down");
         return 1;
index 345891a372a21dd5fabf0d6001714c26bcc59130..a174049ddda693d7ec4db2c33b61b58c5c85d57a 100644 (file)
@@ -376,20 +376,6 @@ static void set_signals(void)
 #endif
 }
 
-static int setup_listeners(server_rec *s)
-{
-    ap_listen_rec *lr;
-    int num_listeners = 0;
-
-    if (ap_listen_open(s->process, s->port)) {
-       return 0;
-    }
-    for (lr = ap_listeners; lr; lr = lr->next) {
-        num_listeners++;
-    }
-    return num_listeners;
-}
-
 /*****************************************************************
  * Here follows a long bunch of generic server bookkeeping stuff...
  */
@@ -1026,7 +1012,7 @@ int ap_mpm_run(ap_pool_t *_pconf, ap_pool_t *plog, server_rec *s)
         exit(1);
     }
     ap_server_conf = s;
-    if ((num_listenfds = setup_listeners(ap_server_conf)) < 1) {
+    if ((num_listenfds = ap_setup_listeners(ap_server_conf)) < 1) {
         /* XXX: hey, what's the right way for the mpm to indicate a fatal error? */
         ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ALERT, 0, s,
             "no listening sockets available, shutting down");
index f00ed2cf724afab21e7b18de086be9a78ab05c9a..63cf116c4c682740abad84df66f1bc434bf9dc30 100644 (file)
@@ -277,19 +277,6 @@ static void set_signals(void)
            ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "sigaction(SIGWINCH)");
 }
 
-static int setup_listeners(server_rec *s)
-{
-    ap_listen_rec *lr;
-    int num_listeners = 0;
-    if (ap_listen_open(s->process, s->port)) {
-       return 0;
-    }
-    for (lr = ap_listeners; lr; lr = lr->next) {
-        num_listeners++;
-    }
-    return num_listeners;
-}
-
 /*****************************************************************
  * Here follows a long bunch of generic server bookkeeping stuff...
  */
@@ -717,7 +704,7 @@ int ap_mpm_run(ap_pool_t *_pconf, ap_pool_t *plog, server_rec *s)
     ap_server_conf = s;
     port_of_death = create_port(1, "httpd_port_of_death");
 
-    if ((num_listenfds = setup_listeners(ap_server_conf)) < 1) {
+    if ((num_listenfds = ap_setup_listeners(ap_server_conf)) < 1) {
         /* XXX: hey, what's the right way for the mpm to indicate a fatal error? */
         ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ALERT, errno, s,
             "no listening sockets available, shutting down");
index 287351d546e22b156a5702d8b52b43c64311b3a7..1cf982d6b416d3ac01a93e3d12d5cd385a98118a 100644 (file)
@@ -373,19 +373,6 @@ static void set_signals(void)
 #endif
 }
 
-static int setup_listeners(server_rec *s)
-{
-    ap_listen_rec *lr;
-    int num_listeners = 0;
-    if (ap_listen_open(s->process, s->port)) {
-       return 0;
-    }
-    for (lr = ap_listeners; lr; lr = lr->next) {
-        num_listeners++;
-    }
-    return num_listeners;
-}
-
 /*****************************************************************
  * Here follows a long bunch of generic server bookkeeping stuff...
  */
@@ -1049,7 +1036,7 @@ int ap_mpm_run(ap_pool_t *_pconf, ap_pool_t *plog, server_rec *s)
         exit(1);
     }
     ap_server_conf = s;
-    if ((num_listensocks = setup_listeners(ap_server_conf)) < 1) {
+    if ((num_listensocks = ap_setup_listeners(ap_server_conf)) < 1) {
         /* XXX: hey, what's the right way for the mpm to indicate a fatal error? */
         ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ALERT, 0, s,
             "no listening sockets available, shutting down");
index 894e0c990a4d507a42bbd449340132d74d8e3a87..1e0b488d102407e3b3474d43907eba613a173739 100644 (file)
@@ -1283,29 +1283,6 @@ static void perform_idle_server_maintenance(void)
     }
 }
 
-static int setup_listeners(server_rec *s)
-{
-    ap_listen_rec *lr;
-    int sockdes;
-
-    if (ap_listen_open(s->process, s->port)) {
-       ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ALERT, 0, s,
-                   "no listening sockets available, shutting down");
-       return -1;
-    }
-
-    listenmaxfd = -1;
-    FD_ZERO(&listenfds);
-    for (lr = ap_listeners; lr; lr = lr->next) {
-        ap_get_os_sock(&sockdes, lr->sd);
-       FD_SET(sockdes, &listenfds);
-       if (sockdes > listenmaxfd) {
-           listenmaxfd = sockdes;
-       }
-    }
-    return 0;
-}
-
 /* Useful to erase the status of children that might be from previous
  * generations */
 static void ap_prefork_force_reset_connection_status(long conn_id)
@@ -1337,7 +1314,7 @@ int ap_mpm_run(ap_pool_t *_pconf, ap_pool_t *plog, server_rec *s)
  
     ap_log_pid(pconf, ap_pid_fname);
 
-    if (setup_listeners(s)) {
+    if (ap_setup_listeners(s)) {
        /* XXX: hey, what's the right way for the mpm to indicate a fatal error? */
        return 1;
     }
index 9ca01bcad0e13978ec8bb0c2ff7a536ee3ed0123..3d882988c59c89a0e3371b7f3add535f9a18bc37 100644 (file)
@@ -741,27 +741,6 @@ int ap_stop_signalled(void)
     return 0;
 }
 
-
-
-static int setup_listeners(ap_pool_t *pchild, ap_pollfd_t **listen_poll)
-{
-    ap_listen_rec *lr;
-    int numfds = 0;
-
-    for (lr = ap_listeners; lr; lr = lr->next) {
-        numfds++;
-    }
-
-    ap_setup_poll(listen_poll, numfds, pchild);
-
-    for (lr = ap_listeners; lr; lr = lr->next) {
-       ap_add_poll_socket(*listen_poll, lr->sd, APR_POLLIN);
-    }
-    return 0;
-}
-
-
-
 static void child_main(void *child_num_arg)
 {
     ap_listen_rec *lr = NULL;
@@ -796,7 +775,7 @@ static void child_main(void *child_num_arg)
     THREAD_GLOBAL(pchild) = pchild;
     ap_create_pool(&ptrans, pchild);
 
-    if (setup_listeners(pchild, &listen_poll)) {
+    if (ap_setup_listeners(pchild, &listen_poll)) {
        clean_child_exit(1);
     }