nginx-0.0.10-2004-09-07-19:29:22 import
diff --git a/src/http/modules/ngx_http_userid_filter.c b/src/http/modules/ngx_http_userid_filter.c
index 718cca7..e37accf 100644
--- a/src/http/modules/ngx_http_userid_filter.c
+++ b/src/http/modules/ngx_http_userid_filter.c
@@ -281,7 +281,6 @@
     size_t               len;
     socklen_t            slen;
     struct sockaddr_in   addr_in;
-    uint32_t             service;
     ngx_str_t            src, dst;
     ngx_table_elt_t     *set_cookie;
 
@@ -542,7 +541,7 @@
 
     if (domain->len == 4 && ngx_strcmp(domain->data, "none") == 0) {
         domain->len = 1;
-        domain->data = ".";
+        domain->data = (u_char *) ".";
     }
 
     return NGX_CONF_OK;
diff --git a/src/http/modules/proxy/ngx_http_proxy_handler.c b/src/http/modules/proxy/ngx_http_proxy_handler.c
index 711aad2..af9760c 100644
--- a/src/http/modules/proxy/ngx_http_proxy_handler.c
+++ b/src/http/modules/proxy/ngx_http_proxy_handler.c
@@ -1234,7 +1234,7 @@
                         u->default_port = 1;
                     }
 
-                    u->port = htons((u_short) u->port);
+                    u->port = htons(u->port);
                     return NULL;
                 }
             }
@@ -1265,7 +1265,7 @@
     if (u->port_text.len > 0) {
         u->port = ngx_atoi(u->port_text.data, u->port_text.len);
         if (u->port > 0) {
-            u->port = htons((u_short) u->port);
+            u->port = htons(u->port);
             return NULL;
         }
     }
diff --git a/src/http/modules/proxy/ngx_http_proxy_handler.h b/src/http/modules/proxy/ngx_http_proxy_handler.h
index 6e37258..27799bb 100644
--- a/src/http/modules/proxy/ngx_http_proxy_handler.h
+++ b/src/http/modules/proxy/ngx_http_proxy_handler.h
@@ -41,7 +41,7 @@
     ngx_str_t                        port_text;
     ngx_str_t                       *location;
 
-    ngx_int_t                        port;
+    in_port_t                        port;
 
     unsigned                         default_port:1;
 } ngx_http_proxy_upstream_conf_t;
