]> granicus.if.org Git - apache/blobdiff - server/listen.c
Remove an unused header
[apache] / server / listen.c
index 51e611e63d12ae495e68f29e6a04778219d3b402..ebcf39db20af53ea59b27fec90400a7e3448cc1c 100644 (file)
@@ -65,7 +65,7 @@
 #include "ap_listen.h"
 #include "apr_strings.h"
 #include "http_log.h"
-#include "mpm.h"
+#include "mpm_common.h"
 #ifdef HAVE_STRING_H
 #include <string.h>
 #endif
@@ -82,14 +82,25 @@ static apr_status_t make_sock(apr_pool_t *p, ap_listen_rec *server)
     int one = 1;
     char addr[512];
     apr_status_t stat;
-    apr_uint32_t port;
+    apr_port_t port;
     char *ipaddr;
+    apr_sockaddr_t *localsa;
 
-    apr_get_local_port(&port,s);
-    apr_get_local_ipaddr(&ipaddr,s);
+    apr_get_sockaddr(&localsa, APR_LOCAL, s);
+    apr_get_port(&port, localsa);
+    apr_get_ipaddr(&ipaddr, localsa);
     apr_snprintf(addr, sizeof(addr), "address %s port %u", ipaddr,
                (unsigned) port);
 
+    stat = apr_getaddrinfo(&localsa, ipaddr, APR_INET, port, 0, p);
+    if (stat != APR_SUCCESS) {
+        ap_log_error(APLOG_MARK, APLOG_CRIT, stat, NULL,
+                     "make_sock: for %s/%hu, apr_getaddrinfo() failed", 
+                     ipaddr, port);
+        apr_close_socket(s);
+        return stat;
+    }
+
     stat = apr_setsocketopt(s, APR_SO_REUSEADDR, one);
     if (stat != APR_SUCCESS && stat != APR_ENOTIMPL) {
        ap_log_error(APLOG_MARK, APLOG_CRIT, stat, NULL,
@@ -135,7 +146,11 @@ static apr_status_t make_sock(apr_pool_t *p, ap_listen_rec *server)
        }
     }
 
-    if ((stat = apr_bind(s)) != APR_SUCCESS) {
+#if DISABLE_NAGLE_INHERITED
+    ap_sock_disable_nagle(s);
+#endif
+
+    if ((stat = apr_bind(s, localsa)) != APR_SUCCESS) {
        ap_log_error(APLOG_MARK, APLOG_CRIT, stat, NULL,
            "make_sock: could not bind to %s", addr);
        apr_close_socket(s);
@@ -167,18 +182,20 @@ static apr_status_t close_listeners_on_exec(void *v)
 }
 
 
-static void alloc_listener(process_rec *process, char *addr, unsigned int port)
+static void alloc_listener(process_rec *process, char *addr, apr_port_t port)
 {
     ap_listen_rec **walk;
     ap_listen_rec *new;
     apr_status_t status;
     char *oldaddr;
-    unsigned int oldport;
+    apr_port_t oldport;
+    apr_sockaddr_t *sa;
 
     /* see if we've got an old listener for this address:port */
     for (walk = &old_listeners; *walk; walk = &(*walk)->next) {
-        apr_get_local_port(&oldport, (*walk)->sd);
-       apr_get_local_ipaddr(&oldaddr,(*walk)->sd);
+        apr_get_sockaddr(&sa, APR_LOCAL, (*walk)->sd);
+        apr_get_port(&oldport, sa);
+       apr_get_ipaddr(&oldaddr, sa);
        if (!strcmp(oldaddr, addr) && port == oldport) {
            /* re-use existing record */
            new = *walk;
@@ -192,13 +209,15 @@ static void alloc_listener(process_rec *process, char *addr, unsigned int port)
     /* this has to survive restarts */
     new = apr_palloc(process->pool, sizeof(ap_listen_rec));
     new->active = 0;
-    if ((status = apr_create_tcp_socket(&new->sd, process->pool)) != APR_SUCCESS) {
+    if ((status = apr_create_socket(&new->sd, APR_INET, SOCK_STREAM, 
+                                    process->pool)) != APR_SUCCESS) {
         ap_log_error(APLOG_MARK, APLOG_CRIT, status, NULL,
                  "make_sock: failed to get a socket for %s", addr);
         return;
     }
-    apr_set_local_port(new->sd, port);
-    apr_set_local_ipaddr(new->sd, addr);
+    apr_get_sockaddr(&sa, APR_LOCAL, new->sd);
+    apr_set_port(sa, port);
+    apr_set_ipaddr(sa, addr);
     new->next = ap_listeners;
     ap_listeners = new;
 }
@@ -206,7 +225,7 @@ static void alloc_listener(process_rec *process, char *addr, unsigned int port)
 #if !defined(WIN32) && !defined(SPMT_OS2_MPM)
 static
 #endif
-int ap_listen_open(process_rec *process, unsigned port)
+int ap_listen_open(process_rec *process, apr_port_t port)
 {
     apr_pool_t *pconf = process->pconf;
     ap_listen_rec *lr;