diff src/http/ngx_http.c @ 486:6484cbba0222 NGINX_0_7_55

nginx 0.7.55 *) Bugfix: the http_XXX parameters in "proxy_cache_use_stale" and "fastcgi_cache_use_stale" directives did not work. *) Bugfix: fastcgi cache did not cache header only responses. *) Bugfix: of "select() failed (9: Bad file descriptor)" error in nginx/Unix and "select() failed (10022: ...)" error in nginx/Windows. *) Bugfix: a segmentation fault might occur in worker process, if an "debug_connection" directive was used; the bug had appeared in 0.7.54. *) Bugfix: fix ngx_http_image_filter_module building errors. *) Bugfix: the files bigger than 2G could not be transferred using $r->sendfile. Thanks to Maxim Dounin.
author Igor Sysoev <http://sysoev.ru>
date Wed, 06 May 2009 00:00:00 +0400
parents ed5e10fb40fc
children 98143f74eb3d
line wrap: on
line diff
--- a/src/http/ngx_http.c
+++ b/src/http/ngx_http.c
@@ -1688,54 +1688,14 @@ static ngx_listening_t *
 ngx_http_add_listening(ngx_conf_t *cf, ngx_http_conf_addr_t *addr)
 {
     ngx_listening_t           *ls;
-    struct sockaddr           *sa;
     ngx_http_core_loc_conf_t  *clcf;
     ngx_http_core_srv_conf_t  *cscf;
-    u_char                     text[NGX_SOCKADDR_STRLEN];
 
-    ls = ngx_array_push(&cf->cycle->listening);
+    ls = ngx_create_listening(cf, addr->sockaddr, addr->socklen);
     if (ls == NULL) {
         return NULL;
     }
 
-    ngx_memzero(ls, sizeof(ngx_listening_t));
-
-    sa = ngx_palloc(cf->pool, addr->socklen);
-    if (sa == NULL) {
-        return NULL;
-    }
-
-    ngx_memcpy(sa, addr->sockaddr, addr->socklen);
-
-    ls->sockaddr = sa;
-    ls->socklen = addr->socklen;
-
-    ls->addr_text.len = ngx_sock_ntop(sa, text, NGX_SOCKADDR_STRLEN, 1);
-
-    ls->addr_text.data = ngx_pnalloc(cf->pool, ls->addr_text.len);
-    if (ls->addr_text.data == NULL) {
-        return NULL;
-    }
-
-    ngx_memcpy(ls->addr_text.data, text, ls->addr_text.len);
-
-    ls->fd = (ngx_socket_t) -1;
-    ls->type = SOCK_STREAM;
-
-    switch (ls->sockaddr->sa_family) {
-#if (NGX_HAVE_INET6)
-    case AF_INET6:
-         ls->addr_text_max_len = NGX_INET6_ADDRSTRLEN;
-         break;
-#endif
-    case AF_INET:
-         ls->addr_text_max_len = NGX_INET_ADDRSTRLEN;
-         break;
-    default:
-         ls->addr_text_max_len = NGX_SOCKADDR_STRLEN;
-         break;
-    }
-
     ls->addr_ntop = 1;
 
     ls->handler = ngx_http_init_connection;