diff --git a/src/http/ngx_http.c b/src/http/ngx_http.c
index fabb2dd..d02b250 100644
--- a/src/http/ngx_http.c
+++ b/src/http/ngx_http.c
@@ -500,48 +500,12 @@
         in_addr = in_port[p].addrs.elts;
         while (a < in_port[p].addrs.nelts) {
 
-            if (!(ls = ngx_push_array(&cf->cycle->listening))) {
+            ls = ngx_listening_inet_stream_socket(cf, in_addr[a].addr,
+                                                  in_port[p].port);
+            if (ls == NULL) {
                 return NGX_CONF_ERROR;
             }
 
-            ngx_memzero(ls, sizeof(ngx_listening_t));
-
-            addr_in = ngx_pcalloc(cf->pool, sizeof(struct sockaddr_in));
-            if (addr_in == NULL) {
-                return NGX_CONF_ERROR;
-            }
-
-#if (HAVE_SIN_LEN)
-            addr_in->sin_len = sizeof(struct sockaddr_in);
-#endif
-            addr_in->sin_family = AF_INET;
-            addr_in->sin_addr.s_addr = in_addr[a].addr;
-            addr_in->sin_port = htons((u_short) in_port[p].port);
-
-            ls->addr_text.data = ngx_palloc(cf->pool, INET_ADDRSTRLEN + 6);
-            if (ls->addr_text.data == NULL) {
-                return NGX_CONF_ERROR;
-            }
-
-            ls->addr_text.len = ngx_inet_ntop(AF_INET, &in_addr[a].addr,
-                                              ls->addr_text.data,
-                                              INET_ADDRSTRLEN),
-
-            ls->addr_text.len += ngx_snprintf((char *) ls->addr_text.data
-                                                           + ls->addr_text.len,
-                                               6, ":%d", in_port[p].port);
-
-            ls->fd = (ngx_socket_t) -1;
-            ls->family = AF_INET;
-            ls->type = SOCK_STREAM;
-            ls->protocol = IPPROTO_IP;
-#if (WIN32)
-            ls->flags = WSA_FLAG_OVERLAPPED;
-#endif
-            ls->sockaddr = (struct sockaddr *) addr_in;
-            ls->socklen = sizeof(struct sockaddr_in);
-            ls->addr = offsetof(struct sockaddr_in, sin_addr);
-            ls->addr_text_max_len = INET_ADDRSTRLEN;
             ls->backlog = -1;
 #if 0
 #if 0
diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c
index 78bb2a7..6c4f819 100644
--- a/src/http/ngx_http_core_module.c
+++ b/src/http/ngx_http_core_module.c
@@ -1473,7 +1473,8 @@
     ngx_http_core_srv_conf_t *scf = conf;
 
     u_char             *addr;
-    u_int               p;
+    ngx_int_t           port;
+    ngx_uint_t          p;
     struct hostent     *h;
     ngx_str_t          *args;
     ngx_http_listen_t  *ls;
@@ -1505,14 +1506,14 @@
         p = 0;
     }
 
-    ls->port = ngx_atoi(&addr[p], args[1].len - p);
-    if (ls->port == NGX_ERROR && p == 0) {
+    port = ngx_atoi(&addr[p], args[1].len - p);
+    if (port == NGX_ERROR && p == 0) {
 
         /* "listen host" */
         ls->port = 80;
 
-    } else if ((ls->port == NGX_ERROR && p != 0) /* "listen host:NONNUMBER" */
-               || (ls->port < 1 || ls->port > 65536)) { /* "listen 99999" */
+    } else if ((port == NGX_ERROR && p != 0) /* "listen host:NONNUMBER" */
+               || (port < 1 || port > 65536)) { /* "listen 99999" */
 
         ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
                            "invalid port \"%s\" in \"%s\" directive, "
@@ -1523,6 +1524,7 @@
 
     } else if (p == 0) {
         ls->addr = INADDR_ANY;
+        ls->port = (in_port_t) port;
         return NGX_CONF_OK;
     }
 
diff --git a/src/http/ngx_http_core_module.h b/src/http/ngx_http_core_module.h
index 6c0e7a1..25101aa 100644
--- a/src/http/ngx_http_core_module.h
+++ b/src/http/ngx_http_core_module.h
@@ -9,7 +9,7 @@
 
 typedef struct {
     in_addr_t  addr;
-    int        port;
+    in_port_t  port;
     int        family;
     ngx_str_t  file_name;
     int        line;
@@ -78,7 +78,7 @@
 /* list of structures to find core_srv_conf quickly at run time */
 
 typedef struct {
-    int           port;
+    in_port_t     port;
     ngx_str_t     port_name;
     ngx_array_t   addrs;       /* array of ngx_http_in_addr_t */
 } ngx_http_in_port_t;
diff --git a/src/http/ngx_http_parse.c b/src/http/ngx_http_parse.c
index 76fbb80..8136f31 100644
--- a/src/http/ngx_http_parse.c
+++ b/src/http/ngx_http_parse.c
@@ -3,6 +3,7 @@
 #include <ngx_core.h>
 #include <ngx_http.h>
 
+
 ngx_int_t ngx_http_parse_request_line(ngx_http_request_t *r)
 {
     u_char  ch, *p, *m;
diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c
index 52c7c42..dcf53d7 100644
--- a/src/http/ngx_http_request.c
+++ b/src/http/ngx_http_request.c
@@ -1899,109 +1899,10 @@
 
 void ngx_http_close_connection(ngx_connection_t *c)
 {
-    ngx_socket_t  fd;
-
     ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0,
                    "close http connection: %d", c->fd);
 
-    if (c->pool == NULL) {
-        ngx_log_error(NGX_LOG_ALERT, c->log, 0, "connection already closed");
-        return;
-    }
-
-#if (NGX_HTTP_SSL)
-
-    if (c->ssl) {
-        if (ngx_ssl_shutdown(c) == NGX_AGAIN) {
-            c->read->event_handler = ngx_ssl_close_handler;
-            c->write->event_handler = ngx_ssl_close_handler;
-            return;
-        }
-    }
-
-#endif
-
-    if (c->read->timer_set) {
-        ngx_del_timer(c->read);
-    }
-
-    if (c->write->timer_set) {
-        ngx_del_timer(c->write);
-    }
-
-    if (ngx_del_conn) {
-        ngx_del_conn(c, NGX_CLOSE_EVENT);
-
-    } else {
-        if (c->read->active || c->read->disabled) {
-            ngx_del_event(c->read, NGX_READ_EVENT, NGX_CLOSE_EVENT);
-        }
-
-        if (c->write->active || c->write->disabled) {
-            ngx_del_event(c->write, NGX_WRITE_EVENT, NGX_CLOSE_EVENT);
-        }
-    }
-
-    /*
-     * we have to clean the connection information before the closing
-     * because another thread may reopen the same file descriptor
-     * before we clean the connection
-     */
-
-#if (NGX_THREADS)
-
-    if (ngx_mutex_lock(ngx_posted_events_mutex) == NGX_OK) {
-
-        if (c->read->prev) {
-            ngx_delete_posted_event(c->read);
-        }
-
-        if (c->write->prev) {
-            ngx_delete_posted_event(c->write);
-        }
-
-        c->read->closed = 1;
-        c->write->closed = 1;
-
-        if (c->single_connection) {
-            ngx_unlock(&c->lock);
-            c->read->locked = 0;
-            c->write->locked = 0;
-        }
-
-        ngx_mutex_unlock(ngx_posted_events_mutex);
-    }
-
-#else
-
-    if (c->read->prev) {
-        ngx_delete_posted_event(c->read);
-    }
-
-    if (c->write->prev) {
-        ngx_delete_posted_event(c->write);
-    }
-
-    c->read->closed = 1;
-    c->write->closed = 1;
-
-#endif
-
-    fd = c->fd;
-    c->fd = (ngx_socket_t) -1;
-    c->data = NULL;
-
-    ngx_destroy_pool(c->pool);
-
-    if (ngx_close_socket(fd) == -1) {
-
-        /* we use ngx_cycle->log because c->log was in c->pool */
-
-        ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, ngx_socket_errno,
-                      ngx_close_socket_n " failed");
-    }
-
-    return;
+    ngx_close_connection(c);
 }