]> granicus.if.org Git - apache/blobdiff - server/listen.c
Enhancements for APR network_io. Adds separate local/remote access methods for
[apache] / server / listen.c
index b90e83fe9ffb9fe8f4c858874ff14dc27d41be16..b9c5950499496cbeb23a1c0b88d031e1f7093852 100644 (file)
@@ -78,7 +78,7 @@ static ap_status_t make_sock(ap_context_t *p, ap_listen_rec *server)
 
     stat = ap_setsocketopt(s, APR_SO_REUSEADDR, one);
     if (stat != APR_SUCCESS && stat != APR_ENOTIMPL) {
-       ap_log_error(APLOG_MARK, APLOG_CRIT, NULL,
+       ap_log_error(APLOG_MARK, APLOG_CRIT, stat, NULL,
                    "make_sock: for %s, setsockopt: (SO_REUSEADDR)", addr);
        ap_close_socket(s);
        return stat;
@@ -86,7 +86,7 @@ static ap_status_t make_sock(ap_context_t *p, ap_listen_rec *server)
     
     stat = ap_setsocketopt(s, APR_SO_KEEPALIVE, one);
     if (stat != APR_SUCCESS && stat != APR_ENOTIMPL) {
-       ap_log_error(APLOG_MARK, APLOG_CRIT, NULL,
+       ap_log_error(APLOG_MARK, APLOG_CRIT, stat, NULL,
                    "make_sock: for %s, setsockopt: (SO_KEEPALIVE)", addr);
        ap_close_socket(s);
        return stat;
@@ -114,7 +114,7 @@ static ap_status_t make_sock(ap_context_t *p, ap_listen_rec *server)
     if (send_buffer_size) {
        stat = ap_setsocketopt(s, APR_SO_SNDBUF,  send_buffer_size);
         if (stat != APR_SUCCESS && stat != APR_ENOTIMPL) {
-            ap_log_error(APLOG_MARK, APLOG_WARNING, NULL,
+            ap_log_error(APLOG_MARK, APLOG_WARNING, stat, NULL,
                        "make_sock: failed to set SendBufferSize for %s, "
                        "using default", addr);
            /* not a fatal error */
@@ -122,14 +122,14 @@ static ap_status_t make_sock(ap_context_t *p, ap_listen_rec *server)
     }
 
     if ((stat = ap_bind(s)) != APR_SUCCESS) {
-       ap_log_error(APLOG_MARK, APLOG_CRIT, NULL,
+       ap_log_error(APLOG_MARK, APLOG_CRIT, stat, NULL,
            "make_sock: could not bind to %s", addr);
        ap_close_socket(s);
        return stat;
     }
 
     if ((stat = ap_listen(s, ap_listenbacklog)) != APR_SUCCESS) {
-       ap_log_error(APLOG_MARK, APLOG_ERR, NULL,
+       ap_log_error(APLOG_MARK, APLOG_ERR, stat, NULL,
            "make_sock: unable to listen for connections on %s", addr);
        ap_close_socket(s);
        return stat;
@@ -157,13 +157,14 @@ static void alloc_listener(process_rec *process, char *addr, unsigned int port)
 {
     ap_listen_rec **walk;
     ap_listen_rec *new;
-    char oldaddr[17];
+    ap_status_t status;
+    char *oldaddr;
     unsigned int oldport;
 
     /* see if we've got an old listener for this address:port */
     for (walk = &old_listeners; *walk; walk = &(*walk)->next) {
-        ap_getport(&oldport, (*walk)->sd);
-       ap_getipaddr(oldaddr,sizeof oldaddr,(*walk)->sd);
+        ap_get_local_port(&oldport, (*walk)->sd);
+       ap_get_local_ipaddr(&oldaddr,(*walk)->sd);
        if (!strcmp(oldaddr, addr) && port == oldport) {
            /* re-use existing record */
            new = *walk;
@@ -178,13 +179,13 @@ static void alloc_listener(process_rec *process, char *addr, unsigned int port)
     /* XXX - We need to deal with freeing this structure properly. */
     new = ap_palloc(process->pool, sizeof(ap_listen_rec));
     new->active = 0;
-    if (ap_create_tcp_socket(&new->sd, NULL) != APR_SUCCESS) {
-        ap_log_error(APLOG_MARK, APLOG_CRIT, NULL,
+    if ((status = ap_create_tcp_socket(&new->sd, NULL)) != APR_SUCCESS) {
+        ap_log_error(APLOG_MARK, APLOG_CRIT, status, NULL,
                  "make_sock: failed to get a socket for %s", addr);
         return;
     }
-    ap_setport(new->sd, port);
-    ap_setipaddr(new->sd, addr);
+    ap_set_local_port(new->sd, port);
+    ap_set_local_ipaddr(new->sd, addr);
     new->next = ap_listeners;
     ap_listeners = new;
 }