diff src/http/ngx_http.c @ 72:b31656313b59 NGINX_0_1_36

nginx 0.1.36 *) Change: if the request header has duplicate the "Host", "Connection", "Content-Length", or "Authorization" lines, then nginx now returns the 400 error. *) Change: the "post_accept_timeout" directive was canceled. *) Feature: the "default", "af=", "bl=", "deferred", and "bind" parameters of the "listen" directive. *) Feature: the FreeBSD accept filters support. *) Feature: the Linux TCP_DEFER_ACCEPT support. *) Bugfix: the ngx_http_autoindex_module did not support the file names in UTF-8. *) Bugfix: the new log file can be rotated by the -USR1 signal only if the reconfiguration by the -HUP signal was made twice.
author Igor Sysoev <http://sysoev.ru>
date Wed, 15 Jun 2005 00:00:00 +0400
parents 8ad297c88dcb
children 71c46860eb55
line wrap: on
line diff
--- a/src/http/ngx_http.c
+++ b/src/http/ngx_http.c
@@ -66,8 +66,9 @@ static char *
 ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
 {
     char                        *rv;
-    ngx_uint_t                   mi, m, s, l, p, a, n;
-    ngx_uint_t                   port_found, addr_found, virtual_names, key;
+    ngx_uint_t                   mi, m, s, l, p, a, n, key;
+    ngx_uint_t                   port_found, addr_found;
+    ngx_uint_t                   virtual_names, separate_binding;
     ngx_conf_t                   pcf;
     ngx_array_t                  in_ports;
     ngx_listening_t             *ls;
@@ -408,9 +409,9 @@ ngx_http_block(ngx_conf_t *cf, ngx_comma
                              * for this address:port
                              */
 
-                            if (lscf[l].default_server) {
+                            if (lscf[l].conf.default_server) {
 
-                                if (in_addr[a].default_server) {
+                                if (in_addr[a].conf.default_server) {
                                     ngx_log_error(NGX_LOG_ERR, cf->log, 0,
                                         "the duplicate default server in %V:%d",
                                         &lscf[l].file_name, lscf[l].line);
@@ -419,7 +420,7 @@ ngx_http_block(ngx_conf_t *cf, ngx_comma
                                 }
 
                                 in_addr[a].core_srv_conf = cscfp[s];
-                                in_addr[a].default_server = 1;
+                                in_addr[a].conf.default_server = 1;
                             }
 
                             addr_found = 1;
@@ -449,8 +450,8 @@ ngx_http_block(ngx_conf_t *cf, ngx_comma
                             in_addr[a].names.elts = NULL;
                             in_addr[a].hash = NULL;
                             in_addr[a].wildcards.elts = NULL;
-                            in_addr[a].default_server = lscf[l].default_server;
                             in_addr[a].core_srv_conf = cscfp[s];
+                            in_addr[a].conf = lscf[l].conf;
 
                             if (ngx_http_add_names(cf, &in_addr[a], cscfp[s])
                                 != NGX_OK)
@@ -518,6 +519,8 @@ ngx_http_block(ngx_conf_t *cf, ngx_comma
     in_port = in_ports.elts;
     for (p = 0; p < in_ports.nelts; p++) {
 
+        separate_binding = 0;
+
         /*
          * check whether all name-based servers have the same configuraiton
          * as the default server, or some servers restrict the host names
@@ -526,6 +529,10 @@ ngx_http_block(ngx_conf_t *cf, ngx_comma
         in_addr = in_port[p].addrs.elts;
         for (a = 0; a < in_port[p].addrs.nelts; a++) {
 
+            if (in_addr[a].conf.bind) {
+                separate_binding = 1;
+            }
+
             virtual_names = 0;
 
             name = in_addr[a].names.elts;
@@ -608,7 +615,7 @@ ngx_http_block(ngx_conf_t *cf, ngx_comma
          * to the "*:port" only and ignore the other bindings
          */
 
-        if (in_addr[a - 1].addr == INADDR_ANY) {
+        if (in_addr[a - 1].addr == INADDR_ANY && !separate_binding) {
             a--;
 
         } else {
@@ -624,15 +631,13 @@ ngx_http_block(ngx_conf_t *cf, ngx_comma
                 return NGX_CONF_ERROR;
             }
 
-            ls->backlog = -1;
-
             ls->addr_ntop = 1;
 
             ls->handler = ngx_http_init_connection;
 
             cscf = in_addr[a].core_srv_conf;
             ls->pool_size = cscf->connection_pool_size;
-            ls->post_accept_timeout = cscf->post_accept_timeout;
+            ls->post_accept_timeout = cscf->client_header_timeout;
 
             clcf = cscf->ctx->loc_conf[ngx_http_core_module.ctx_index];
             ls->log = clcf->err_log;
@@ -644,6 +649,16 @@ ngx_http_block(ngx_conf_t *cf, ngx_comma
             }
 #endif
 
+            ls->backlog = in_addr[a].conf.backlog;
+
+#if (NGX_HAVE_DEFERRED_ACCEPT && defined SO_ACCEPTFILTER)
+            ls->accept_filter = in_addr[a].conf.accept_filter;
+#endif
+
+#if (NGX_HAVE_DEFERRED_ACCEPT && defined TCP_DEFER_ACCEPT)
+            ls->deferred_accept = in_addr[a].conf.deferred_accept;
+#endif
+
             ls->ctx = ctx;
 
             if (in_port[p].addrs.nelts > 1) {
@@ -766,8 +781,8 @@ ngx_http_add_address(ngx_conf_t *cf, ngx
     in_addr->names.elts = NULL;
     in_addr->hash = NULL;
     in_addr->wildcards.elts = NULL;
-    in_addr->default_server = lscf->default_server;
     in_addr->core_srv_conf = cscf;
+    in_addr->conf = lscf->conf;
 
 #if (NGX_DEBUG)
     {