From mdounin at mdounin.ru Mon Jul 2 14:42:09 2012 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Mon, 2 Jul 2012 14:42:09 +0000 Subject: [nginx] svn commit: r4714 - in branches/stable-1.2: . src/http Message-ID: <20120702144209.3A9F43F9F2B@mail.nginx.com> Author: mdounin Date: 2012-07-02 14:42:08 +0000 (Mon, 02 Jul 2012) New Revision: 4714 URL: http://trac.nginx.org/nginx/changeset/4714/nginx Log: Merge of r4642: Fixed core variables dynamic access after reconfiguration. If variable was indexed in previous configuration but not in current one, the NGX_HTTP_VAR_INDEXED flag was left set and confused ngx_http_get_variable(). Patch by Yichun Zhang (agentzh), slightly modified. Modified: branches/stable-1.2/ branches/stable-1.2/src/http/ngx_http_variables.c Index: branches/stable-1.2 =================================================================== --- branches/stable-1.2 2012-06-29 20:33:26 UTC (rev 4713) +++ branches/stable-1.2 2012-07-02 14:42:08 UTC (rev 4714) Property changes on: branches/stable-1.2 ___________________________________________________________________ Modified: svn:mergeinfo ## -1 +1 ## -/trunk:4611-4632,4636-4641,4645,4674-4676 +/trunk:4611-4632,4636-4642,4645,4674-4676 \ No newline at end of property Modified: branches/stable-1.2/src/http/ngx_http_variables.c =================================================================== --- branches/stable-1.2/src/http/ngx_http_variables.c 2012-06-29 20:33:26 UTC (rev 4713) +++ branches/stable-1.2/src/http/ngx_http_variables.c 2012-07-02 14:42:08 UTC (rev 4714) @@ -2016,7 +2016,7 @@ ngx_http_variables_add_core_vars(ngx_conf_t *cf) { ngx_int_t rc; - ngx_http_variable_t *v; + ngx_http_variable_t *cv, *v; ngx_http_core_main_conf_t *cmcf; cmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module); @@ -2036,7 +2036,14 @@ return NGX_ERROR; } - for (v = ngx_http_core_variables; v->name.len; v++) { + for (cv = ngx_http_core_variables; cv->name.len; cv++) { + v = ngx_palloc(cf->pool, sizeof(ngx_http_variable_t)); + if (v == NULL) { + return NGX_ERROR; + } + + *v = *cv; + rc = ngx_hash_add_key(cmcf->variables_keys, &v->name, v, NGX_HASH_READONLY_KEY); From mdounin at mdounin.ru Mon Jul 2 15:33:35 2012 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Mon, 2 Jul 2012 15:33:35 +0000 Subject: [nginx] svn commit: r4715 - in branches/stable-1.2: . src/core Message-ID: <20120702153336.4A48F3F9F2B@mail.nginx.com> Author: mdounin Date: 2012-07-02 15:33:35 +0000 (Mon, 02 Jul 2012) New Revision: 4715 URL: http://trac.nginx.org/nginx/changeset/4715/nginx Log: Merge of r4643: Removed historical and now redundant syntax pre-checks in ngx_parse_url(). Modified: branches/stable-1.2/ branches/stable-1.2/src/core/ngx_inet.c Index: branches/stable-1.2 =================================================================== --- branches/stable-1.2 2012-07-02 14:42:08 UTC (rev 4714) +++ branches/stable-1.2 2012-07-02 15:33:35 UTC (rev 4715) Property changes on: branches/stable-1.2 ___________________________________________________________________ Modified: svn:mergeinfo ## -1 +1 ## -/trunk:4611-4632,4636-4642,4645,4674-4676 +/trunk:4611-4632,4636-4643,4645,4674-4676 \ No newline at end of property Modified: branches/stable-1.2/src/core/ngx_inet.c =================================================================== --- branches/stable-1.2/src/core/ngx_inet.c 2012-07-02 14:42:08 UTC (rev 4714) +++ branches/stable-1.2/src/core/ngx_inet.c 2012-07-02 15:33:35 UTC (rev 4715) @@ -522,11 +522,6 @@ return ngx_parse_unix_domain_url(pool, u); } - if ((p[0] == ':' || p[0] == '/') && !u->listen) { - u->err = "invalid host"; - return NGX_ERROR; - } - if (p[0] == '[') { return ngx_parse_inet6_url(pool, u); } From mdounin at mdounin.ru Mon Jul 2 15:35:22 2012 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Mon, 2 Jul 2012 15:35:22 +0000 Subject: [nginx] svn commit: r4716 - in branches/stable-1.2: . src/core Message-ID: <20120702153523.15A403F9F2B@mail.nginx.com> Author: mdounin Date: 2012-07-02 15:35:22 +0000 (Mon, 02 Jul 2012) New Revision: 4716 URL: http://trac.nginx.org/nginx/changeset/4716/nginx Log: Merge of r4644: Fixed potential null pointer dereference in ngx_resolver_create(). While here, improved error message. Modified: branches/stable-1.2/ branches/stable-1.2/src/core/ngx_resolver.c Index: branches/stable-1.2 =================================================================== --- branches/stable-1.2 2012-07-02 15:33:35 UTC (rev 4715) +++ branches/stable-1.2 2012-07-02 15:35:22 UTC (rev 4716) Property changes on: branches/stable-1.2 ___________________________________________________________________ Modified: svn:mergeinfo ## -1 +1 ## -/trunk:4611-4632,4636-4643,4645,4674-4676 +/trunk:4611-4632,4636-4645,4674-4676 \ No newline at end of property Modified: branches/stable-1.2/src/core/ngx_resolver.c =================================================================== --- branches/stable-1.2/src/core/ngx_resolver.c 2012-07-02 15:33:35 UTC (rev 4715) +++ branches/stable-1.2/src/core/ngx_resolver.c 2012-07-02 15:35:22 UTC (rev 4716) @@ -175,7 +175,12 @@ u.port = 53; if (ngx_inet_resolve_host(cf->pool, &u) != NGX_OK) { - ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "%V: %s", &u.host, u.err); + if (u.err) { + ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, + "%s in resolver \"%V\"", + u.err, &u.host); + } + return NULL; } From mdounin at mdounin.ru Mon Jul 2 15:37:49 2012 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Mon, 2 Jul 2012 15:37:49 +0000 Subject: [nginx] svn commit: r4717 - in branches/stable-1.2: . src/os/unix Message-ID: <20120702153749.F14A53F9F5D@mail.nginx.com> Author: mdounin Date: 2012-07-02 15:37:49 +0000 (Mon, 02 Jul 2012) New Revision: 4717 URL: http://trac.nginx.org/nginx/changeset/4717/nginx Log: Merge of r4646: jemalloc 3.0.0 compatibility. Fixed compilation with -DNGX_DEBUG_MALLOC on FreeBSD 10. After jemalloc 3.0.0 import there is no _malloc_options symbol, it has been replaced with the malloc_conf one with a different syntax. Modified: branches/stable-1.2/ branches/stable-1.2/src/os/unix/ngx_freebsd_init.c Index: branches/stable-1.2 =================================================================== --- branches/stable-1.2 2012-07-02 15:35:22 UTC (rev 4716) +++ branches/stable-1.2 2012-07-02 15:37:49 UTC (rev 4717) Property changes on: branches/stable-1.2 ___________________________________________________________________ Modified: svn:mergeinfo ## -1 +1 ## -/trunk:4611-4632,4636-4645,4674-4676 +/trunk:4611-4632,4636-4646,4674-4676 \ No newline at end of property Modified: branches/stable-1.2/src/os/unix/ngx_freebsd_init.c =================================================================== --- branches/stable-1.2/src/os/unix/ngx_freebsd_init.c 2012-07-02 15:35:22 UTC (rev 4716) +++ branches/stable-1.2/src/os/unix/ngx_freebsd_init.c 2012-07-02 15:37:49 UTC (rev 4717) @@ -76,9 +76,9 @@ { #if (NGX_DEBUG_MALLOC) -#if __FreeBSD_version >= 500014 +#if __FreeBSD_version >= 500014 && __FreeBSD_version < 1000011 _malloc_options = "J"; -#else +#elif __FreeBSD_version < 500014 malloc_options = "J"; #endif From mdounin at mdounin.ru Mon Jul 2 15:39:28 2012 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Mon, 2 Jul 2012 15:39:28 +0000 Subject: [nginx] svn commit: r4718 - in branches/stable-1.2: . src/http/modules Message-ID: <20120702153928.804293F9F3E@mail.nginx.com> Author: mdounin Date: 2012-07-02 15:39:28 +0000 (Mon, 02 Jul 2012) New Revision: 4718 URL: http://trac.nginx.org/nginx/changeset/4718/nginx Log: Merge of r4647: xslt reuse. Fixed the reuse of parsed DTDs and XSLTs. Patch by Kuramoto Eiji. Modified: branches/stable-1.2/ branches/stable-1.2/src/http/modules/ngx_http_xslt_filter_module.c Index: branches/stable-1.2 =================================================================== --- branches/stable-1.2 2012-07-02 15:37:49 UTC (rev 4717) +++ branches/stable-1.2 2012-07-02 15:39:28 UTC (rev 4718) Property changes on: branches/stable-1.2 ___________________________________________________________________ Modified: svn:mergeinfo ## -1 +1 ## -/trunk:4611-4632,4636-4646,4674-4676 +/trunk:4611-4632,4636-4647,4674-4676 \ No newline at end of property Modified: branches/stable-1.2/src/http/modules/ngx_http_xslt_filter_module.c =================================================================== --- branches/stable-1.2/src/http/modules/ngx_http_xslt_filter_module.c 2012-07-02 15:37:49 UTC (rev 4717) +++ branches/stable-1.2/src/http/modules/ngx_http_xslt_filter_module.c 2012-07-02 15:39:28 UTC (rev 4718) @@ -810,7 +810,7 @@ file = xmcf->dtd_files.elts; for (i = 0; i < xmcf->dtd_files.nelts; i++) { - if (ngx_strcmp(file[i].name, &value[1].data) == 0) { + if (ngx_strcmp(file[i].name, value[1].data) == 0) { xlcf->dtd = file[i].data; return NGX_CONF_OK; } @@ -884,7 +884,7 @@ file = xmcf->sheet_files.elts; for (i = 0; i < xmcf->sheet_files.nelts; i++) { - if (ngx_strcmp(file[i].name, &value[1].data) == 0) { + if (ngx_strcmp(file[i].name, value[1].data) == 0) { sheet->stylesheet = file[i].data; goto found; } From mdounin at mdounin.ru Mon Jul 2 15:41:32 2012 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Mon, 2 Jul 2012 15:41:32 +0000 Subject: [nginx] svn commit: r4719 - in branches/stable-1.2: . src/http/modules Message-ID: <20120702154132.9B7443FA0AA@mail.nginx.com> Author: mdounin Date: 2012-07-02 15:41:31 +0000 (Mon, 02 Jul 2012) New Revision: 4719 URL: http://trac.nginx.org/nginx/changeset/4719/nginx Log: Merge of r4648, r4649, r4650: memory leak with $geoip_org. Patch by Denis F. Latypoff (slightly modified). Modified: branches/stable-1.2/ branches/stable-1.2/src/http/modules/ngx_http_geoip_module.c Index: branches/stable-1.2 =================================================================== --- branches/stable-1.2 2012-07-02 15:39:28 UTC (rev 4718) +++ branches/stable-1.2 2012-07-02 15:41:31 UTC (rev 4719) Property changes on: branches/stable-1.2 ___________________________________________________________________ Modified: svn:mergeinfo ## -1 +1 ## -/trunk:4611-4632,4636-4647,4674-4676 +/trunk:4611-4632,4636-4650,4674-4676 \ No newline at end of property Modified: branches/stable-1.2/src/http/modules/ngx_http_geoip_module.c =================================================================== --- branches/stable-1.2/src/http/modules/ngx_http_geoip_module.c 2012-07-02 15:39:28 UTC (rev 4718) +++ branches/stable-1.2/src/http/modules/ngx_http_geoip_module.c 2012-07-02 15:41:31 UTC (rev 4719) @@ -28,7 +28,7 @@ } ngx_http_geoip_var_t; -typedef const char *(*ngx_http_geoip_variable_handler_pt)(GeoIP *, u_long addr); +typedef char *(*ngx_http_geoip_variable_handler_pt)(GeoIP *, u_long addr); static u_long ngx_http_geoip_addr(ngx_http_request_t *r, ngx_http_geoip_conf_t *gcf); @@ -291,7 +291,8 @@ ngx_http_geoip_variable_handler_pt handler = (ngx_http_geoip_variable_handler_pt) data; - const char *val; + size_t len; + char *val; ngx_http_geoip_conf_t *gcf; gcf = ngx_http_get_module_main_conf(r, ngx_http_geoip_module); @@ -306,12 +307,22 @@ goto not_found; } - v->len = ngx_strlen(val); + len = ngx_strlen(val); + v->data = ngx_pnalloc(r->pool, len); + if (v->data == NULL) { + ngx_free(val); + return NGX_ERROR; + } + + ngx_memcpy(v->data, val, len); + + v->len = len; v->valid = 1; v->no_cacheable = 0; v->not_found = 0; - v->data = (u_char *) val; + ngx_free(val); + return NGX_OK; not_found: From mdounin at mdounin.ru Mon Jul 2 15:43:51 2012 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Mon, 2 Jul 2012 15:43:51 +0000 Subject: [nginx] svn commit: r4720 - in branches/stable-1.2: . src/http Message-ID: <20120702154351.5C6FA3F9C1B@mail.nginx.com> Author: mdounin Date: 2012-07-02 15:43:50 +0000 (Mon, 02 Jul 2012) New Revision: 4720 URL: http://trac.nginx.org/nginx/changeset/4720/nginx Log: Merge of r4651: proxy_cookie_* fix. Fixed returned value handling from the cookie rewrite handler. If the "proxy_cookie_domain" or "proxy_cookie_path" directive is used and there are no matches in Set-Cookie header then ngx_http_proxy_rewrite_cookie() returns NGX_DECLINED to indicate that the header was not rewritten. Returning this value further from the upstream headers copy handler resulted in 500 error response. See here for report: http://mailman.nginx.org/pipermail/nginx/2012-May/033858.html Modified: branches/stable-1.2/ branches/stable-1.2/src/http/ngx_http_upstream.c Index: branches/stable-1.2 =================================================================== --- branches/stable-1.2 2012-07-02 15:41:31 UTC (rev 4719) +++ branches/stable-1.2 2012-07-02 15:43:50 UTC (rev 4720) Property changes on: branches/stable-1.2 ___________________________________________________________________ Modified: svn:mergeinfo ## -1 +1 ## -/trunk:4611-4632,4636-4650,4674-4676 +/trunk:4611-4632,4636-4651,4674-4676 \ No newline at end of property Modified: branches/stable-1.2/src/http/ngx_http_upstream.c =================================================================== --- branches/stable-1.2/src/http/ngx_http_upstream.c 2012-07-02 15:41:31 UTC (rev 4719) +++ branches/stable-1.2/src/http/ngx_http_upstream.c 2012-07-02 15:43:50 UTC (rev 4720) @@ -3677,6 +3677,7 @@ ngx_http_upstream_rewrite_set_cookie(ngx_http_request_t *r, ngx_table_elt_t *h, ngx_uint_t offset) { + ngx_int_t rc; ngx_table_elt_t *ho; ho = ngx_list_push(&r->headers_out.headers); @@ -3687,7 +3688,20 @@ *ho = *h; if (r->upstream->rewrite_cookie) { - return r->upstream->rewrite_cookie(r, ho); + rc = r->upstream->rewrite_cookie(r, ho); + + if (rc == NGX_DECLINED) { + return NGX_OK; + } + +#if (NGX_DEBUG) + if (rc == NGX_OK) { + ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, + "rewritten cookie: \"%V\"", &ho->value); + } +#endif + + return rc; } return NGX_OK; From mdounin at mdounin.ru Mon Jul 2 15:51:02 2012 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Mon, 2 Jul 2012 15:51:02 +0000 Subject: [nginx] svn commit: r4721 - in branches/stable-1.2: . src/event Message-ID: <20120702155103.065E83F9F2F@mail.nginx.com> Author: mdounin Date: 2012-07-02 15:51:02 +0000 (Mon, 02 Jul 2012) New Revision: 4721 URL: http://trac.nginx.org/nginx/changeset/4721/nginx Log: Merge of r4652: ssl without buffer should not set c->buffered. Removed mistaken setting of NGX_SSL_BUFFERED flag in ngx_ssl_send_chain() if SSL buffer is not used. Modified: branches/stable-1.2/ branches/stable-1.2/src/event/ngx_event_openssl.c Index: branches/stable-1.2 =================================================================== --- branches/stable-1.2 2012-07-02 15:43:50 UTC (rev 4720) +++ branches/stable-1.2 2012-07-02 15:51:02 UTC (rev 4721) Property changes on: branches/stable-1.2 ___________________________________________________________________ Modified: svn:mergeinfo ## -1 +1 ## -/trunk:4611-4632,4636-4651,4674-4676 +/trunk:4611-4632,4636-4652,4674-4676 \ No newline at end of property Modified: branches/stable-1.2/src/event/ngx_event_openssl.c =================================================================== --- branches/stable-1.2/src/event/ngx_event_openssl.c 2012-07-02 15:43:50 UTC (rev 4720) +++ branches/stable-1.2/src/event/ngx_event_openssl.c 2012-07-02 15:51:02 UTC (rev 4721) @@ -990,7 +990,6 @@ } if (n == NGX_AGAIN) { - c->buffered |= NGX_SSL_BUFFERED; return in; } From mdounin at mdounin.ru Mon Jul 2 16:11:02 2012 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Mon, 2 Jul 2012 16:11:02 +0000 Subject: [nginx] svn commit: r4722 - in branches/stable-1.2: . src/core Message-ID: <20120702161102.A0FBD3FA0F4@mail.nginx.com> Author: mdounin Date: 2012-07-02 16:11:02 +0000 (Mon, 02 Jul 2012) New Revision: 4722 URL: http://trac.nginx.org/nginx/changeset/4722/nginx Log: Merge of r4653: ngx_inet.c code reduction. Code reduction (no functional changes). Modified: branches/stable-1.2/ branches/stable-1.2/src/core/ngx_inet.c Index: branches/stable-1.2 =================================================================== --- branches/stable-1.2 2012-07-02 15:51:02 UTC (rev 4721) +++ branches/stable-1.2 2012-07-02 16:11:02 UTC (rev 4722) Property changes on: branches/stable-1.2 ___________________________________________________________________ Modified: svn:mergeinfo ## -1 +1 ## -/trunk:4611-4632,4636-4652,4674-4676 +/trunk:4611-4632,4636-4653,4674-4676 \ No newline at end of property Modified: branches/stable-1.2/src/core/ngx_inet.c =================================================================== --- branches/stable-1.2/src/core/ngx_inet.c 2012-07-02 15:51:02 UTC (rev 4721) +++ branches/stable-1.2/src/core/ngx_inet.c 2012-07-02 16:11:02 UTC (rev 4722) @@ -634,11 +634,8 @@ args = ngx_strlchr(host, last, '?'); if (args) { - if (uri == NULL) { + if (uri == NULL || args < uri) { uri = args; - - } else if (args < uri) { - uri = args; } } @@ -663,11 +660,6 @@ len = last - port; - if (len == 0) { - u->err = "invalid port"; - return NGX_ERROR; - } - n = ngx_atoi(port, len); if (n < 1 || n > 65535) { @@ -774,11 +766,7 @@ return NGX_OK; } - if (ngx_inet_resolve_host(pool, u) != NGX_OK) { - return NGX_ERROR; - } - - return NGX_OK; + return ngx_inet_resolve_host(pool, u); } @@ -827,11 +815,6 @@ len = last - port; - if (len == 0) { - u->err = "invalid port"; - return NGX_ERROR; - } - n = ngx_atoi(port, len); if (n < 1 || n > 65535) { From mdounin at mdounin.ru Mon Jul 2 16:16:27 2012 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Mon, 2 Jul 2012 16:16:27 +0000 Subject: [nginx] svn commit: r4723 - in branches/stable-1.2: . src/core Message-ID: <20120702161627.AF1293F9F2B@mail.nginx.com> Author: mdounin Date: 2012-07-02 16:16:27 +0000 (Mon, 02 Jul 2012) New Revision: 4723 URL: http://trac.nginx.org/nginx/changeset/4723/nginx Log: Merge of r4671: support for IPv6 literals in proxy_pass and so on. Modified: branches/stable-1.2/ branches/stable-1.2/src/core/ngx_inet.c Index: branches/stable-1.2 =================================================================== --- branches/stable-1.2 2012-07-02 16:11:02 UTC (rev 4722) +++ branches/stable-1.2 2012-07-02 16:16:27 UTC (rev 4723) Property changes on: branches/stable-1.2 ___________________________________________________________________ Modified: svn:mergeinfo ## -1 +1 ## -/trunk:4611-4632,4636-4653,4674-4676 +/trunk:4611-4632,4636-4653,4671,4674-4676 \ No newline at end of property Modified: branches/stable-1.2/src/core/ngx_inet.c =================================================================== --- branches/stable-1.2/src/core/ngx_inet.c 2012-07-02 16:11:02 UTC (rev 4722) +++ branches/stable-1.2/src/core/ngx_inet.c 2012-07-02 16:16:27 UTC (rev 4723) @@ -808,6 +808,8 @@ u->uri.len = last - uri; u->uri.data = uri; + + last = uri; } if (*port == ':') { @@ -840,8 +842,8 @@ return NGX_ERROR; } - u->host.len = len; - u->host.data = host; + u->host.len = len + 2; + u->host.data = host - 1; if (ngx_inet6_addr(host, len, sin6->sin6_addr.s6_addr) != NGX_OK) { u->err = "invalid IPv6 address"; @@ -852,17 +854,38 @@ u->wildcard = 1; } + if (u->no_port) { + u->port = u->default_port; + sin6->sin6_port = htons(u->default_port); + } + u->family = AF_INET6; + u->naddrs = 1; - if (u->no_resolve) { - return NGX_OK; + u->addrs = ngx_pcalloc(pool, sizeof(ngx_addr_t)); + if (u->addrs == NULL) { + return NGX_ERROR; } - if (u->no_port) { - u->port = u->default_port; - sin6->sin6_port = htons(u->default_port); + sin6 = ngx_pcalloc(pool, sizeof(struct sockaddr_in6)); + if (sin6 == NULL) { + return NGX_ERROR; } + ngx_memcpy(sin6, u->sockaddr, sizeof(struct sockaddr_in6)); + + u->addrs[0].sockaddr = (struct sockaddr *) sin6; + u->addrs[0].socklen = sizeof(struct sockaddr_in6); + + p = ngx_pnalloc(pool, u->host.len + sizeof(":65535") - 1); + if (p == NULL) { + return NGX_ERROR; + } + + u->addrs[0].name.len = ngx_sprintf(p, "%V:%d", + &u->host, u->port) - p; + u->addrs[0].name.data = p; + return NGX_OK; #else From mdounin at mdounin.ru Mon Jul 2 16:23:15 2012 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Mon, 2 Jul 2012 16:23:15 +0000 Subject: [nginx] svn commit: r4724 - in branches/stable-1.2: . src/core src/os/unix Message-ID: <20120702162315.94CD73F9F2A@mail.nginx.com> Author: mdounin Date: 2012-07-02 16:23:14 +0000 (Mon, 02 Jul 2012) New Revision: 4724 URL: http://trac.nginx.org/nginx/changeset/4724/nginx Log: Merge of r4654, r4672, r4684, r4685, r4692: resolver changes. *) Resolver: fixed format specification. Patch by Yichun Zhang (agentzh). *) Support for IPv6 literals and an optional port in resolver. *) Fixed crash in ngx_resolver_cleanup_tree(). If sending a DNS request fails with an error (e.g., when mistakenly trying to send it to a local IP broadcast), such a request is not deleted if there are clients waiting on it. However, it was still erroneously removed from the queue. Later ngx_resolver_cleanup_tree() attempted to remove it from the queue again that resulted in a NULL pointer dereference. *) When "resolver" is configured with a domain name, only the first resolved address was used. Now all addresses will be used. *) Fixed segfault with poll and resolver used. Poll event method needs ngx_cycle->files to work, and use of ngx_exit_cycle without files set caused null pointer dereference in resolver's cleanup on udp socket close. Modified: branches/stable-1.2/ branches/stable-1.2/src/core/ngx_resolver.c branches/stable-1.2/src/os/unix/ngx_process_cycle.c Index: branches/stable-1.2 =================================================================== --- branches/stable-1.2 2012-07-02 16:16:27 UTC (rev 4723) +++ branches/stable-1.2 2012-07-02 16:23:14 UTC (rev 4724) Property changes on: branches/stable-1.2 ___________________________________________________________________ Modified: svn:mergeinfo ## -1 +1 ## -/trunk:4611-4632,4636-4653,4671,4674-4676 +/trunk:4611-4632,4636-4654,4671-4672,4674-4676,4684-4685,4692 \ No newline at end of property Modified: branches/stable-1.2/src/core/ngx_resolver.c =================================================================== --- branches/stable-1.2/src/core/ngx_resolver.c 2012-07-02 16:16:27 UTC (rev 4723) +++ branches/stable-1.2/src/core/ngx_resolver.c 2012-07-02 16:23:14 UTC (rev 4724) @@ -96,7 +96,7 @@ { ngx_str_t s; ngx_url_t u; - ngx_uint_t i; + ngx_uint_t i, j; ngx_resolver_t *r; ngx_pool_cleanup_t *cln; ngx_udp_connection_t *uc; @@ -171,29 +171,31 @@ ngx_memzero(&u, sizeof(ngx_url_t)); - u.host = names[i]; - u.port = 53; + u.url = names[i]; + u.default_port = 53; - if (ngx_inet_resolve_host(cf->pool, &u) != NGX_OK) { + if (ngx_parse_url(cf->pool, &u) != NGX_OK) { if (u.err) { ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "%s in resolver \"%V\"", - u.err, &u.host); + u.err, &u.url); } return NULL; } - uc = ngx_array_push(&r->udp_connections); + uc = ngx_array_push_n(&r->udp_connections, u.naddrs); if (uc == NULL) { return NULL; } - ngx_memzero(uc, sizeof(ngx_udp_connection_t)); + ngx_memzero(uc, u.naddrs * sizeof(ngx_udp_connection_t)); - uc->sockaddr = u.addrs->sockaddr; - uc->socklen = u.addrs->socklen; - uc->server = u.addrs->name; + for (j = 0; j < u.naddrs; j++) { + uc[j].sockaddr = u.addrs[j].sockaddr; + uc[j].socklen = u.addrs[j].socklen; + uc[j].server = u.addrs[j].name; + } } return r; @@ -977,12 +979,11 @@ if (rn->waiting) { - if (ngx_resolver_send_query(r, rn) == NGX_OK) { + (void) ngx_resolver_send_query(r, rn); - rn->expire = now + r->resend_timeout; + rn->expire = now + r->resend_timeout; - ngx_queue_insert_head(queue, &rn->queue); - } + ngx_queue_insert_head(queue, q); continue; } @@ -1040,7 +1041,7 @@ nan = (query->nan_hi << 8) + query->nan_lo; ngx_log_debug6(NGX_LOG_DEBUG_CORE, r->log, 0, - "resolver DNS response %ui fl:%04Xui %ui/%ui/%ui/%ui", + "resolver DNS response %ui fl:%04Xui %ui/%ui/%ud/%ud", ident, flags, nqs, nan, (query->nns_hi << 8) + query->nns_lo, (query->nar_hi << 8) + query->nar_lo); @@ -2189,7 +2190,7 @@ ngx_socket_t s; ngx_connection_t *c; - s = ngx_socket(AF_INET, SOCK_DGRAM, 0); + s = ngx_socket(uc->sockaddr->sa_family, SOCK_DGRAM, 0); ngx_log_debug1(NGX_LOG_DEBUG_EVENT, &uc->log, 0, "UDP socket %d", s); Modified: branches/stable-1.2/src/os/unix/ngx_process_cycle.c =================================================================== --- branches/stable-1.2/src/os/unix/ngx_process_cycle.c 2012-07-02 16:16:27 UTC (rev 4723) +++ branches/stable-1.2/src/os/unix/ngx_process_cycle.c 2012-07-02 16:23:14 UTC (rev 4724) @@ -711,6 +711,8 @@ ngx_exit_log.file = &ngx_exit_log_file; ngx_exit_cycle.log = &ngx_exit_log; + ngx_exit_cycle.files = ngx_cycle->files; + ngx_exit_cycle.files_n = ngx_cycle->files_n; ngx_cycle = &ngx_exit_cycle; ngx_destroy_pool(cycle->pool); @@ -1054,6 +1056,8 @@ ngx_exit_log.file = &ngx_exit_log_file; ngx_exit_cycle.log = &ngx_exit_log; + ngx_exit_cycle.files = ngx_cycle->files; + ngx_exit_cycle.files_n = ngx_cycle->files_n; ngx_cycle = &ngx_exit_cycle; ngx_destroy_pool(cycle->pool); From mdounin at mdounin.ru Mon Jul 2 16:41:14 2012 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Mon, 2 Jul 2012 16:41:14 +0000 Subject: [nginx] svn commit: r4725 - in branches/stable-1.2: . auto src/http src/http/modules Message-ID: <20120702164115.55EF03F9E70@mail.nginx.com> Author: mdounin Date: 2012-07-02 16:41:13 +0000 (Mon, 02 Jul 2012) New Revision: 4725 URL: http://trac.nginx.org/nginx/changeset/4725/nginx Log: Merge of r4655, r4656, r4657, r4695, r4696: upstream changes. *) Upstream: least_conn balancer module. *) Upstream: weights and IPv6 support in ip_hash balancer. *) Upstream keepalive: "single" parameter deprecated. Added: branches/stable-1.2/src/http/modules/ngx_http_upstream_least_conn_module.c Modified: branches/stable-1.2/ branches/stable-1.2/auto/modules branches/stable-1.2/auto/options branches/stable-1.2/auto/sources branches/stable-1.2/src/http/modules/ngx_http_upstream_ip_hash_module.c branches/stable-1.2/src/http/modules/ngx_http_upstream_keepalive_module.c branches/stable-1.2/src/http/ngx_http_upstream_round_robin.c branches/stable-1.2/src/http/ngx_http_upstream_round_robin.h Index: branches/stable-1.2 =================================================================== --- branches/stable-1.2 2012-07-02 16:23:14 UTC (rev 4724) +++ branches/stable-1.2 2012-07-02 16:41:13 UTC (rev 4725) Property changes on: branches/stable-1.2 ___________________________________________________________________ Modified: svn:mergeinfo ## -1 +1 ## -/trunk:4611-4632,4636-4654,4671-4672,4674-4676,4684-4685,4692 +/trunk:4611-4632,4636-4657,4671-4672,4674-4676,4684-4685,4692,4695-4696 \ No newline at end of property Modified: branches/stable-1.2/auto/modules =================================================================== --- branches/stable-1.2/auto/modules 2012-07-02 16:23:14 UTC (rev 4724) +++ branches/stable-1.2/auto/modules 2012-07-02 16:41:13 UTC (rev 4725) @@ -345,6 +345,11 @@ HTTP_SRCS="$HTTP_SRCS $HTTP_UPSTREAM_IP_HASH_SRCS" fi +if [ $HTTP_UPSTREAM_LEAST_CONN = YES ]; then + HTTP_MODULES="$HTTP_MODULES $HTTP_UPSTREAM_LEAST_CONN_MODULE" + HTTP_SRCS="$HTTP_SRCS $HTTP_UPSTREAM_LEAST_CONN_SRCS" +fi + if [ $HTTP_UPSTREAM_KEEPALIVE = YES ]; then HTTP_MODULES="$HTTP_MODULES $HTTP_UPSTREAM_KEEPALIVE_MODULE" HTTP_SRCS="$HTTP_SRCS $HTTP_UPSTREAM_KEEPALIVE_SRCS" Modified: branches/stable-1.2/auto/options =================================================================== --- branches/stable-1.2/auto/options 2012-07-02 16:23:14 UTC (rev 4724) +++ branches/stable-1.2/auto/options 2012-07-02 16:41:13 UTC (rev 4725) @@ -96,6 +96,7 @@ HTTP_MP4=NO HTTP_GZIP_STATIC=NO HTTP_UPSTREAM_IP_HASH=YES +HTTP_UPSTREAM_LEAST_CONN=YES HTTP_UPSTREAM_KEEPALIVE=YES # STUB @@ -243,6 +244,8 @@ --without-http_empty_gif_module) HTTP_EMPTY_GIF=NO ;; --without-http_browser_module) HTTP_BROWSER=NO ;; --without-http_upstream_ip_hash_module) HTTP_UPSTREAM_IP_HASH=NO ;; + --without-http_upstream_least_conn_module) + HTTP_UPSTREAM_LEAST_CONN=NO ;; --without-http_upstream_keepalive_module) HTTP_UPSTREAM_KEEPALIVE=NO ;; --with-http_perl_module) HTTP_PERL=YES ;; Modified: branches/stable-1.2/auto/sources =================================================================== --- branches/stable-1.2/auto/sources 2012-07-02 16:23:14 UTC (rev 4724) +++ branches/stable-1.2/auto/sources 2012-07-02 16:41:13 UTC (rev 4725) @@ -479,6 +479,11 @@ HTTP_UPSTREAM_IP_HASH_SRCS=src/http/modules/ngx_http_upstream_ip_hash_module.c +HTTP_UPSTREAM_LEAST_CONN_MODULE=ngx_http_upstream_least_conn_module +HTTP_UPSTREAM_LEAST_CONN_SRCS=" \ + src/http/modules/ngx_http_upstream_least_conn_module.c" + + HTTP_UPSTREAM_KEEPALIVE_MODULE=ngx_http_upstream_keepalive_module HTTP_UPSTREAM_KEEPALIVE_SRCS=" \ src/http/modules/ngx_http_upstream_keepalive_module.c" Modified: branches/stable-1.2/src/http/modules/ngx_http_upstream_ip_hash_module.c =================================================================== --- branches/stable-1.2/src/http/modules/ngx_http_upstream_ip_hash_module.c 2012-07-02 16:23:14 UTC (rev 4724) +++ branches/stable-1.2/src/http/modules/ngx_http_upstream_ip_hash_module.c 2012-07-02 16:41:13 UTC (rev 4725) @@ -16,7 +16,8 @@ ngx_uint_t hash; - u_char addr[3]; + u_char addrlen; + u_char *addr; u_char tries; @@ -76,7 +77,10 @@ }; -ngx_int_t +static u_char ngx_http_upstream_ip_hash_pseudo_addr[3]; + + +static ngx_int_t ngx_http_upstream_init_ip_hash(ngx_conf_t *cf, ngx_http_upstream_srv_conf_t *us) { if (ngx_http_upstream_init_round_robin(cf, us) != NGX_OK) { @@ -93,8 +97,10 @@ ngx_http_upstream_init_ip_hash_peer(ngx_http_request_t *r, ngx_http_upstream_srv_conf_t *us) { - u_char *p; struct sockaddr_in *sin; +#if (NGX_HAVE_INET6) + struct sockaddr_in6 *sin6; +#endif ngx_http_upstream_ip_hash_peer_data_t *iphp; iphp = ngx_palloc(r->pool, sizeof(ngx_http_upstream_ip_hash_peer_data_t)); @@ -110,20 +116,25 @@ r->upstream->peer.get = ngx_http_upstream_get_ip_hash_peer; - /* AF_INET only */ + switch (r->connection->sockaddr->sa_family) { - if (r->connection->sockaddr->sa_family == AF_INET) { - + case AF_INET: sin = (struct sockaddr_in *) r->connection->sockaddr; - p = (u_char *) &sin->sin_addr.s_addr; - iphp->addr[0] = p[0]; - iphp->addr[1] = p[1]; - iphp->addr[2] = p[2]; + iphp->addr = (u_char *) &sin->sin_addr.s_addr; + iphp->addrlen = 3; + break; - } else { - iphp->addr[0] = 0; - iphp->addr[1] = 0; - iphp->addr[2] = 0; +#if (NGX_HAVE_INET6) + case AF_INET6: + sin6 = (struct sockaddr_in6 *) r->connection->sockaddr; + iphp->addr = (u_char *) &sin6->sin6_addr.s6_addr; + iphp->addrlen = 16; + break; +#endif + + default: + iphp->addr = ngx_http_upstream_ip_hash_pseudo_addr; + iphp->addrlen = 3; } iphp->hash = 89; @@ -140,6 +151,7 @@ ngx_http_upstream_ip_hash_peer_data_t *iphp = data; time_t now; + ngx_int_t w; uintptr_t m; ngx_uint_t i, n, p, hash; ngx_http_upstream_rr_peer_t *peer; @@ -162,12 +174,26 @@ for ( ;; ) { - for (i = 0; i < 3; i++) { + for (i = 0; i < iphp->addrlen; i++) { hash = (hash * 113 + iphp->addr[i]) % 6271; } - p = hash % iphp->rrp.peers->number; + if (!iphp->rrp.peers->weighted) { + p = hash % iphp->rrp.peers->number; + } else { + w = hash % iphp->rrp.peers->total_weight; + + for (i = 0; i < iphp->rrp.peers->number; i++) { + w -= iphp->rrp.peers->peer[i].weight; + if (w < 0) { + break; + } + } + + p = i; + } + n = p / (8 * sizeof(uintptr_t)); m = (uintptr_t) 1 << p % (8 * sizeof(uintptr_t)); @@ -229,6 +255,7 @@ uscf->peer.init_upstream = ngx_http_upstream_init_ip_hash; uscf->flags = NGX_HTTP_UPSTREAM_CREATE + |NGX_HTTP_UPSTREAM_WEIGHT |NGX_HTTP_UPSTREAM_MAX_FAILS |NGX_HTTP_UPSTREAM_FAIL_TIMEOUT |NGX_HTTP_UPSTREAM_DOWN; Modified: branches/stable-1.2/src/http/modules/ngx_http_upstream_keepalive_module.c =================================================================== --- branches/stable-1.2/src/http/modules/ngx_http_upstream_keepalive_module.c 2012-07-02 16:23:14 UTC (rev 4724) +++ branches/stable-1.2/src/http/modules/ngx_http_upstream_keepalive_module.c 2012-07-02 16:41:13 UTC (rev 4725) @@ -12,7 +12,6 @@ typedef struct { ngx_uint_t max_cached; - ngx_uint_t single; /* unsigned:1 */ ngx_queue_t cache; ngx_queue_t free; @@ -223,36 +222,11 @@ kp->failed = 0; - /* single pool of cached connections */ + /* ask balancer */ - if (kp->conf->single && !ngx_queue_empty(&kp->conf->cache)) { - - q = ngx_queue_head(&kp->conf->cache); - - item = ngx_queue_data(q, ngx_http_upstream_keepalive_cache_t, queue); - c = item->connection; - - ngx_queue_remove(q); - ngx_queue_insert_head(&kp->conf->free, q); - - ngx_log_debug1(NGX_LOG_DEBUG_HTTP, pc->log, 0, - "get keepalive peer: using connection %p", c); - - c->idle = 0; - c->log = pc->log; - c->read->log = pc->log; - c->write->log = pc->log; - c->pool->log = pc->log; - - pc->connection = c; - pc->cached = 1; - - return NGX_DONE; - } - rc = kp->original_get_peer(pc, kp->data); - if (kp->conf->single || rc != NGX_OK) { + if (rc != NGX_OK) { return rc; } @@ -552,7 +526,8 @@ for (i = 2; i < cf->args->nelts; i++) { if (ngx_strcmp(value[i].data, "single") == 0) { - kcf->single = 1; + ngx_conf_log_error(NGX_LOG_WARN, cf, 0, + "the \"single\" parameter is deprecated"); continue; } Copied: branches/stable-1.2/src/http/modules/ngx_http_upstream_least_conn_module.c (from rev 4655, trunk/src/http/modules/ngx_http_upstream_least_conn_module.c) =================================================================== --- branches/stable-1.2/src/http/modules/ngx_http_upstream_least_conn_module.c (rev 0) +++ branches/stable-1.2/src/http/modules/ngx_http_upstream_least_conn_module.c 2012-07-02 16:41:13 UTC (rev 4725) @@ -0,0 +1,402 @@ + +/* + * Copyright (C) Maxim Dounin + * Copyright (C) Nginx, Inc. + */ + + +#include +#include +#include + + +typedef struct { + ngx_uint_t *conns; +} ngx_http_upstream_least_conn_conf_t; + + +typedef struct { + /* the round robin data must be first */ + ngx_http_upstream_rr_peer_data_t rrp; + + ngx_uint_t *conns; + + ngx_event_get_peer_pt get_rr_peer; + ngx_event_free_peer_pt free_rr_peer; +} ngx_http_upstream_lc_peer_data_t; + + +static ngx_int_t ngx_http_upstream_init_least_conn_peer(ngx_http_request_t *r, + ngx_http_upstream_srv_conf_t *us); +static ngx_int_t ngx_http_upstream_get_least_conn_peer( + ngx_peer_connection_t *pc, void *data); +static void ngx_http_upstream_free_least_conn_peer(ngx_peer_connection_t *pc, + void *data, ngx_uint_t state); +static void *ngx_http_upstream_least_conn_create_conf(ngx_conf_t *cf); +static char *ngx_http_upstream_least_conn(ngx_conf_t *cf, ngx_command_t *cmd, + void *conf); + + +static ngx_command_t ngx_http_upstream_least_conn_commands[] = { + + { ngx_string("least_conn"), + NGX_HTTP_UPS_CONF|NGX_CONF_NOARGS, + ngx_http_upstream_least_conn, + 0, + 0, + NULL }, + + ngx_null_command +}; + + +static ngx_http_module_t ngx_http_upstream_least_conn_module_ctx = { + NULL, /* preconfiguration */ + NULL, /* postconfiguration */ + + NULL, /* create main configuration */ + NULL, /* init main configuration */ + + ngx_http_upstream_least_conn_create_conf, /* create server configuration */ + NULL, /* merge server configuration */ + + NULL, /* create location configuration */ + NULL /* merge location configuration */ +}; + + +ngx_module_t ngx_http_upstream_least_conn_module = { + NGX_MODULE_V1, + &ngx_http_upstream_least_conn_module_ctx, /* module context */ + ngx_http_upstream_least_conn_commands, /* module directives */ + NGX_HTTP_MODULE, /* module type */ + NULL, /* init master */ + NULL, /* init module */ + NULL, /* init process */ + NULL, /* init thread */ + NULL, /* exit thread */ + NULL, /* exit process */ + NULL, /* exit master */ + NGX_MODULE_V1_PADDING +}; + + +ngx_int_t +ngx_http_upstream_init_least_conn(ngx_conf_t *cf, + ngx_http_upstream_srv_conf_t *us) +{ + ngx_uint_t n; + ngx_http_upstream_rr_peers_t *peers; + ngx_http_upstream_least_conn_conf_t *lcf; + + ngx_log_debug0(NGX_LOG_DEBUG_HTTP, cf->log, 0, + "init least conn"); + + if (ngx_http_upstream_init_round_robin(cf, us) != NGX_OK) { + return NGX_ERROR; + } + + peers = us->peer.data; + + n = peers->number; + + if (peers->next) { + n += peers->next->number; + } + + lcf = ngx_http_conf_upstream_srv_conf(us, + ngx_http_upstream_least_conn_module); + + lcf->conns = ngx_pcalloc(cf->pool, sizeof(ngx_uint_t) * n); + if (lcf->conns == NULL) { + return NGX_ERROR; + } + + us->peer.init = ngx_http_upstream_init_least_conn_peer; + + return NGX_OK; +} + + +static ngx_int_t +ngx_http_upstream_init_least_conn_peer(ngx_http_request_t *r, + ngx_http_upstream_srv_conf_t *us) +{ + ngx_http_upstream_lc_peer_data_t *lcp; + ngx_http_upstream_least_conn_conf_t *lcf; + + ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, + "init least conn peer"); + + lcf = ngx_http_conf_upstream_srv_conf(us, + ngx_http_upstream_least_conn_module); + + lcp = ngx_palloc(r->pool, sizeof(ngx_http_upstream_lc_peer_data_t)); + if (lcp == NULL) { + return NGX_ERROR; + } + + lcp->conns = lcf->conns; + + r->upstream->peer.data = &lcp->rrp; + + if (ngx_http_upstream_init_round_robin_peer(r, us) != NGX_OK) { + return NGX_ERROR; + } + + r->upstream->peer.get = ngx_http_upstream_get_least_conn_peer; + r->upstream->peer.free = ngx_http_upstream_free_least_conn_peer; + + lcp->get_rr_peer = ngx_http_upstream_get_round_robin_peer; + lcp->free_rr_peer = ngx_http_upstream_free_round_robin_peer; + + return NGX_OK; +} + + +static ngx_int_t +ngx_http_upstream_get_least_conn_peer(ngx_peer_connection_t *pc, void *data) +{ + ngx_http_upstream_lc_peer_data_t *lcp = data; + + time_t now; + uintptr_t m; + ngx_int_t rc, total; + ngx_uint_t i, n, p, many; + ngx_http_upstream_rr_peer_t *peer, *best; + ngx_http_upstream_rr_peers_t *peers; + + ngx_log_debug1(NGX_LOG_DEBUG_HTTP, pc->log, 0, + "get least conn peer, try: %ui", pc->tries); + + if (lcp->rrp.peers->single) { + return lcp->get_rr_peer(pc, &lcp->rrp); + } + + pc->cached = 0; + pc->connection = NULL; + + now = ngx_time(); + + peers = lcp->rrp.peers; + + best = NULL; + total = 0; + +#if (NGX_SUPPRESS_WARN) + many = 0; + p = 0; +#endif + + for (i = 0; i < peers->number; i++) { + + n = i / (8 * sizeof(uintptr_t)); + m = (uintptr_t) 1 << i % (8 * sizeof(uintptr_t)); + + if (lcp->rrp.tried[n] & m) { + continue; + } + + peer = &peers->peer[i]; + + if (peer->down) { + continue; + } + + if (peer->max_fails + && peer->fails >= peer->max_fails + && now - peer->checked <= peer->fail_timeout) + { + continue; + } + + /* + * select peer with least number of connections; if there are + * multiple peers with the same number of connections, select + * based on round-robin + */ + + if (best == NULL + || lcp->conns[i] * best->weight < lcp->conns[p] * peer->weight) + { + best = peer; + many = 0; + p = i; + + } else if (lcp->conns[i] * best->weight + == lcp->conns[p] * peer->weight) + { + many = 1; + } + } + + if (best == NULL) { + ngx_log_debug0(NGX_LOG_DEBUG_HTTP, pc->log, 0, + "get least conn peer, no peer found"); + + goto failed; + } + + if (many) { + ngx_log_debug0(NGX_LOG_DEBUG_HTTP, pc->log, 0, + "get least conn peer, many"); + + for (i = p; i < peers->number; i++) { + + n = i / (8 * sizeof(uintptr_t)); + m = (uintptr_t) 1 << i % (8 * sizeof(uintptr_t)); + + if (lcp->rrp.tried[n] & m) { + continue; + } + + peer = &peers->peer[i]; + + if (peer->down) { + continue; + } + + if (lcp->conns[i] * best->weight != lcp->conns[p] * peer->weight) { + continue; + } + + if (peer->max_fails + && peer->fails >= peer->max_fails + && now - peer->checked <= peer->fail_timeout) + { + continue; + } + + peer->current_weight += peer->effective_weight; + total += peer->effective_weight; + + if (peer->effective_weight < peer->weight) { + peer->effective_weight++; + } + + if (peer->current_weight > best->current_weight) { + best = peer; + p = i; + } + } + } + + best->current_weight -= total; + best->checked = now; + + pc->sockaddr = best->sockaddr; + pc->socklen = best->socklen; + pc->name = &best->name; + + lcp->rrp.current = p; + + n = p / (8 * sizeof(uintptr_t)); + m = (uintptr_t) 1 << p % (8 * sizeof(uintptr_t)); + + lcp->rrp.tried[n] |= m; + lcp->conns[p]++; + + if (pc->tries == 1 && peers->next) { + pc->tries += peers->next->number; + } + + return NGX_OK; + +failed: + + if (peers->next) { + ngx_log_debug0(NGX_LOG_DEBUG_HTTP, pc->log, 0, + "get least conn peer, backup servers"); + + lcp->conns += peers->number; + + lcp->rrp.peers = peers->next; + pc->tries = lcp->rrp.peers->number; + + n = lcp->rrp.peers->number / (8 * sizeof(uintptr_t)) + 1; + for (i = 0; i < n; i++) { + lcp->rrp.tried[i] = 0; + } + + rc = ngx_http_upstream_get_least_conn_peer(pc, lcp); + + if (rc != NGX_BUSY) { + return rc; + } + } + + /* all peers failed, mark them as live for quick recovery */ + + for (i = 0; i < peers->number; i++) { + peers->peer[i].fails = 0; + } + + pc->name = peers->name; + + return NGX_BUSY; +} + + +static void +ngx_http_upstream_free_least_conn_peer(ngx_peer_connection_t *pc, + void *data, ngx_uint_t state) +{ + ngx_http_upstream_lc_peer_data_t *lcp = data; + + ngx_log_debug2(NGX_LOG_DEBUG_HTTP, pc->log, 0, + "free least conn peer %ui %ui", pc->tries, state); + + if (lcp->rrp.peers->single) { + lcp->free_rr_peer(pc, &lcp->rrp, state); + return; + } + + if (state == 0 && pc->tries == 0) { + return; + } + + lcp->conns[lcp->rrp.current]--; + + lcp->free_rr_peer(pc, &lcp->rrp, state); +} + + +static void * +ngx_http_upstream_least_conn_create_conf(ngx_conf_t *cf) +{ + ngx_http_upstream_least_conn_conf_t *conf; + + conf = ngx_pcalloc(cf->pool, + sizeof(ngx_http_upstream_least_conn_conf_t)); + if (conf == NULL) { + return NULL; + } + + /* + * set by ngx_pcalloc(): + * + * conf->conns = NULL; + */ + + return conf; +} + + +static char * +ngx_http_upstream_least_conn(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) +{ + ngx_http_upstream_srv_conf_t *uscf; + + uscf = ngx_http_conf_get_module_srv_conf(cf, ngx_http_upstream_module); + + uscf->peer.init_upstream = ngx_http_upstream_init_least_conn; + + uscf->flags = NGX_HTTP_UPSTREAM_CREATE + |NGX_HTTP_UPSTREAM_WEIGHT + |NGX_HTTP_UPSTREAM_MAX_FAILS + |NGX_HTTP_UPSTREAM_FAIL_TIMEOUT + |NGX_HTTP_UPSTREAM_DOWN + |NGX_HTTP_UPSTREAM_BACKUP; + + return NGX_CONF_OK; +} Modified: branches/stable-1.2/src/http/ngx_http_upstream_round_robin.c =================================================================== --- branches/stable-1.2/src/http/ngx_http_upstream_round_robin.c 2012-07-02 16:23:14 UTC (rev 4724) +++ branches/stable-1.2/src/http/ngx_http_upstream_round_robin.c 2012-07-02 16:41:13 UTC (rev 4725) @@ -30,7 +30,7 @@ ngx_http_upstream_srv_conf_t *us) { ngx_url_t u; - ngx_uint_t i, j, n; + ngx_uint_t i, j, n, w; ngx_http_upstream_server_t *server; ngx_http_upstream_rr_peers_t *peers, *backup; @@ -40,6 +40,7 @@ server = us->servers->elts; n = 0; + w = 0; for (i = 0; i < us->servers->nelts; i++) { if (server[i].backup) { @@ -47,6 +48,7 @@ } n += server[i].naddrs; + w += server[i].naddrs * server[i].weight; } if (n == 0) { @@ -64,6 +66,8 @@ peers->single = (n == 1); peers->number = n; + peers->weighted = (w != n); + peers->total_weight = w; peers->name = &us->host; n = 0; @@ -96,6 +100,7 @@ /* backup servers */ n = 0; + w = 0; for (i = 0; i < us->servers->nelts; i++) { if (!server[i].backup) { @@ -103,6 +108,7 @@ } n += server[i].naddrs; + w += server[i].naddrs * server[i].weight; } if (n == 0) { @@ -118,6 +124,8 @@ peers->single = 0; backup->single = 0; backup->number = n; + backup->weighted = (w != n); + backup->total_weight = w; backup->name = &us->host; n = 0; @@ -185,6 +193,8 @@ peers->single = (n == 1); peers->number = n; + peers->weighted = 0; + peers->total_weight = n; peers->name = &us->host; for (i = 0; i < u.naddrs; i++) { Modified: branches/stable-1.2/src/http/ngx_http_upstream_round_robin.h =================================================================== --- branches/stable-1.2/src/http/ngx_http_upstream_round_robin.h 2012-07-02 16:23:14 UTC (rev 4724) +++ branches/stable-1.2/src/http/ngx_http_upstream_round_robin.h 2012-07-02 16:41:13 UTC (rev 4725) @@ -41,13 +41,17 @@ typedef struct ngx_http_upstream_rr_peers_s ngx_http_upstream_rr_peers_t; struct ngx_http_upstream_rr_peers_s { - ngx_uint_t single; /* unsigned single:1; */ ngx_uint_t number; ngx_uint_t last_cached; /* ngx_mutex_t *mutex; */ ngx_connection_t **cached; + ngx_uint_t total_weight; + + unsigned single:1; + unsigned weighted:1; + ngx_str_t *name; ngx_http_upstream_rr_peers_t *next; From mdounin at mdounin.ru Mon Jul 2 16:51:03 2012 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Mon, 2 Jul 2012 16:51:03 +0000 Subject: [nginx] svn commit: r4726 - in branches/stable-1.2: . auto auto/lib/google-perftools src/http src/http/modules src/os/unix src/os/win32 Message-ID: <20120702165103.930FA3F9F39@mail.nginx.com> Author: mdounin Date: 2012-07-02 16:51:02 +0000 (Mon, 02 Jul 2012) New Revision: 4726 URL: http://trac.nginx.org/nginx/changeset/4726/nginx Log: Merge of r4682, r4694, r4699, r4704, r4705: minor nits. *) Fixed spelling of "endianness", and called it "byte ordering" in the user visible part. *) Fixed return type of ngx_strerror_init(). *) Fixed a harmless error in spelling of "Connection: close" when computing the response header length. *) Style. *) Added code to look up Google perftools in /opt/local/, for MacPorts. Added: branches/stable-1.2/auto/endianness Removed: branches/stable-1.2/auto/endianess Modified: branches/stable-1.2/ branches/stable-1.2/auto/lib/google-perftools/conf branches/stable-1.2/auto/unix branches/stable-1.2/src/http/modules/ngx_http_geo_module.c branches/stable-1.2/src/http/ngx_http_header_filter_module.c branches/stable-1.2/src/os/unix/ngx_errno.c branches/stable-1.2/src/os/unix/ngx_errno.h branches/stable-1.2/src/os/win32/ngx_errno.c branches/stable-1.2/src/os/win32/ngx_errno.h branches/stable-1.2/src/os/win32/ngx_files.c Index: branches/stable-1.2 =================================================================== --- branches/stable-1.2 2012-07-02 16:41:13 UTC (rev 4725) +++ branches/stable-1.2 2012-07-02 16:51:02 UTC (rev 4726) Property changes on: branches/stable-1.2 ___________________________________________________________________ Modified: svn:mergeinfo ## -1 +1 ## -/trunk:4611-4632,4636-4657,4671-4672,4674-4676,4684-4685,4692,4695-4696 +/trunk:4611-4632,4636-4657,4671-4672,4674-4676,4682,4684-4685,4692,4694-4696,4699,4704-4705 \ No newline at end of property Deleted: branches/stable-1.2/auto/endianess =================================================================== --- branches/stable-1.2/auto/endianess 2012-07-02 16:41:13 UTC (rev 4725) +++ branches/stable-1.2/auto/endianess 2012-07-02 16:51:02 UTC (rev 4726) @@ -1,45 +0,0 @@ - -# Copyright (C) Igor Sysoev -# Copyright (C) Nginx, Inc. - - -echo $ngx_n "checking for system endianess ...$ngx_c" -echo >> $NGX_ERR -echo "checking for system endianess" >> $NGX_ERR - - -cat << END > $NGX_AUTOTEST.c - -int main() { - int i = 0x11223344; - char *p; - - p = (char *) &i; - if (*p == 0x44) return 0; - return 1; -} - -END - -ngx_test="$CC $CC_TEST_FLAGS $CC_AUX_FLAGS \ - -o $NGX_AUTOTEST $NGX_AUTOTEST.c $NGX_LD_OPT $ngx_feature_libs" - -eval "$ngx_test >> $NGX_AUTOCONF_ERR 2>&1" - -if [ -x $NGX_AUTOTEST ]; then - if $NGX_AUTOTEST >/dev/null 2>&1; then - echo " little endianess" - have=NGX_HAVE_LITTLE_ENDIAN . auto/have - else - echo " big endianess" - fi - - rm $NGX_AUTOTEST* - -else - rm $NGX_AUTOTEST* - - echo - echo "$0: error: can not detect system endianess" - exit 1 -fi Copied: branches/stable-1.2/auto/endianness (from rev 4682, trunk/auto/endianness) =================================================================== --- branches/stable-1.2/auto/endianness (rev 0) +++ branches/stable-1.2/auto/endianness 2012-07-02 16:51:02 UTC (rev 4726) @@ -0,0 +1,45 @@ + +# Copyright (C) Igor Sysoev +# Copyright (C) Nginx, Inc. + + +echo $ngx_n "checking for system byte ordering ...$ngx_c" +echo >> $NGX_ERR +echo "checking for system byte ordering" >> $NGX_ERR + + +cat << END > $NGX_AUTOTEST.c + +int main() { + int i = 0x11223344; + char *p; + + p = (char *) &i; + if (*p == 0x44) return 0; + return 1; +} + +END + +ngx_test="$CC $CC_TEST_FLAGS $CC_AUX_FLAGS \ + -o $NGX_AUTOTEST $NGX_AUTOTEST.c $NGX_LD_OPT $ngx_feature_libs" + +eval "$ngx_test >> $NGX_AUTOCONF_ERR 2>&1" + +if [ -x $NGX_AUTOTEST ]; then + if $NGX_AUTOTEST >/dev/null 2>&1; then + echo " little endian" + have=NGX_HAVE_LITTLE_ENDIAN . auto/have + else + echo " big endian" + fi + + rm $NGX_AUTOTEST* + +else + rm $NGX_AUTOTEST* + + echo + echo "$0: error: cannot detect system byte ordering" + exit 1 +fi Modified: branches/stable-1.2/auto/lib/google-perftools/conf =================================================================== --- branches/stable-1.2/auto/lib/google-perftools/conf 2012-07-02 16:41:13 UTC (rev 4725) +++ branches/stable-1.2/auto/lib/google-perftools/conf 2012-07-02 16:51:02 UTC (rev 4726) @@ -29,6 +29,22 @@ fi +if [ $ngx_found = no ]; then + + # MacPorts + + ngx_feature="Google perftools in /opt/local/" + + if [ $NGX_RPATH = YES ]; then + ngx_feature_libs="-R/opt/local/lib -L/opt/local/lib -lprofiler" + else + ngx_feature_libs="-L/opt/local/lib -lprofiler" + fi + + . auto/feature +fi + + if [ $ngx_found = yes ]; then CORE_LIBS="$CORE_LIBS $ngx_feature_libs" Modified: branches/stable-1.2/auto/unix =================================================================== --- branches/stable-1.2/auto/unix 2012-07-02 16:41:13 UTC (rev 4725) +++ branches/stable-1.2/auto/unix 2012-07-02 16:51:02 UTC (rev 4726) @@ -464,7 +464,7 @@ . auto/types/uintptr_t -. auto/endianess +. auto/endianness ngx_type="size_t"; . auto/types/sizeof ngx_param=NGX_MAX_SIZE_T_VALUE; ngx_value=$ngx_max_value; . auto/types/value Modified: branches/stable-1.2/src/http/modules/ngx_http_geo_module.c =================================================================== --- branches/stable-1.2/src/http/modules/ngx_http_geo_module.c 2012-07-02 16:41:13 UTC (rev 4725) +++ branches/stable-1.2/src/http/modules/ngx_http_geo_module.c 2012-07-02 16:51:02 UTC (rev 4726) @@ -145,7 +145,7 @@ u_char GEORNG[6]; u_char version; u_char ptr_size; - uint32_t endianess; + uint32_t endianness; uint32_t crc32; } ngx_http_geo_header_t; Modified: branches/stable-1.2/src/http/ngx_http_header_filter_module.c =================================================================== --- branches/stable-1.2/src/http/ngx_http_header_filter_module.c 2012-07-02 16:41:13 UTC (rev 4725) +++ branches/stable-1.2/src/http/ngx_http_header_filter_module.c 2012-07-02 16:51:02 UTC (rev 4726) @@ -395,7 +395,7 @@ } } else { - len += sizeof("Connection: closed" CRLF) - 1; + len += sizeof("Connection: close" CRLF) - 1; } #if (NGX_HTTP_GZIP) Modified: branches/stable-1.2/src/os/unix/ngx_errno.c =================================================================== --- branches/stable-1.2/src/os/unix/ngx_errno.c 2012-07-02 16:41:13 UTC (rev 4725) +++ branches/stable-1.2/src/os/unix/ngx_errno.c 2012-07-02 16:51:02 UTC (rev 4726) @@ -42,7 +42,7 @@ } -ngx_uint_t +ngx_int_t ngx_strerror_init(void) { char *msg; Modified: branches/stable-1.2/src/os/unix/ngx_errno.h =================================================================== --- branches/stable-1.2/src/os/unix/ngx_errno.h 2012-07-02 16:41:13 UTC (rev 4725) +++ branches/stable-1.2/src/os/unix/ngx_errno.h 2012-07-02 16:51:02 UTC (rev 4726) @@ -69,7 +69,7 @@ u_char *ngx_strerror(ngx_err_t err, u_char *errstr, size_t size); -ngx_uint_t ngx_strerror_init(void); +ngx_int_t ngx_strerror_init(void); #endif /* _NGX_ERRNO_H_INCLUDED_ */ Modified: branches/stable-1.2/src/os/win32/ngx_errno.c =================================================================== --- branches/stable-1.2/src/os/win32/ngx_errno.c 2012-07-02 16:41:13 UTC (rev 4725) +++ branches/stable-1.2/src/os/win32/ngx_errno.c 2012-07-02 16:51:02 UTC (rev 4726) @@ -53,7 +53,7 @@ } -ngx_uint_t +ngx_int_t ngx_strerror_init(void) { return NGX_OK; Modified: branches/stable-1.2/src/os/win32/ngx_errno.h =================================================================== --- branches/stable-1.2/src/os/win32/ngx_errno.h 2012-07-02 16:41:13 UTC (rev 4725) +++ branches/stable-1.2/src/os/win32/ngx_errno.h 2012-07-02 16:51:02 UTC (rev 4726) @@ -59,7 +59,7 @@ u_char *ngx_strerror(ngx_err_t err, u_char *errstr, size_t size); -ngx_uint_t ngx_strerror_init(void); +ngx_int_t ngx_strerror_init(void); #endif /* _NGX_ERRNO_H_INCLUDED_ */ Modified: branches/stable-1.2/src/os/win32/ngx_files.c =================================================================== --- branches/stable-1.2/src/os/win32/ngx_files.c 2012-07-02 16:41:13 UTC (rev 4725) +++ branches/stable-1.2/src/os/win32/ngx_files.c 2012-07-02 16:51:02 UTC (rev 4726) @@ -722,7 +722,7 @@ if (ch == ':') { goto invalid; } - + if (ch == '.' || ch == ' ') { break; } From mdounin at mdounin.ru Mon Jul 2 16:53:36 2012 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Mon, 2 Jul 2012 16:53:36 +0000 Subject: [nginx] svn commit: r4727 - in branches/stable-1.2: . src/http src/http/modules Message-ID: <20120702165337.297F03FA0B3@mail.nginx.com> Author: mdounin Date: 2012-07-02 16:53:36 +0000 (Mon, 02 Jul 2012) New Revision: 4727 URL: http://trac.nginx.org/nginx/changeset/4727/nginx Log: Merge of r4686, r4687: $status variable. Contains response status code as a 3-digit integer (with leading zeroes if necessary), or one of the following values: 000 - response status code has not yet been assigned 009 - HTTP/0.9 request is being processed Modified: branches/stable-1.2/ branches/stable-1.2/src/http/modules/ngx_http_log_module.c branches/stable-1.2/src/http/ngx_http_variables.c Index: branches/stable-1.2 =================================================================== --- branches/stable-1.2 2012-07-02 16:51:02 UTC (rev 4726) +++ branches/stable-1.2 2012-07-02 16:53:36 UTC (rev 4727) Property changes on: branches/stable-1.2 ___________________________________________________________________ Modified: svn:mergeinfo ## -1 +1 ## -/trunk:4611-4632,4636-4657,4671-4672,4674-4676,4682,4684-4685,4692,4694-4696,4699,4704-4705 +/trunk:4611-4632,4636-4657,4671-4672,4674-4676,4682,4684-4687,4692,4694-4696,4699,4704-4705 \ No newline at end of property Modified: branches/stable-1.2/src/http/modules/ngx_http_log_module.c =================================================================== --- branches/stable-1.2/src/http/modules/ngx_http_log_module.c 2012-07-02 16:51:02 UTC (rev 4726) +++ branches/stable-1.2/src/http/modules/ngx_http_log_module.c 2012-07-02 16:53:36 UTC (rev 4727) @@ -584,10 +584,7 @@ status = r->headers_out.status; } else if (r->http_version == NGX_HTTP_VERSION_9) { - *buf++ = '0'; - *buf++ = '0'; - *buf++ = '9'; - return buf; + status = 9; } else { status = 0; Modified: branches/stable-1.2/src/http/ngx_http_variables.c =================================================================== --- branches/stable-1.2/src/http/ngx_http_variables.c 2012-07-02 16:51:02 UTC (rev 4726) +++ branches/stable-1.2/src/http/ngx_http_variables.c 2012-07-02 16:53:36 UTC (rev 4727) @@ -77,6 +77,8 @@ ngx_http_variable_value_t *v, uintptr_t data); static ngx_int_t ngx_http_variable_request_body_file(ngx_http_request_t *r, ngx_http_variable_value_t *v, uintptr_t data); +static ngx_int_t ngx_http_variable_status(ngx_http_request_t *r, + ngx_http_variable_value_t *v, uintptr_t data); static ngx_int_t ngx_http_variable_sent_content_type(ngx_http_request_t *r, ngx_http_variable_value_t *v, uintptr_t data); @@ -225,6 +227,10 @@ ngx_http_variable_request_body_file, 0, 0, 0 }, + { ngx_string("status"), NULL, + ngx_http_variable_status, 0, + NGX_HTTP_VAR_NOCACHEABLE, 0 }, + { ngx_string("sent_http_content_type"), NULL, ngx_http_variable_sent_content_type, 0, 0, 0 }, @@ -1456,6 +1462,39 @@ static ngx_int_t +ngx_http_variable_status(ngx_http_request_t *r, + ngx_http_variable_value_t *v, uintptr_t data) +{ + ngx_uint_t status; + + v->data = ngx_pnalloc(r->pool, NGX_INT_T_LEN); + if (v->data == NULL) { + return NGX_ERROR; + } + + if (r->err_status) { + status = r->err_status; + + } else if (r->headers_out.status) { + status = r->headers_out.status; + + } else if (r->http_version == NGX_HTTP_VERSION_9) { + status = 9; + + } else { + status = 0; + } + + v->len = ngx_sprintf(v->data, "%03ui", status) - v->data; + v->valid = 1; + v->no_cacheable = 0; + v->not_found = 0; + + return NGX_OK; +} + + +static ngx_int_t ngx_http_variable_sent_content_type(ngx_http_request_t *r, ngx_http_variable_value_t *v, uintptr_t data) { From mdounin at mdounin.ru Mon Jul 2 16:56:54 2012 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Mon, 2 Jul 2012 16:56:54 +0000 Subject: [nginx] svn commit: r4728 - in branches/stable-1.2: . src/http/modules Message-ID: <20120702165654.57C8B3F9C6B@mail.nginx.com> Author: mdounin Date: 2012-07-02 16:56:53 +0000 (Mon, 02 Jul 2012) New Revision: 4728 URL: http://trac.nginx.org/nginx/changeset/4728/nginx Log: Merge of r4688, r4689, r4706: *) Mp4: fixed non-keyframe seeks in some cases (ticket #175). Number of entries in stsc atom was wrong if we've added an entry to split a chunk. Additionally, there is no need to add an entry if we are going to split last chunk in an entry, it's enough to update the entry we already have. Previously new entry was added and old one was left as is, resulting in incorrect entry with zero chunks which might confuse some software. *) Mp4: fixed streaming if moov atom is at buffer edge. Modified: branches/stable-1.2/ branches/stable-1.2/src/http/modules/ngx_http_mp4_module.c Index: branches/stable-1.2 =================================================================== --- branches/stable-1.2 2012-07-02 16:53:36 UTC (rev 4727) +++ branches/stable-1.2 2012-07-02 16:56:53 UTC (rev 4728) Property changes on: branches/stable-1.2 ___________________________________________________________________ Modified: svn:mergeinfo ## -1 +1 ## -/trunk:4611-4632,4636-4657,4671-4672,4674-4676,4682,4684-4687,4692,4694-4696,4699,4704-4705 +/trunk:4611-4632,4636-4657,4671-4672,4674-4676,4682,4684-4689,4692,4694-4696,4699,4704-4706 \ No newline at end of property Modified: branches/stable-1.2/src/http/modules/ngx_http_mp4_module.c =================================================================== --- branches/stable-1.2/src/http/modules/ngx_http_mp4_module.c 2012-07-02 16:53:36 UTC (rev 4727) +++ branches/stable-1.2/src/http/modules/ngx_http_mp4_module.c 2012-07-02 16:56:53 UTC (rev 4728) @@ -1024,6 +1024,10 @@ + NGX_HTTP_MP4_MOOV_BUFFER_EXCESS * no_mdat; } + if (ngx_http_mp4_read(mp4, (size_t) atom_data_size) != NGX_OK) { + return NGX_ERROR; + } + mp4->trak.elts = &mp4->traks; mp4->trak.size = sizeof(ngx_http_mp4_trak_t); mp4->trak.nalloc = 2; @@ -1044,6 +1048,12 @@ mp4->buffer_start = mp4->buffer_pos; mp4->buffer_size = NGX_HTTP_MP4_MOOV_BUFFER_EXCESS; + if (mp4->buffer_start + mp4->buffer_size > mp4->buffer_end) { + mp4->buffer = NULL; + mp4->buffer_pos = NULL; + mp4->buffer_end = NULL; + } + } else { /* skip atoms after moov atom */ mp4->offset = mp4->end; @@ -2488,8 +2498,14 @@ ngx_mp4_set_32value(entry->chunk, 1); - if (trak->chunk_samples) { + if (trak->chunk_samples && next_chunk - trak->start_chunk == 2) { + /* last chunk in the entry */ + + ngx_mp4_set_32value(entry->samples, samples - trak->chunk_samples); + + } else if (trak->chunk_samples) { + first = &trak->stsc_chunk_entry; ngx_mp4_set_32value(first->chunk, 1); ngx_mp4_set_32value(first->samples, samples - trak->chunk_samples); @@ -2504,6 +2520,7 @@ ngx_mp4_set_32value(entry->chunk, 2); + entries++; atom_size += sizeof(ngx_mp4_stsc_entry_t); } From pass86 at gmail.com Mon Jul 2 16:57:32 2012 From: pass86 at gmail.com (l.jay Yuan) Date: Tue, 3 Jul 2012 00:57:32 +0800 Subject: Is iocp module working now? Message-ID: Is iocp module working now? From mdounin at mdounin.ru Mon Jul 2 16:59:34 2012 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Mon, 2 Jul 2012 16:59:34 +0000 Subject: [nginx] svn commit: r4729 - in branches/stable-1.2: . src/core Message-ID: <20120702165934.EDECE3F9C6B@mail.nginx.com> Author: mdounin Date: 2012-07-02 16:59:34 +0000 (Mon, 02 Jul 2012) New Revision: 4729 URL: http://trac.nginx.org/nginx/changeset/4729/nginx Log: Merge of r4690: conflicting wildcard server names fix. With previous code wildcard names were added to hash even if conflict was detected. This resulted in identical names in hash and segfault later in ngx_hash_wildcard_init(). Modified: branches/stable-1.2/ branches/stable-1.2/src/core/ngx_hash.c Index: branches/stable-1.2 =================================================================== --- branches/stable-1.2 2012-07-02 16:56:53 UTC (rev 4728) +++ branches/stable-1.2 2012-07-02 16:59:34 UTC (rev 4729) Property changes on: branches/stable-1.2 ___________________________________________________________________ Modified: svn:mergeinfo ## -1 +1 ## -/trunk:4611-4632,4636-4657,4671-4672,4674-4676,4682,4684-4689,4692,4694-4696,4699,4704-4706 +/trunk:4611-4632,4636-4657,4671-4672,4674-4676,4682,4684-4690,4692,4694-4696,4699,4704-4706 \ No newline at end of property Modified: branches/stable-1.2/src/core/ngx_hash.c =================================================================== --- branches/stable-1.2/src/core/ngx_hash.c 2012-07-02 16:56:53 UTC (rev 4728) +++ branches/stable-1.2/src/core/ngx_hash.c 2012-07-02 16:59:34 UTC (rev 4729) @@ -924,17 +924,6 @@ } - hk = ngx_array_push(hwc); - if (hk == NULL) { - return NGX_ERROR; - } - - hk->key.len = last - 1; - hk->key.data = p; - hk->key_hash = 0; - hk->value = value; - - /* check conflicts in wildcard hash */ name = keys->elts; @@ -972,5 +961,18 @@ ngx_memcpy(name->data, key->data + skip, name->len); + + /* add to wildcard hash */ + + hk = ngx_array_push(hwc); + if (hk == NULL) { + return NGX_ERROR; + } + + hk->key.len = last - 1; + hk->key.data = p; + hk->key_hash = 0; + hk->value = value; + return NGX_OK; } From mdounin at mdounin.ru Mon Jul 2 17:08:26 2012 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Mon, 2 Jul 2012 17:08:26 +0000 Subject: [nginx] svn commit: r4730 - in branches/stable-1.2: . auto/os Message-ID: <20120702170826.E6AF23F9F96@mail.nginx.com> Author: mdounin Date: 2012-07-02 17:08:26 +0000 (Mon, 02 Jul 2012) New Revision: 4730 URL: http://trac.nginx.org/nginx/changeset/4730/nginx Log: Merge of r4691: changed default alignment to 16. This fixes alignment problems observerd on ARMs, and likely also needed for MIPSes. Unless we know alignment is not required just assume we need 16, which appears to be safe default for all architectures. See here for details: http://mailman.nginx.org/pipermail/nginx/2012-June/034139.html Modified: branches/stable-1.2/ branches/stable-1.2/auto/os/conf Index: branches/stable-1.2 =================================================================== --- branches/stable-1.2 2012-07-02 16:59:34 UTC (rev 4729) +++ branches/stable-1.2 2012-07-02 17:08:26 UTC (rev 4730) Property changes on: branches/stable-1.2 ___________________________________________________________________ Modified: svn:mergeinfo ## -1 +1 ## -/trunk:4611-4632,4636-4657,4671-4672,4674-4676,4682,4684-4690,4692,4694-4696,4699,4704-4706 +/trunk:4611-4632,4636-4657,4671-4672,4674-4676,4682,4684-4692,4694-4696,4699,4704-4706 \ No newline at end of property Modified: branches/stable-1.2/auto/os/conf =================================================================== --- branches/stable-1.2/auto/os/conf 2012-07-02 16:59:34 UTC (rev 4729) +++ branches/stable-1.2/auto/os/conf 2012-07-02 17:08:26 UTC (rev 4730) @@ -93,6 +93,7 @@ ;; *) + have=NGX_ALIGNMENT value=16 . auto/define NGX_MACH_CACHE_LINE=32 ;; From ne at vbart.ru Mon Jul 2 17:08:23 2012 From: ne at vbart.ru (Valentin V. Bartenev) Date: Mon, 2 Jul 2012 21:08:23 +0400 Subject: Is iocp module working now? In-Reply-To: References: Message-ID: <201207022108.23765.ne@vbart.ru> On Monday 02 July 2012 20:57:32 l.jay Yuan wrote: > Is iocp module working now? > No, it's not working. wbr, Valentin V. Bartenev From mdounin at mdounin.ru Mon Jul 2 17:22:32 2012 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Mon, 2 Jul 2012 17:22:32 +0000 Subject: [nginx] svn commit: r4731 - in branches/stable-1.2: . auto/os src/os/unix Message-ID: <20120702172232.5278E3F9E2A@mail.nginx.com> Author: mdounin Date: 2012-07-02 17:22:31 +0000 (Mon, 02 Jul 2012) New Revision: 4731 URL: http://trac.nginx.org/nginx/changeset/4731/nginx Log: Merge of r4693: fixed "sendmsg() failed" alerts on HP-UX. HP-UX needs _HPUX_ALT_XOPEN_SOCKET_API to be defined to be able to use various POSIX versions of networking functions. Notably sendmsg() resulted in "sendmsg() failed (9: Bad file number)" alerts without it. See xopen_networking(7) for more details. Modified: branches/stable-1.2/ branches/stable-1.2/auto/os/conf branches/stable-1.2/src/os/unix/ngx_posix_config.h Index: branches/stable-1.2 =================================================================== --- branches/stable-1.2 2012-07-02 17:08:26 UTC (rev 4730) +++ branches/stable-1.2 2012-07-02 17:22:31 UTC (rev 4731) Property changes on: branches/stable-1.2 ___________________________________________________________________ Modified: svn:mergeinfo ## -1 +1 ## -/trunk:4611-4632,4636-4657,4671-4672,4674-4676,4682,4684-4692,4694-4696,4699,4704-4706 +/trunk:4611-4632,4636-4657,4671-4672,4674-4676,4682,4684-4696,4699,4704-4706 \ No newline at end of property Modified: branches/stable-1.2/auto/os/conf =================================================================== --- branches/stable-1.2/auto/os/conf 2012-07-02 17:08:26 UTC (rev 4730) +++ branches/stable-1.2/auto/os/conf 2012-07-02 17:22:31 UTC (rev 4731) @@ -48,6 +48,7 @@ CORE_DEPS="$UNIX_DEPS $POSIX_DEPS" CORE_SRCS="$UNIX_SRCS" CC_AUX_FLAGS="$CC_AUX_FLAGS -D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED=1" + CC_AUX_FLAGS="$CC_AUX_FLAGS -D_HPUX_ALT_XOPEN_SOCKET_API" ;; OSF1:*) Modified: branches/stable-1.2/src/os/unix/ngx_posix_config.h =================================================================== --- branches/stable-1.2/src/os/unix/ngx_posix_config.h 2012-07-02 17:08:26 UTC (rev 4730) +++ branches/stable-1.2/src/os/unix/ngx_posix_config.h 2012-07-02 17:22:31 UTC (rev 4731) @@ -12,6 +12,7 @@ #if (NGX_HPUX) #define _XOPEN_SOURCE #define _XOPEN_SOURCE_EXTENDED 1 +#define _HPUX_ALT_XOPEN_SOCKET_API #endif From mdounin at mdounin.ru Mon Jul 2 17:25:51 2012 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Mon, 2 Jul 2012 17:25:51 +0000 Subject: [nginx] svn commit: r4732 - in branches/stable-1.2: . src/event Message-ID: <20120702172551.D3CCE3F9E2A@mail.nginx.com> Author: mdounin Date: 2012-07-02 17:25:51 +0000 (Mon, 02 Jul 2012) New Revision: 4732 URL: http://trac.nginx.org/nginx/changeset/4732/nginx Log: Merge of r4697: disabled gzip in OpenSSL prior to 1.0.0. Disabled gzip compression in OpenSSL prior to 1.0.0 version. This saves about 522K per connection. Modified: branches/stable-1.2/ branches/stable-1.2/src/event/ngx_event_openssl.c Index: branches/stable-1.2 =================================================================== --- branches/stable-1.2 2012-07-02 17:22:31 UTC (rev 4731) +++ branches/stable-1.2 2012-07-02 17:25:51 UTC (rev 4732) Property changes on: branches/stable-1.2 ___________________________________________________________________ Modified: svn:mergeinfo ## -1 +1 ## -/trunk:4611-4632,4636-4657,4671-4672,4674-4676,4682,4684-4696,4699,4704-4706 +/trunk:4611-4632,4636-4657,4671-4672,4674-4676,4682,4684-4697,4699,4704-4706 \ No newline at end of property Modified: branches/stable-1.2/src/event/ngx_event_openssl.c =================================================================== --- branches/stable-1.2/src/event/ngx_event_openssl.c 2012-07-02 17:22:31 UTC (rev 4731) +++ branches/stable-1.2/src/event/ngx_event_openssl.c 2012-07-02 17:25:51 UTC (rev 4732) @@ -94,6 +94,24 @@ OpenSSL_add_all_algorithms(); +#ifndef SSL_OP_NO_COMPRESSION + { + /* + * Disable gzip compression in OpenSSL prior to 1.0.0 version, + * this saves about 522K per connection. + */ + int i, n; + STACK_OF(SSL_COMP) *ssl_comp_methods; + + ssl_comp_methods = SSL_COMP_get_compression_methods(); + n = sk_SSL_COMP_num(ssl_comp_methods); + + for (i = 0; i < n; i++) { + (void) sk_SSL_COMP_delete(ssl_comp_methods, i); + } + } +#endif + ngx_ssl_connection_index = SSL_get_ex_new_index(0, NULL, NULL, NULL, NULL); if (ngx_ssl_connection_index == -1) { From piotr.sikora at frickle.com Mon Jul 2 17:40:45 2012 From: piotr.sikora at frickle.com (Piotr Sikora) Date: Mon, 2 Jul 2012 19:40:45 +0200 Subject: Patch for ngx_purge_cache on nginx-1.3.2 not working In-Reply-To: <20120628134457.GA53777@lo0.su> References: <20120628134457.GA53777@lo0.su> Message-ID: Hey, > This is a wrong patch. As of 1.3.2, nginx no longer exposes the > NGX_HTTP_PROXY macro, and it never exposed any of the macros > NGX_HTTP_{FASTCGI,SCGI,UWSGI} that this module is trying to use > to detect if the modules were configured to be built. > > The below patch should be better compatible with both old and > changed versions of nginx: > > %%% > --- ngx_cache_purge-1.5/config 2011-12-20 16:36:20.000000000 +0400 > +++ ngx_cache_purge-1.5/config 2012-06-28 17:33:42.000000000 +0400 > @@ -1,3 +1,7 @@ > +if [ "$HTTP_PROXY" = "YES" ]; then > + have=NGX_HTTP_PROXY . auto/have > +fi > + > if [ "$HTTP_FASTCGI" = "YES" ]; then > have=NGX_HTTP_FASTCGI . auto/have > fi > %%% Committed, thanks to both of you! Best regards, Piotr Sikora < piotr.sikora at frickle.com > From mdounin at mdounin.ru Mon Jul 2 17:41:52 2012 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Mon, 2 Jul 2012 17:41:52 +0000 Subject: [nginx] svn commit: r4733 - in branches/stable-1.2: . auto src/http Message-ID: <20120702174153.74A9C3FA59D@mail.nginx.com> Author: mdounin Date: 2012-07-02 17:41:52 +0000 (Mon, 02 Jul 2012) New Revision: 4733 URL: http://trac.nginx.org/nginx/changeset/4733/nginx Log: Merge of r4698: X-Forwarded-For conditionals. Fixed compile-time conditionals used to detect if X-Forwarded-For support is needed. Note: compatibility shims where added during merge to avoid possible breakage of 3rd party modules. At least cache purge module was broken by the original commit, as it used to rely on NGX_HTTP_PROXY define. Modified: branches/stable-1.2/ branches/stable-1.2/auto/modules branches/stable-1.2/src/http/ngx_http_request.c branches/stable-1.2/src/http/ngx_http_request.h branches/stable-1.2/src/http/ngx_http_variables.c Index: branches/stable-1.2 =================================================================== --- branches/stable-1.2 2012-07-02 17:25:51 UTC (rev 4732) +++ branches/stable-1.2 2012-07-02 17:41:52 UTC (rev 4733) Property changes on: branches/stable-1.2 ___________________________________________________________________ Modified: svn:mergeinfo ## -1 +1 ## -/trunk:4611-4632,4636-4657,4671-4672,4674-4676,4682,4684-4697,4699,4704-4706 +/trunk:4611-4632,4636-4657,4671-4672,4674-4676,4682,4684-4699,4704-4706 \ No newline at end of property Modified: branches/stable-1.2/auto/modules =================================================================== --- branches/stable-1.2/auto/modules 2012-07-02 17:25:51 UTC (rev 4732) +++ branches/stable-1.2/auto/modules 2012-07-02 17:41:52 UTC (rev 4733) @@ -223,6 +223,7 @@ if [ $HTTP_REALIP = YES ]; then have=NGX_HTTP_REALIP . auto/have + have=NGX_HTTP_X_FORWARDED_FOR . auto/have HTTP_MODULES="$HTTP_MODULES $HTTP_REALIP_MODULE" HTTP_SRCS="$HTTP_SRCS $HTTP_REALIP_SRCS" fi @@ -234,11 +235,13 @@ if [ $HTTP_GEO = YES ]; then have=NGX_HTTP_GEO . auto/have + have=NGX_HTTP_X_FORWARDED_FOR . auto/have HTTP_MODULES="$HTTP_MODULES $HTTP_GEO_MODULE" HTTP_SRCS="$HTTP_SRCS $HTTP_GEO_SRCS" fi if [ $HTTP_GEOIP = YES ]; then + have=NGX_HTTP_X_FORWARDED_FOR . auto/have HTTP_MODULES="$HTTP_MODULES $HTTP_GEOIP_MODULE" HTTP_SRCS="$HTTP_SRCS $HTTP_GEOIP_SRCS" fi @@ -274,6 +277,7 @@ if [ $HTTP_PROXY = YES ]; then have=NGX_HTTP_PROXY . auto/have + have=NGX_HTTP_X_FORWARDED_FOR . auto/have #USE_MD5=YES HTTP_MODULES="$HTTP_MODULES $HTTP_PROXY_MODULE" HTTP_DEPS="$HTTP_DEPS $HTTP_PROXY_DEPS" Modified: branches/stable-1.2/src/http/ngx_http_request.c =================================================================== --- branches/stable-1.2/src/http/ngx_http_request.c 2012-07-02 17:25:51 UTC (rev 4732) +++ branches/stable-1.2/src/http/ngx_http_request.c 2012-07-02 17:41:52 UTC (rev 4733) @@ -138,7 +138,7 @@ { ngx_string("Keep-Alive"), offsetof(ngx_http_headers_in_t, keep_alive), ngx_http_process_header_line }, -#if (NGX_HTTP_PROXY || NGX_HTTP_REALIP || NGX_HTTP_GEO) +#if (NGX_HTTP_X_FORWARDED_FOR) { ngx_string("X-Forwarded-For"), offsetof(ngx_http_headers_in_t, x_forwarded_for), ngx_http_process_header_line }, Modified: branches/stable-1.2/src/http/ngx_http_request.h =================================================================== --- branches/stable-1.2/src/http/ngx_http_request.h 2012-07-02 17:25:51 UTC (rev 4732) +++ branches/stable-1.2/src/http/ngx_http_request.h 2012-07-02 17:41:52 UTC (rev 4733) @@ -137,6 +137,13 @@ #define NGX_HTTP_COPY_BUFFERED 0x04 +#if (NGX_HTTP_PROXY || NGX_HTTP_REALIP || NGX_HTTP_GEO) +#ifndef NGX_HTTP_X_FORWARDED_FOR +#define NGX_HTTP_X_FORWARDED_FOR 1 +#endif +#endif + + typedef enum { NGX_HTTP_INITING_REQUEST_STATE = 0, NGX_HTTP_READING_REQUEST_STATE, @@ -192,7 +199,7 @@ ngx_table_elt_t *keep_alive; -#if (NGX_HTTP_PROXY || NGX_HTTP_REALIP || NGX_HTTP_GEO) +#if (NGX_HTTP_X_FORWARDED_FOR) ngx_table_elt_t *x_forwarded_for; #endif Modified: branches/stable-1.2/src/http/ngx_http_variables.c =================================================================== --- branches/stable-1.2/src/http/ngx_http_variables.c 2012-07-02 17:25:51 UTC (rev 4732) +++ branches/stable-1.2/src/http/ngx_http_variables.c 2012-07-02 17:41:52 UTC (rev 4733) @@ -134,7 +134,7 @@ offsetof(ngx_http_request_t, headers_in.via), 0, 0 }, #endif -#if (NGX_HTTP_PROXY || NGX_HTTP_REALIP) +#if (NGX_HTTP_X_FORWARDED_FOR) { ngx_string("http_x_forwarded_for"), NULL, ngx_http_variable_header, offsetof(ngx_http_request_t, headers_in.x_forwarded_for), 0, 0 }, #endif From pass86 at gmail.com Mon Jul 2 17:48:12 2012 From: pass86 at gmail.com (l.jay Yuan) Date: Tue, 3 Jul 2012 01:48:12 +0800 Subject: Is iocp module working now? In-Reply-To: <201207022108.23765.ne@vbart.ru> References: <201207022108.23765.ne@vbart.ru> Message-ID: When do you think I can use :D 2012/7/3 Valentin V. Bartenev : > On Monday 02 July 2012 20:57:32 l.jay Yuan wrote: >> Is iocp module working now? >> > > No, it's not working. > > wbr, Valentin V. Bartenev > > _______________________________________________ > nginx-devel mailing list > nginx-devel at nginx.org > http://mailman.nginx.org/mailman/listinfo/nginx-devel From mdounin at mdounin.ru Tue Jul 3 10:48:31 2012 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Tue, 3 Jul 2012 10:48:31 +0000 Subject: [nginx] svn commit: r4734 - branches/stable-1.2/docs/xml/nginx Message-ID: <20120703104832.89E8A3FA051@mail.nginx.com> Author: mdounin Date: 2012-07-03 10:48:31 +0000 (Tue, 03 Jul 2012) New Revision: 4734 URL: http://trac.nginx.org/nginx/changeset/4734/nginx Log: nginx-1.2.2-RELEASE Modified: branches/stable-1.2/docs/xml/nginx/changes.xml Modified: branches/stable-1.2/docs/xml/nginx/changes.xml =================================================================== --- branches/stable-1.2/docs/xml/nginx/changes.xml 2012-07-02 17:41:52 UTC (rev 4733) +++ branches/stable-1.2/docs/xml/nginx/changes.xml 2012-07-03 10:48:31 UTC (rev 4734) @@ -9,6 +9,210 @@ nginx changelog + + + + +???????? single ????????? keepalive ?????? ????????????. + + +the "single" parameter of the "keepalive" directive is now ignored. + + + + + +?????? SSL ?????? ????????? +? ??? ????? ??? ????????????? OpenSSL c????? 1.0.0. + + +SSL compression is now disabled when using all versions of OpenSSL, +including ones prior to 1.0.0. + + + + + +????????? proxy_pass, fastcgi_pass, scgi_pass, uwsgi_pass ? +????????? server ? ????? upstream +?????? ???????????? IPv6-??????. + + +the "proxy_pass", "fastcgi_pass", "scgi_pass", "uwsgi_pass" directives, and +the "server" directive inside the "upstream" block, +now support IPv6 addresses. + + + + + +? ????????? resolver ?????? ????? ????????? ???? ? +???????? IPv6-?????? DNS-????????. + + +the "resolver" directive now support IPv6 addresses and +an optional port specification. + + + + + +????????? least_conn ? ????? upstream. + + +the "least_conn" directive inside the "upstream" block. + + + + + +??? ????????????? ????????? ip_hash +?????? ????? ???????? ???? ????????. + + +it is now possible to specify a weight for servers +while using the "ip_hash" directive. + + + + + +????????? "ip_hash" ?????? ????? ???????????? ??? ???????????? IPv6 ????????. + + +it is now possible to use the "ip_hash" directive to balance IPv6 clients. + + + + + +?????????? $status ?????? ????? ???????????? ?? ?????? ? ????????? log_format. + + +the $status variable can now be used not only in the "log_format" directive. + + + + + +nginx ?? ????????? ? ??????? ngx_cpp_test_module; +?????? ????????? ? 1.1.12. + + +nginx could not be built with ngx_cpp_test_module; +the bug had appeared in 1.1.12. + + + + + +?????? ? ?????????? ?? SSI ? ??????????? ????? ??? ?? ???????? ????? +????????????????.
+??????? Yichun Zhang. +
+ +access to variables from SSI and embedded perl module might not work after +reconfiguration.
+Thanks to Yichun Zhang. +
+
+ + + +? ?????? ngx_http_xslt_filter_module.
+??????? Kuramoto Eiji. +
+ +in the ngx_http_xslt_filter_module.
+Thanks to Kuramoto Eiji. +
+
+ + + +?????? ?????? ??? ????????????? ?????????? $geoip_org.
+??????? ?????? ????????. +
+ +memory leak if $geoip_org variable was used.
+Thanks to Denis F. Latypoff. +
+
+ + + +? ?????????? proxy_cookie_domain ? proxy_cookie_path. + + +in the "proxy_cookie_domain" and "proxy_cookie_path" directives. + + + + + +??? ?????????? ???????? ???????? ??? ????????? segmentation fault, +???? ?????????????? ????????? resolver. + + +a segmentation fault might occur in a worker process on shutdown +if the "resolver" directive was used. + + + + + +? ??????? ???????? ??? ????????? segmentation fault, +???? ????????????? ?????? ngx_http_mp4_module. + + +a segmentation fault might occur in a worker process +if the ngx_http_mp4_module was used. + + + + + +? ?????? ngx_http_mp4_module. + + +in the ngx_http_mp4_module. + + + + + +? ??????? ???????? ??? ????????? segmentation fault, +???? ?????????????? ????????????? ????? ???????? ? ???????. + + +a segmentation fault might occur in a worker process +if conflicting wildcard server names were used. + + + + + +?? ????????? ARM nginx ??? ???????? ??????????? ?? ??????? SIGBUS. + + +nginx might be terminated abnormally on a SIGBUS signal on ARM platform. + + + + + +?? ????? ???????????????? ?? HP-UX ? ??? +??????????? alert "sendmsg() failed (9: Bad file number)". + + +an alert "sendmsg() failed (9: Bad file number)" on HP-UX +while reconfiguration. + + + +
+ + From mdounin at mdounin.ru Tue Jul 3 10:48:54 2012 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Tue, 3 Jul 2012 10:48:54 +0000 Subject: [nginx] svn commit: r4735 - in tags: . release-1.2.2 Message-ID: <20120703104856.681143FA1A5@mail.nginx.com> Author: mdounin Date: 2012-07-03 10:48:54 +0000 (Tue, 03 Jul 2012) New Revision: 4735 URL: http://trac.nginx.org/nginx/changeset/4735/nginx Log: release-1.2.2 tag Added: tags/release-1.2.2/ Index: tags/release-1.2.2 =================================================================== --- branches/stable-1.2 2012-07-03 10:48:31 UTC (rev 4734) +++ tags/release-1.2.2 2012-07-03 10:48:54 UTC (rev 4735) Property changes on: tags/release-1.2.2 ___________________________________________________________________ Added: svn:ignore ## -0,0 +1,14 ## +access.log +client_body_temp +fastcgi_temp +proxy_temp +scgi_temp +uwsgi_temp +GNUmakefile +Makefile +makefile +nginx +nginx.conf +nginx-*.tar.gz +objs* +tmp Added: svn:mergeinfo ## -0,0 +1 ## +/trunk:4611-4632,4636-4657,4671-4672,4674-4676,4682,4684-4699,4704-4706 \ No newline at end of property From mdounin at mdounin.ru Tue Jul 3 11:28:55 2012 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Tue, 3 Jul 2012 11:28:55 +0000 Subject: [nginx] svn commit: r4736 - trunk/docs/xml/nginx Message-ID: <20120703112855.6497C3F9ECC@mail.nginx.com> Author: mdounin Date: 2012-07-03 11:28:54 +0000 (Tue, 03 Jul 2012) New Revision: 4736 URL: http://trac.nginx.org/nginx/changeset/4736/nginx Log: Typo fixed. Modified: trunk/docs/xml/nginx/changes.xml Modified: trunk/docs/xml/nginx/changes.xml =================================================================== --- trunk/docs/xml/nginx/changes.xml 2012-07-03 10:48:54 UTC (rev 4735) +++ trunk/docs/xml/nginx/changes.xml 2012-07-03 11:28:54 UTC (rev 4736) @@ -148,7 +148,7 @@ ???????? IPv6-?????? DNS-????????. -the "resolver" directive now support IPv6 addresses and +the "resolver" directive now supports IPv6 addresses and an optional port specification. From mdounin at mdounin.ru Tue Jul 3 11:30:05 2012 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Tue, 3 Jul 2012 11:30:05 +0000 Subject: [nginx] svn commit: r4737 - trunk/src/http Message-ID: <20120703113005.E35593F9ECC@mail.nginx.com> Author: mdounin Date: 2012-07-03 11:30:05 +0000 (Tue, 03 Jul 2012) New Revision: 4737 URL: http://trac.nginx.org/nginx/changeset/4737/nginx Log: Reset r->uri_changed in a named location (ticket #184). Modified: trunk/src/http/ngx_http_core_module.c Modified: trunk/src/http/ngx_http_core_module.c =================================================================== --- trunk/src/http/ngx_http_core_module.c 2012-07-03 11:28:54 UTC (rev 4736) +++ trunk/src/http/ngx_http_core_module.c 2012-07-03 11:30:05 UTC (rev 4737) @@ -2588,6 +2588,7 @@ r->internal = 1; r->content_handler = NULL; + r->uri_changed = 0; r->loc_conf = (*clcfp)->loc_conf; /* clear the modules contexts */ From ru at nginx.com Tue Jul 3 13:05:18 2012 From: ru at nginx.com (ru at nginx.com) Date: Tue, 3 Jul 2012 13:05:18 +0000 Subject: [nginx] svn commit: r4738 - trunk/src/os/unix Message-ID: <20120703130518.7F0F53F9F47@mail.nginx.com> Author: ru Date: 2012-07-03 13:05:18 +0000 (Tue, 03 Jul 2012) New Revision: 4738 URL: http://trac.nginx.org/nginx/changeset/4738/nginx Log: Made sure to initialize the entire "struct flock" allocated on stack. Modified: trunk/src/os/unix/ngx_files.c Modified: trunk/src/os/unix/ngx_files.c =================================================================== --- trunk/src/os/unix/ngx_files.c 2012-07-03 11:30:05 UTC (rev 4737) +++ trunk/src/os/unix/ngx_files.c 2012-07-03 13:05:18 UTC (rev 4738) @@ -413,9 +413,7 @@ { struct flock fl; - fl.l_start = 0; - fl.l_len = 0; - fl.l_pid = 0; + ngx_memzero(&fl, sizeof(struct flock)); fl.l_type = F_WRLCK; fl.l_whence = SEEK_SET; @@ -432,9 +430,7 @@ { struct flock fl; - fl.l_start = 0; - fl.l_len = 0; - fl.l_pid = 0; + ngx_memzero(&fl, sizeof(struct flock)); fl.l_type = F_WRLCK; fl.l_whence = SEEK_SET; @@ -451,9 +447,7 @@ { struct flock fl; - fl.l_start = 0; - fl.l_len = 0; - fl.l_pid = 0; + ngx_memzero(&fl, sizeof(struct flock)); fl.l_type = F_UNLCK; fl.l_whence = SEEK_SET; From ru at nginx.com Tue Jul 3 13:06:41 2012 From: ru at nginx.com (ru at nginx.com) Date: Tue, 3 Jul 2012 13:06:41 +0000 Subject: [nginx] svn commit: r4739 - trunk/src/core Message-ID: <20120703130641.25A573F9C6B@mail.nginx.com> Author: ru Date: 2012-07-03 13:06:40 +0000 (Tue, 03 Jul 2012) New Revision: 4739 URL: http://trac.nginx.org/nginx/changeset/4739/nginx Log: Fixed typo in a function name. Modified: trunk/src/core/ngx_shmtx.c trunk/src/core/ngx_shmtx.h Modified: trunk/src/core/ngx_shmtx.c =================================================================== --- trunk/src/core/ngx_shmtx.c 2012-07-03 13:05:18 UTC (rev 4738) +++ trunk/src/core/ngx_shmtx.c 2012-07-03 13:06:40 UTC (rev 4739) @@ -44,7 +44,7 @@ void -ngx_shmtx_destory(ngx_shmtx_t *mtx) +ngx_shmtx_destroy(ngx_shmtx_t *mtx) { #if (NGX_HAVE_POSIX_SEM) @@ -208,7 +208,7 @@ return NGX_OK; } - ngx_shmtx_destory(mtx); + ngx_shmtx_destroy(mtx); } mtx->fd = ngx_open_file(name, NGX_FILE_RDWR, NGX_FILE_CREATE_OR_OPEN, @@ -232,7 +232,7 @@ void -ngx_shmtx_destory(ngx_shmtx_t *mtx) +ngx_shmtx_destroy(ngx_shmtx_t *mtx) { if (ngx_close_file(mtx->fd) == NGX_FILE_ERROR) { ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, ngx_errno, Modified: trunk/src/core/ngx_shmtx.h =================================================================== --- trunk/src/core/ngx_shmtx.h 2012-07-03 13:05:18 UTC (rev 4738) +++ trunk/src/core/ngx_shmtx.h 2012-07-03 13:06:40 UTC (rev 4739) @@ -39,7 +39,7 @@ ngx_int_t ngx_shmtx_create(ngx_shmtx_t *mtx, ngx_shmtx_sh_t *addr, u_char *name); -void ngx_shmtx_destory(ngx_shmtx_t *mtx); +void ngx_shmtx_destroy(ngx_shmtx_t *mtx); ngx_uint_t ngx_shmtx_trylock(ngx_shmtx_t *mtx); void ngx_shmtx_lock(ngx_shmtx_t *mtx); void ngx_shmtx_unlock(ngx_shmtx_t *mtx); From crk_world at yahoo.com.cn Wed Jul 4 07:47:50 2012 From: crk_world at yahoo.com.cn (chen cw) Date: Wed, 4 Jul 2012 15:47:50 +0800 Subject: nginx.org documents in simplified Chinese In-Reply-To: References: <20120530125746.GX31671@mdounin.ru> <20120628103657.GB47269@lo0.su> Message-ID: It's honor that the nginx's official site accepts our Chinese patch, and now, for the further development, we apply for the Chinese document site. This site will be under the tengine.taobao.org, and will look exactly the same style as the nginx official document site. This site will update the latest Chinese translation results, attract more people participating, and finally cover all the contents from your official nginx site. We are sure to update the patches, so we need your permit to build the site. Thank you On Fri, Jun 29, 2012 at 11:20 PM, Joshua Zhu wrote: > Hi, > > On Thu, Jun 28, 2012 at 6:36 PM, Ruslan Ermilov wrote: > >> Hi there, >> >> On Thu, May 31, 2012 at 07:54:02PM +0800, chen cw wrote: >> > I come here with the patch for [1]nginx.org documents in simplified >> > Chinese, and I'm glad that someone will give it a review. This work is >> > done by the whole Server Platforms Team at Taobao.com. >> >> I've committed your translation, thanks! >> >> The only changes I made were: >> >> - removed translated version of security_advisories (we only >> maintain a single version of it in English); >> >> - put English and Russian at the top of the language list as >> these are the only two officially supported translations; >> >> - made GNUmakefile diff'able with other languages makefiles. >> >> Don't hesitate to send us more patches and keep them updated! > > > Thanks a lot! > We'll keep on working on it. > > Regards, > > -- > Joshua Zhu > Senior Software Engineer > > Server Platforms Team at Taobao > -- -- Charles Chen Software Engineer Server Platforms Team at Taobao.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From ru at nginx.com Thu Jul 5 09:32:02 2012 From: ru at nginx.com (Ruslan Ermilov) Date: Thu, 5 Jul 2012 13:32:02 +0400 Subject: nginx.org documents in simplified Chinese In-Reply-To: References: <20120530125746.GX31671@mdounin.ru> <20120628103657.GB47269@lo0.su> Message-ID: <20120705093202.GF78937@lo0.su> On Wed, Jul 04, 2012 at 03:47:50PM +0800, chen cw wrote: > It's honor that the nginx's official site accepts our Chinese patch, and > now, for the further development, we apply for the Chinese document site. > This site will be under the [1]tengine.taobao.org, and will look exactly > the same style as the nginx official document site. This site will update > the latest Chinese translation results, attract more people participating, > and finally cover all the contents from your official nginx site. We are > sure to update the patches, so we need your permit to build the site. > > Thank you Original docs are part of the nginx distribution and are covered by the same license, http://nginx.org/LICENSE From postmaster at softsearch.ru Thu Jul 5 18:57:26 2012 From: postmaster at softsearch.ru (=?Windows-1251?B?zOj14OjrIMzu7eD4uOI=?=) Date: Thu, 5 Jul 2012 22:57:26 +0400 Subject: Memory allocators test Message-ID: <1652170354.20120705225726@softsearch.ru> Hi! It can be infesting for nginx developers: http://www.mysqlperformanceblog.com/2012/07/05/impact-of-memory-allocators-on-mysql-performance/ -- ? ?????????, ?????? mailto:postmaster at softsearch.ru From defan at nginx.com Fri Jul 6 04:27:06 2012 From: defan at nginx.com (defan at nginx.com) Date: Fri, 6 Jul 2012 04:27:06 +0000 Subject: [nginx] svn commit: r4740 - trunk/src/http Message-ID: <20120706042706.BD15D3F9F3A@mail.nginx.com> Author: defan Date: 2012-07-06 04:27:06 +0000 (Fri, 06 Jul 2012) New Revision: 4740 URL: http://trac.nginx.org/nginx/changeset/4740/nginx Log: Corrected $request_length calculation for pipelined requests. Modified: trunk/src/http/ngx_http_request.c Modified: trunk/src/http/ngx_http_request.c =================================================================== --- trunk/src/http/ngx_http_request.c 2012-07-03 13:06:40 UTC (rev 4739) +++ trunk/src/http/ngx_http_request.c 2012-07-06 04:27:06 UTC (rev 4740) @@ -747,6 +747,7 @@ r->request_line.len = r->request_end - r->request_start; r->request_line.data = r->request_start; + r->request_length = r->header_in->pos - r->request_start; if (r->args_start) { @@ -1056,6 +1057,8 @@ if (rc == NGX_OK) { + r->request_length += r->header_in->pos - r->header_name_start; + if (r->invalid_header && cscf->ignore_invalid_headers) { /* there was error while a header line parsing */ @@ -1119,7 +1122,7 @@ ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "http header done"); - r->request_length += r->header_in->pos - r->header_in->start; + r->request_length += r->header_in->pos - r->header_name_start; r->http_state = NGX_HTTP_PROCESS_REQUEST_STATE; @@ -1226,8 +1229,6 @@ /* the client fills up the buffer with "\r\n" */ - r->request_length += r->header_in->end - r->header_in->start; - r->header_in->pos = r->header_in->start; r->header_in->last = r->header_in->start; @@ -1287,8 +1288,6 @@ * to relocate the parser header pointers */ - r->request_length += r->header_in->end - r->header_in->start; - r->header_in = b; return NGX_OK; @@ -1297,8 +1296,6 @@ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "http large header copy: %d", r->header_in->pos - old); - r->request_length += old - r->header_in->start; - new = b->start; ngx_memcpy(new, old, r->header_in->pos - old); From mdounin at mdounin.ru Sat Jul 7 09:35:32 2012 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Sat, 7 Jul 2012 09:35:32 +0000 Subject: [nginx] svn commit: r4741 - in trunk/auto: . lib/libatomic lib/perl Message-ID: <20120707093533.447553FA017@mail.nginx.com> Author: mdounin Date: 2012-07-07 09:35:30 +0000 (Sat, 07 Jul 2012) New Revision: 4741 URL: http://trac.nginx.org/nginx/changeset/4741/nginx Log: Configure: fixed "make" used instead of "${MAKE}". Modified: trunk/auto/install trunk/auto/lib/libatomic/make trunk/auto/lib/perl/make Modified: trunk/auto/install =================================================================== --- trunk/auto/install 2012-07-06 04:27:06 UTC (rev 4740) +++ trunk/auto/install 2012-07-07 09:35:30 UTC (rev 4741) @@ -8,7 +8,7 @@ cat << END >> $NGX_MAKEFILE install_perl_modules: - cd $NGX_OBJS/src/http/modules/perl && make install + cd $NGX_OBJS/src/http/modules/perl && \${MAKE} install END NGX_INSTALL_PERL_MODULES=install_perl_modules Modified: trunk/auto/lib/libatomic/make =================================================================== --- trunk/auto/lib/libatomic/make 2012-07-06 04:27:06 UTC (rev 4740) +++ trunk/auto/lib/libatomic/make 2012-07-07 09:35:30 UTC (rev 4741) @@ -6,7 +6,7 @@ cat << END >> $NGX_MAKEFILE $NGX_LIBATOMIC/src/libatomic_ops.a: $NGX_LIBATOMIC/Makefile - cd $NGX_LIBATOMIC && make + cd $NGX_LIBATOMIC && \${MAKE} $NGX_LIBATOMIC/Makefile: $NGX_MAKEFILE cd $NGX_LIBATOMIC && ./configure Modified: trunk/auto/lib/perl/make =================================================================== --- trunk/auto/lib/perl/make 2012-07-06 04:27:06 UTC (rev 4740) +++ trunk/auto/lib/perl/make 2012-07-07 09:35:30 UTC (rev 4741) @@ -12,7 +12,7 @@ $NGX_OBJS/src/http/modules/perl/Makefile cp -p src/http/modules/perl/nginx.* $NGX_OBJS/src/http/modules/perl/ - cd $NGX_OBJS/src/http/modules/perl && make + cd $NGX_OBJS/src/http/modules/perl && \${MAKE} rm -rf $NGX_OBJS/install_perl From mdounin at mdounin.ru Sat Jul 7 21:16:22 2012 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Sat, 7 Jul 2012 21:16:22 +0000 Subject: [nginx] svn commit: r4742 - trunk/src/http/modules Message-ID: <20120707211622.191663F9F2A@mail.nginx.com> Author: mdounin Date: 2012-07-07 21:16:21 +0000 (Sat, 07 Jul 2012) New Revision: 4742 URL: http://trac.nginx.org/nginx/changeset/4742/nginx Log: Fixed If-Range with unknown last modified time. If modification time isn't known, skip range processing and return full entity body instead of just ignoring If-Range. Ignoring If-Range isn't safe as client will assume entity wasn't changed since time specified. Modified: trunk/src/http/modules/ngx_http_range_filter_module.c Modified: trunk/src/http/modules/ngx_http_range_filter_module.c =================================================================== --- trunk/src/http/modules/ngx_http_range_filter_module.c 2012-07-07 09:35:30 UTC (rev 4741) +++ trunk/src/http/modules/ngx_http_range_filter_module.c 2012-07-07 21:16:21 UTC (rev 4742) @@ -174,8 +174,12 @@ goto next_filter; } - if (r->headers_in.if_range && r->headers_out.last_modified_time != -1) { + if (r->headers_in.if_range) { + if (r->headers_out.last_modified_time == (time_t) -1) { + goto next_filter; + } + if_range = ngx_http_parse_time(r->headers_in.if_range->value.data, r->headers_in.if_range->value.len); From mdounin at mdounin.ru Sat Jul 7 21:16:51 2012 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Sat, 7 Jul 2012 21:16:51 +0000 Subject: [nginx] svn commit: r4743 - trunk/src/http/modules Message-ID: <20120707211651.EB0613F9F2F@mail.nginx.com> Author: mdounin Date: 2012-07-07 21:16:51 +0000 (Sat, 07 Jul 2012) New Revision: 4743 URL: http://trac.nginx.org/nginx/changeset/4743/nginx Log: Added Last-Modified parsing in add_header. This allows to use last modified time set in If-Range checks. Code simplified to improve readability. Modified: trunk/src/http/modules/ngx_http_headers_filter_module.c Modified: trunk/src/http/modules/ngx_http_headers_filter_module.c =================================================================== --- trunk/src/http/modules/ngx_http_headers_filter_module.c 2012-07-07 21:16:21 UTC (rev 4742) +++ trunk/src/http/modules/ngx_http_headers_filter_module.c 2012-07-07 21:16:51 UTC (rev 4743) @@ -72,9 +72,7 @@ { ngx_string("Cache-Control"), 0, ngx_http_add_cache_control }, - { ngx_string("Last-Modified"), - offsetof(ngx_http_headers_out_t, last_modified), - ngx_http_set_last_modified }, + { ngx_string("Last-Modified"), 0, ngx_http_set_last_modified }, { ngx_null_string, 0, NULL } }; @@ -368,34 +366,24 @@ ngx_http_set_last_modified(ngx_http_request_t *r, ngx_http_header_val_t *hv, ngx_str_t *value) { - ngx_table_elt_t *h, **old; + ngx_table_elt_t *h; - old = (ngx_table_elt_t **) ((char *) &r->headers_out + hv->offset); + ngx_http_clear_last_modified(r); - r->headers_out.last_modified_time = -1; + if (value->len == 0) { + return NGX_OK; + } - if (*old == NULL) { + r->headers_out.last_modified_time = ngx_http_parse_time(value->data, + value->len); - if (value->len == 0) { - return NGX_OK; - } + h = ngx_list_push(&r->headers_out.headers); + if (h == NULL) { + return NGX_ERROR; + } - h = ngx_list_push(&r->headers_out.headers); - if (h == NULL) { - return NGX_ERROR; - } + r->headers_out.last_modified = h; - *old = h; - - } else { - h = *old; - - if (value->len == 0) { - h->hash = 0; - return NGX_OK; - } - } - h->hash = 1; h->key = hv->key; h->value = *value; From mdounin at mdounin.ru Sat Jul 7 21:18:30 2012 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Sat, 7 Jul 2012 21:18:30 +0000 Subject: [nginx] svn commit: r4744 - trunk/src/http/modules Message-ID: <20120707211830.BF72E3F9F0D@mail.nginx.com> Author: mdounin Date: 2012-07-07 21:18:30 +0000 (Sat, 07 Jul 2012) New Revision: 4744 URL: http://trac.nginx.org/nginx/changeset/4744/nginx Log: Not modified filter: tests separated from actions. This makes code more extendable. The only functional change is when If-Modified-Since and If-Unmodified-Since are specified together, the case which is explicitly left undefined by RFC 2616. The new behaviour is to respect them both, which seems better. Modified: trunk/src/http/modules/ngx_http_not_modified_filter_module.c Modified: trunk/src/http/modules/ngx_http_not_modified_filter_module.c =================================================================== --- trunk/src/http/modules/ngx_http_not_modified_filter_module.c 2012-07-07 21:16:51 UTC (rev 4743) +++ trunk/src/http/modules/ngx_http_not_modified_filter_module.c 2012-07-07 21:18:30 UTC (rev 4744) @@ -10,8 +10,8 @@ #include -static ngx_int_t ngx_http_test_precondition(ngx_http_request_t *r); -static ngx_int_t ngx_http_test_not_modified(ngx_http_request_t *r); +static ngx_uint_t ngx_http_test_if_unmodified(ngx_http_request_t *r); +static ngx_uint_t ngx_http_test_if_modified(ngx_http_request_t *r); static ngx_int_t ngx_http_not_modified_filter_init(ngx_conf_t *cf); @@ -59,20 +59,38 @@ return ngx_http_next_header_filter(r); } - if (r->headers_in.if_unmodified_since) { - return ngx_http_test_precondition(r); + if (r->headers_in.if_unmodified_since + && !ngx_http_test_if_unmodified(r)) + { + return ngx_http_filter_finalize_request(r, NULL, + NGX_HTTP_PRECONDITION_FAILED); } - if (r->headers_in.if_modified_since) { - return ngx_http_test_not_modified(r); + if (r->headers_in.if_modified_since + && !ngx_http_test_if_modified(r)) + { + /* not modified */ + + r->headers_out.status = NGX_HTTP_NOT_MODIFIED; + r->headers_out.status_line.len = 0; + r->headers_out.content_type.len = 0; + ngx_http_clear_content_length(r); + ngx_http_clear_accept_ranges(r); + + if (r->headers_out.content_encoding) { + r->headers_out.content_encoding->hash = 0; + r->headers_out.content_encoding = NULL; + } + + return ngx_http_next_header_filter(r); } return ngx_http_next_header_filter(r); } -static ngx_int_t -ngx_http_test_precondition(ngx_http_request_t *r) +static ngx_uint_t +ngx_http_test_if_unmodified(ngx_http_request_t *r) { time_t iums; @@ -83,16 +101,15 @@ "http iums:%d lm:%d", iums, r->headers_out.last_modified_time); if (iums >= r->headers_out.last_modified_time) { - return ngx_http_next_header_filter(r); + return 1; } - return ngx_http_filter_finalize_request(r, NULL, - NGX_HTTP_PRECONDITION_FAILED); + return 0; } -static ngx_int_t -ngx_http_test_not_modified(ngx_http_request_t *r) +static ngx_uint_t +ngx_http_test_if_modified(ngx_http_request_t *r) { time_t ims; ngx_http_core_loc_conf_t *clcf; @@ -100,7 +117,7 @@ clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); if (clcf->if_modified_since == NGX_HTTP_IMS_OFF) { - return ngx_http_next_header_filter(r); + return 1; } ims = ngx_http_parse_time(r->headers_in.if_modified_since->value.data, @@ -109,27 +126,17 @@ ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "http ims:%d lm:%d", ims, r->headers_out.last_modified_time); - if (ims != r->headers_out.last_modified_time) { - - if (clcf->if_modified_since == NGX_HTTP_IMS_EXACT - || ims < r->headers_out.last_modified_time) - { - return ngx_http_next_header_filter(r); - } + if (ims == r->headers_out.last_modified_time) { + return 0; } - r->headers_out.status = NGX_HTTP_NOT_MODIFIED; - r->headers_out.status_line.len = 0; - r->headers_out.content_type.len = 0; - ngx_http_clear_content_length(r); - ngx_http_clear_accept_ranges(r); - - if (r->headers_out.content_encoding) { - r->headers_out.content_encoding->hash = 0; - r->headers_out.content_encoding = NULL; + if (clcf->if_modified_since == NGX_HTTP_IMS_EXACT + || ims < r->headers_out.last_modified_time) + { + return 1; } - return ngx_http_next_header_filter(r); + return 0; } From mdounin at mdounin.ru Sat Jul 7 21:20:28 2012 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Sat, 7 Jul 2012 21:20:28 +0000 Subject: [nginx] svn commit: r4745 - in trunk/src/http: . modules Message-ID: <20120707212028.4D01E3F9F0D@mail.nginx.com> Author: mdounin Date: 2012-07-07 21:20:27 +0000 (Sat, 07 Jul 2012) New Revision: 4745 URL: http://trac.nginx.org/nginx/changeset/4745/nginx Log: Entity tags: basic support in not modified filter. This includes handling of ETag headers (if present in a response) with basic support for If-Match, If-None-Match conditionals in not modified filter. Note that the "r->headers_out.last_modified_time == -1" check in the not modified filter is left as is intentionally. It's to prevent handling of If-* headers in case of proxy without cache (much like currently done with If-Modified-Since). Modified: trunk/src/http/modules/ngx_http_not_modified_filter_module.c trunk/src/http/ngx_http_request.c trunk/src/http/ngx_http_request.h Modified: trunk/src/http/modules/ngx_http_not_modified_filter_module.c =================================================================== --- trunk/src/http/modules/ngx_http_not_modified_filter_module.c 2012-07-07 21:18:30 UTC (rev 4744) +++ trunk/src/http/modules/ngx_http_not_modified_filter_module.c 2012-07-07 21:20:27 UTC (rev 4745) @@ -12,6 +12,8 @@ static ngx_uint_t ngx_http_test_if_unmodified(ngx_http_request_t *r); static ngx_uint_t ngx_http_test_if_modified(ngx_http_request_t *r); +static ngx_uint_t ngx_http_test_if_match(ngx_http_request_t *r, + ngx_table_elt_t *header); static ngx_int_t ngx_http_not_modified_filter_init(ngx_conf_t *cf); @@ -66,9 +68,27 @@ NGX_HTTP_PRECONDITION_FAILED); } - if (r->headers_in.if_modified_since - && !ngx_http_test_if_modified(r)) + if (r->headers_in.if_match + && !ngx_http_test_if_match(r, r->headers_in.if_match)) { + return ngx_http_filter_finalize_request(r, NULL, + NGX_HTTP_PRECONDITION_FAILED); + } + + if (r->headers_in.if_modified_since || r->headers_in.if_none_match) { + + if (r->headers_in.if_modified_since + && ngx_http_test_if_modified(r)) + { + return ngx_http_next_header_filter(r); + } + + if (r->headers_in.if_none_match + && !ngx_http_test_if_match(r, r->headers_in.if_none_match)) + { + return ngx_http_next_header_filter(r); + } + /* not modified */ r->headers_out.status = NGX_HTTP_NOT_MODIFIED; @@ -140,6 +160,76 @@ } +static ngx_uint_t +ngx_http_test_if_match(ngx_http_request_t *r, ngx_table_elt_t *header) +{ + u_char *start, *end, ch; + ngx_str_t *etag, *list; + + list = &header->value; + + if (list->len == 1 && list->data[0] == '*') { + return 1; + } + + if (r->headers_out.etag == NULL) { + return 0; + } + + etag = &r->headers_out.etag->value; + + ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, + "http im:\"%V\" etag:%V", list, etag); + + start = list->data; + end = list->data + list->len; + + while (start < end) { + + if (etag->len > (size_t) (end - start)) { + return 0; + } + + if (ngx_strncmp(start, etag->data, etag->len) != 0) { + goto skip; + } + + start += etag->len; + + while (start < end) { + ch = *start; + + if (ch == ' ' || ch == '\t') { + start++; + continue; + } + + break; + } + + if (start == end || *start == ',') { + return 1; + } + + skip: + + while (start < end && *start != ',') { start++; } + while (start < end) { + ch = *start; + + if (ch == ' ' || ch == '\t' || ch == ',') { + start++; + continue; + } + + break; + } + } + + return 0; +} + + static ngx_int_t ngx_http_not_modified_filter_init(ngx_conf_t *cf) { Modified: trunk/src/http/ngx_http_request.c =================================================================== --- trunk/src/http/ngx_http_request.c 2012-07-07 21:18:30 UTC (rev 4744) +++ trunk/src/http/ngx_http_request.c 2012-07-07 21:20:27 UTC (rev 4745) @@ -93,6 +93,14 @@ offsetof(ngx_http_headers_in_t, if_unmodified_since), ngx_http_process_unique_header_line }, + { ngx_string("If-Match"), + offsetof(ngx_http_headers_in_t, if_match), + ngx_http_process_unique_header_line }, + + { ngx_string("If-None-Match"), + offsetof(ngx_http_headers_in_t, if_none_match), + ngx_http_process_unique_header_line }, + { ngx_string("User-Agent"), offsetof(ngx_http_headers_in_t, user_agent), ngx_http_process_user_agent }, Modified: trunk/src/http/ngx_http_request.h =================================================================== --- trunk/src/http/ngx_http_request.h 2012-07-07 21:18:30 UTC (rev 4744) +++ trunk/src/http/ngx_http_request.h 2012-07-07 21:20:27 UTC (rev 4745) @@ -172,6 +172,8 @@ ngx_table_elt_t *connection; ngx_table_elt_t *if_modified_since; ngx_table_elt_t *if_unmodified_since; + ngx_table_elt_t *if_match; + ngx_table_elt_t *if_none_match; ngx_table_elt_t *user_agent; ngx_table_elt_t *referer; ngx_table_elt_t *content_length; From mdounin at mdounin.ru Sat Jul 7 21:21:16 2012 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Sat, 7 Jul 2012 21:21:16 +0000 Subject: [nginx] svn commit: r4746 - trunk/src/http/modules Message-ID: <20120707212116.2F12E3F9F0D@mail.nginx.com> Author: mdounin Date: 2012-07-07 21:21:15 +0000 (Sat, 07 Jul 2012) New Revision: 4746 URL: http://trac.nginx.org/nginx/changeset/4746/nginx Log: Entity tags: support in If-Range header. Modified: trunk/src/http/modules/ngx_http_range_filter_module.c Modified: trunk/src/http/modules/ngx_http_range_filter_module.c =================================================================== --- trunk/src/http/modules/ngx_http_range_filter_module.c 2012-07-07 21:20:27 UTC (rev 4745) +++ trunk/src/http/modules/ngx_http_range_filter_module.c 2012-07-07 21:21:15 UTC (rev 4746) @@ -146,7 +146,8 @@ static ngx_int_t ngx_http_range_header_filter(ngx_http_request_t *r) { - time_t if_range; + time_t if_range_time; + ngx_str_t *if_range, *etag; ngx_http_core_loc_conf_t *clcf; ngx_http_range_filter_ctx_t *ctx; @@ -176,22 +177,45 @@ if (r->headers_in.if_range) { + if_range = &r->headers_in.if_range->value; + + if (if_range->len > 2 && if_range->data[if_range->len - 1] == '"') { + + if (r->headers_out.etag == NULL) { + goto next_filter; + } + + etag = &r->headers_out.etag->value; + + ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, + "http ir:%V etag:%V", if_range, etag); + + if (if_range->len != etag->len + || ngx_strncmp(if_range->data, etag->data, etag->len) != 0) + { + goto next_filter; + } + + goto parse; + } + if (r->headers_out.last_modified_time == (time_t) -1) { goto next_filter; } - if_range = ngx_http_parse_time(r->headers_in.if_range->value.data, - r->headers_in.if_range->value.len); + if_range_time = ngx_http_parse_time(if_range->data, if_range->len); ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "http ir:%d lm:%d", - if_range, r->headers_out.last_modified_time); + if_range_time, r->headers_out.last_modified_time); - if (if_range != r->headers_out.last_modified_time) { + if (if_range_time != r->headers_out.last_modified_time) { goto next_filter; } } +parse: + ctx = ngx_pcalloc(r->pool, sizeof(ngx_http_range_filter_ctx_t)); if (ctx == NULL) { return NGX_ERROR; From mdounin at mdounin.ru Sat Jul 7 21:22:27 2012 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Sat, 7 Jul 2012 21:22:27 +0000 Subject: [nginx] svn commit: r4747 - in trunk/src/http: . modules Message-ID: <20120707212229.0223C3F9F0D@mail.nginx.com> Author: mdounin Date: 2012-07-07 21:22:27 +0000 (Sat, 07 Jul 2012) New Revision: 4747 URL: http://trac.nginx.org/nginx/changeset/4747/nginx Log: Entity tags: clear on entity changes. Modified: trunk/src/http/modules/ngx_http_addition_filter_module.c trunk/src/http/modules/ngx_http_gzip_filter_module.c trunk/src/http/modules/ngx_http_ssi_filter_module.c trunk/src/http/modules/ngx_http_sub_filter_module.c trunk/src/http/modules/ngx_http_xslt_filter_module.c trunk/src/http/ngx_http_core_module.h trunk/src/http/ngx_http_special_response.c Modified: trunk/src/http/modules/ngx_http_addition_filter_module.c =================================================================== --- trunk/src/http/modules/ngx_http_addition_filter_module.c 2012-07-07 21:21:15 UTC (rev 4746) +++ trunk/src/http/modules/ngx_http_addition_filter_module.c 2012-07-07 21:22:27 UTC (rev 4747) @@ -121,6 +121,7 @@ ngx_http_clear_content_length(r); ngx_http_clear_accept_ranges(r); + ngx_http_clear_etag(r); return ngx_http_next_header_filter(r); } Modified: trunk/src/http/modules/ngx_http_gzip_filter_module.c =================================================================== --- trunk/src/http/modules/ngx_http_gzip_filter_module.c 2012-07-07 21:21:15 UTC (rev 4746) +++ trunk/src/http/modules/ngx_http_gzip_filter_module.c 2012-07-07 21:22:27 UTC (rev 4747) @@ -306,6 +306,7 @@ ngx_http_clear_content_length(r); ngx_http_clear_accept_ranges(r); + ngx_http_clear_etag(r); return ngx_http_next_header_filter(r); } Modified: trunk/src/http/modules/ngx_http_ssi_filter_module.c =================================================================== --- trunk/src/http/modules/ngx_http_ssi_filter_module.c 2012-07-07 21:21:15 UTC (rev 4746) +++ trunk/src/http/modules/ngx_http_ssi_filter_module.c 2012-07-07 21:22:27 UTC (rev 4747) @@ -361,6 +361,7 @@ ngx_http_clear_content_length(r); ngx_http_clear_last_modified(r); ngx_http_clear_accept_ranges(r); + ngx_http_clear_etag(r); } return ngx_http_next_header_filter(r); Modified: trunk/src/http/modules/ngx_http_sub_filter_module.c =================================================================== --- trunk/src/http/modules/ngx_http_sub_filter_module.c 2012-07-07 21:21:15 UTC (rev 4746) +++ trunk/src/http/modules/ngx_http_sub_filter_module.c 2012-07-07 21:22:27 UTC (rev 4747) @@ -168,6 +168,7 @@ if (r == r->main) { ngx_http_clear_content_length(r); ngx_http_clear_last_modified(r); + ngx_http_clear_etag(r); } return ngx_http_next_header_filter(r); Modified: trunk/src/http/modules/ngx_http_xslt_filter_module.c =================================================================== --- trunk/src/http/modules/ngx_http_xslt_filter_module.c 2012-07-07 21:21:15 UTC (rev 4746) +++ trunk/src/http/modules/ngx_http_xslt_filter_module.c 2012-07-07 21:22:27 UTC (rev 4747) @@ -328,6 +328,7 @@ } ngx_http_clear_last_modified(r); + ngx_http_clear_etag(r); } rc = ngx_http_next_header_filter(r); Modified: trunk/src/http/ngx_http_core_module.h =================================================================== --- trunk/src/http/ngx_http_core_module.h 2012-07-07 21:21:15 UTC (rev 4746) +++ trunk/src/http/ngx_http_core_module.h 2012-07-07 21:22:27 UTC (rev 4747) @@ -555,5 +555,12 @@ r->headers_out.location = NULL; \ } +#define ngx_http_clear_etag(r) \ + \ + if (r->headers_out.etag) { \ + r->headers_out.etag->hash = 0; \ + r->headers_out.etag = NULL; \ + } + #endif /* _NGX_HTTP_CORE_H_INCLUDED_ */ Modified: trunk/src/http/ngx_http_special_response.c =================================================================== --- trunk/src/http/ngx_http_special_response.c 2012-07-07 21:21:15 UTC (rev 4746) +++ trunk/src/http/ngx_http_special_response.c 2012-07-07 21:22:27 UTC (rev 4747) @@ -656,6 +656,7 @@ ngx_http_clear_accept_ranges(r); ngx_http_clear_last_modified(r); + ngx_http_clear_etag(r); rc = ngx_http_send_header(r); @@ -754,6 +755,7 @@ ngx_http_clear_accept_ranges(r); ngx_http_clear_last_modified(r); + ngx_http_clear_etag(r); rc = ngx_http_send_header(r); From mdounin at mdounin.ru Sat Jul 7 21:24:02 2012 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Sat, 7 Jul 2012 21:24:02 +0000 Subject: [nginx] svn commit: r4748 - trunk/src/http/modules Message-ID: <20120707212402.72A5C3F9F46@mail.nginx.com> Author: mdounin Date: 2012-07-07 21:24:01 +0000 (Sat, 07 Jul 2012) New Revision: 4748 URL: http://trac.nginx.org/nginx/changeset/4748/nginx Log: Entity tags: handling in add_header. Notably this allows to clear ETag if one want to for some reason. Modified: trunk/src/http/modules/ngx_http_headers_filter_module.c Modified: trunk/src/http/modules/ngx_http_headers_filter_module.c =================================================================== --- trunk/src/http/modules/ngx_http_headers_filter_module.c 2012-07-07 21:22:27 UTC (rev 4747) +++ trunk/src/http/modules/ngx_http_headers_filter_module.c 2012-07-07 21:24:01 UTC (rev 4748) @@ -57,6 +57,8 @@ ngx_http_header_val_t *hv, ngx_str_t *value); static ngx_int_t ngx_http_set_last_modified(ngx_http_request_t *r, ngx_http_header_val_t *hv, ngx_str_t *value); +static ngx_int_t ngx_http_set_response_header(ngx_http_request_t *r, + ngx_http_header_val_t *hv, ngx_str_t *value); static void *ngx_http_headers_create_conf(ngx_conf_t *cf); static char *ngx_http_headers_merge_conf(ngx_conf_t *cf, @@ -74,6 +76,10 @@ { ngx_string("Last-Modified"), 0, ngx_http_set_last_modified }, + { ngx_string("ETag"), + offsetof(ngx_http_headers_out_t, etag), + ngx_http_set_response_header }, + { ngx_null_string, 0, NULL } }; @@ -392,6 +398,38 @@ } +static ngx_int_t +ngx_http_set_response_header(ngx_http_request_t *r, ngx_http_header_val_t *hv, + ngx_str_t *value) +{ + ngx_table_elt_t *h, **old; + + old = (ngx_table_elt_t **) ((char *) &r->headers_out + hv->offset); + + if (*old) { + (*old)->hash = 0; + *old = NULL; + } + + if (value->len == 0) { + return NGX_OK; + } + + h = ngx_list_push(&r->headers_out.headers); + if (h == NULL) { + return NGX_ERROR; + } + + *old = h; + + h->hash = 1; + h->key = hv->key; + h->value = *value; + + return NGX_OK; +} + + static void * ngx_http_headers_create_conf(ngx_conf_t *cf) { From mikegagnon at gmail.com Sat Jul 7 23:41:49 2012 From: mikegagnon at gmail.com (Mike Gagnon) Date: Sat, 7 Jul 2012 16:41:49 -0700 Subject: Get $request_body before content handlers? Message-ID: Hello, I have the impression that $request_body isn't available until the content-handlers phase. Is that correct? Is it possible to hack nginx such that the rewrite phase is delayed until after the request_body is available? I am writing a module that analyzes requests during the rewrite phase to determine where to route them. The goal is to use online machine learning to detect suspicious requests and re-route them to a quarantine. http://mikegagnon.com/2012/06/08/beer-garden/ If I have access to the request_body during the rewrite phase then my request classifier will be better at detecting suspicious requests (since it has more information about requests). Thanks! Mike Gagnon -------------- next part -------------- An HTML attachment was scrubbed... URL: From agentzh at gmail.com Sun Jul 8 03:19:47 2012 From: agentzh at gmail.com (agentzh) Date: Sat, 7 Jul 2012 20:19:47 -0700 Subject: Get $request_body before content handlers? In-Reply-To: References: Message-ID: Hello! On Sat, Jul 7, 2012 at 4:41 PM, Mike Gagnon wrote: > I have the impression that $request_body isn't available until the > content-handlers phase. Is that correct? > It depends on actual nginx modules. It's the nginx module's responsibility to trigger request body reading (or discarding). For ngx_proxy, ngx_fastcgi, and many other upstream modules, they run in the content phase, so request body is read in that phase. But in modules like ngx_form_input, it reads the request body at rewrite phase, see https://github.com/calio/form-input-nginx-module And in ngx_lua, we can read request body at various phases at our own will, like "rewrite", "access", and "content" phases. > Is it possible to hack nginx such that the rewrite phase is delayed until > after the request_body is available? I am writing a module that analyzes > requests during the rewrite phase to determine where to route them. The goal > is to use online machine learning to detect suspicious requests and re-route > them to a quarantine. http://mikegagnon.com/2012/06/08/beer-garden/ > We're just using ngx_lua to do suspicious request filtering in rewrite and/or access phases. It's convenient (and also rather efficient) to use the various Lua APIs for Nginx provided by ngx_lua. See http://wiki.nginx.org/HttpLuaModule It even supports streaming reading of request body via the "downstream cosocket" API, so you can implement "input body filter" in pure Lua. > If I have access to the request_body during the rewrite phase then my > request classifier will be better at detecting suspicious requests (since it > has more information about requests). > It's more appropriate to do that at the access phase, preferably running after the nginx "access" phase. (You can just ngx_lua's access_by_lua or access_by_lua_file directives.) Best regards, -agentzh From mikegagnon at gmail.com Sun Jul 8 21:38:41 2012 From: mikegagnon at gmail.com (Mike Gagnon) Date: Sun, 8 Jul 2012 14:38:41 -0700 Subject: Get $request_body before content handlers? In-Reply-To: References: Message-ID: Thanks! On Sat, Jul 7, 2012 at 8:19 PM, agentzh wrote: > Hello! > > On Sat, Jul 7, 2012 at 4:41 PM, Mike Gagnon wrote: > > I have the impression that $request_body isn't available until the > > content-handlers phase. Is that correct? > > > > It depends on actual nginx modules. It's the nginx module's > responsibility to trigger request body reading (or discarding). For > ngx_proxy, ngx_fastcgi, and many other upstream modules, they run in > the content phase, so request body is read in that phase. > > But in modules like ngx_form_input, it reads the request body at > rewrite phase, see > > https://github.com/calio/form-input-nginx-module > > Thanks for the pointer! I just looked at the source for form-input-nginx-module. It gives me the impression that the function ngx_http_read_client_request_body() isn't guaranteed to read the complete request_body before it is time to find the value for a set_form_input variable. In other words. it seems possible that the directive "set_form_input $data" might not work if the request_body isn't fully read before ngx_http_set_form_input() is called. I gathered this impression because it looks like ctx->done is only set after request_body is fully read. However, the function ngx_http_set_form_input() only advances to the function ngx_http_form_input_arg() if ctx->done is set. Do you know of my analysis correct? I would like to ensure that the request_body is fully read before my module attempts to read it during the rewrite phase. And in ngx_lua, we can read request body at various phases at our own > will, like "rewrite", "access", and "content" phases. > > > Is it possible to hack nginx such that the rewrite phase is delayed until > > after the request_body is available? I am writing a module that analyzes > > requests during the rewrite phase to determine where to route them. The > goal > > is to use online machine learning to detect suspicious requests and > re-route > > them to a quarantine. http://mikegagnon.com/2012/06/08/beer-garden/ > > > > We're just using ngx_lua to do suspicious request filtering in rewrite > and/or access phases. It's convenient (and also rather efficient) to > use the various Lua APIs for Nginx provided by ngx_lua. See > > http://wiki.nginx.org/HttpLuaModule > > It even supports streaming reading of request body via the "downstream > cosocket" API, so you can implement "input body filter" in pure Lua. > > Thanks for the Lua tips. Lua has a reputation for speed, but I am worried it won't be as performant as a well engineered C module. Normally, I wouldn't be concerned with minor speed improvements but I am specifically trying building my module to withstand CPU overload attacks. Within my context, it is critical that my module be able to classify incoming requests quickly. Do you think I am under-estimating Lua's performance capability? > > If I have access to the request_body during the rewrite phase then my > > request classifier will be better at detecting suspicious requests > (since it > > has more information about requests). > > > > It's more appropriate to do that at the access phase, preferably > running after the nginx "access" phase. (You can just ngx_lua's > access_by_lua or access_by_lua_file directives.) > > Thanks for the tip! > Best regards, > -agentzh > > _______________________________________________ > nginx-devel mailing list > nginx-devel at nginx.org > http://mailman.nginx.org/mailman/listinfo/nginx-devel > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mikegagnon at gmail.com Sun Jul 8 23:28:09 2012 From: mikegagnon at gmail.com (Mike Gagnon) Date: Sun, 8 Jul 2012 16:28:09 -0700 Subject: Get $request_body before content handlers? In-Reply-To: References: Message-ID: On Sat, Jul 7, 2012 at 8:19 PM, agentzh wrote: > > Is it possible to hack nginx such that the rewrite phase is delayed until > > after the request_body is available? I am writing a module that analyzes > > requests during the rewrite phase to determine where to route them. The > goal > > is to use online machine learning to detect suspicious requests and > re-route > > them to a quarantine. http://mikegagnon.com/2012/06/08/beer-garden/ > > > > We're just using ngx_lua to do suspicious request filtering in rewrite > and/or access phases. It's convenient (and also rather efficient) to > use the various Lua APIs for Nginx provided by ngx_lua. See > > http://wiki.nginx.org/HttpLuaModule > > Oh, yeah I ment to ask, but forgot. I'm curious to learn more about your code to filter suspicious requests. I looked at http://wiki.nginx.org/HttpLuaModule but did not see anything specifically regarding filting suspicious requests. Thanks again! Mike Gagnon -------------- next part -------------- An HTML attachment was scrubbed... URL: From mdounin at mdounin.ru Mon Jul 9 00:13:07 2012 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Mon, 9 Jul 2012 00:13:07 +0000 Subject: [nginx] svn commit: r4749 - in trunk/src/http: . modules Message-ID: <20120709001307.ECF003FA125@mail.nginx.com> Author: mdounin Date: 2012-07-09 00:13:06 +0000 (Mon, 09 Jul 2012) New Revision: 4749 URL: http://trac.nginx.org/nginx/changeset/4749/nginx Log: Entity tags: set for static respones. Modified: trunk/src/http/modules/ngx_http_flv_module.c trunk/src/http/modules/ngx_http_gzip_static_module.c trunk/src/http/modules/ngx_http_mp4_module.c trunk/src/http/modules/ngx_http_static_module.c trunk/src/http/ngx_http_core_module.c trunk/src/http/ngx_http_core_module.h Modified: trunk/src/http/modules/ngx_http_flv_module.c =================================================================== --- trunk/src/http/modules/ngx_http_flv_module.c 2012-07-07 21:24:01 UTC (rev 4748) +++ trunk/src/http/modules/ngx_http_flv_module.c 2012-07-09 00:13:06 UTC (rev 4749) @@ -194,6 +194,10 @@ r->headers_out.content_length_n = len; r->headers_out.last_modified_time = of.mtime; + if (ngx_http_set_etag(r) != NGX_OK) { + return NGX_HTTP_INTERNAL_SERVER_ERROR; + } + if (ngx_http_set_content_type(r) != NGX_OK) { return NGX_HTTP_INTERNAL_SERVER_ERROR; } Modified: trunk/src/http/modules/ngx_http_gzip_static_module.c =================================================================== --- trunk/src/http/modules/ngx_http_gzip_static_module.c 2012-07-07 21:24:01 UTC (rev 4748) +++ trunk/src/http/modules/ngx_http_gzip_static_module.c 2012-07-09 00:13:06 UTC (rev 4749) @@ -207,6 +207,10 @@ r->headers_out.content_length_n = of.size; r->headers_out.last_modified_time = of.mtime; + if (ngx_http_set_etag(r) != NGX_OK) { + return NGX_HTTP_INTERNAL_SERVER_ERROR; + } + if (ngx_http_set_content_type(r) != NGX_OK) { return NGX_HTTP_INTERNAL_SERVER_ERROR; } Modified: trunk/src/http/modules/ngx_http_mp4_module.c =================================================================== --- trunk/src/http/modules/ngx_http_mp4_module.c 2012-07-07 21:24:01 UTC (rev 4748) +++ trunk/src/http/modules/ngx_http_mp4_module.c 2012-07-09 00:13:06 UTC (rev 4749) @@ -586,6 +586,10 @@ r->headers_out.status = NGX_HTTP_OK; r->headers_out.last_modified_time = of.mtime; + if (ngx_http_set_etag(r) != NGX_OK) { + return NGX_HTTP_INTERNAL_SERVER_ERROR; + } + if (ngx_http_set_content_type(r) != NGX_OK) { return NGX_HTTP_INTERNAL_SERVER_ERROR; } Modified: trunk/src/http/modules/ngx_http_static_module.c =================================================================== --- trunk/src/http/modules/ngx_http_static_module.c 2012-07-07 21:24:01 UTC (rev 4748) +++ trunk/src/http/modules/ngx_http_static_module.c 2012-07-09 00:13:06 UTC (rev 4749) @@ -220,6 +220,10 @@ r->headers_out.content_length_n = of.size; r->headers_out.last_modified_time = of.mtime; + if (ngx_http_set_etag(r) != NGX_OK) { + return NGX_HTTP_INTERNAL_SERVER_ERROR; + } + if (ngx_http_set_content_type(r) != NGX_OK) { return NGX_HTTP_INTERNAL_SERVER_ERROR; } Modified: trunk/src/http/ngx_http_core_module.c =================================================================== --- trunk/src/http/ngx_http_core_module.c 2012-07-07 21:24:01 UTC (rev 4748) +++ trunk/src/http/ngx_http_core_module.c 2012-07-09 00:13:06 UTC (rev 4749) @@ -1809,6 +1809,35 @@ ngx_int_t +ngx_http_set_etag(ngx_http_request_t *r) +{ + ngx_table_elt_t *etag; + + etag = ngx_list_push(&r->headers_out.headers); + if (etag == NULL) { + return NGX_ERROR; + } + + etag->hash = 1; + ngx_str_set(&etag->key, "ETag"); + + etag->value.data = ngx_pnalloc(r->pool, NGX_OFF_T_LEN + NGX_TIME_T_LEN + 3); + if (etag->value.data == NULL) { + return NGX_ERROR; + } + + etag->value.len = ngx_sprintf(etag->value.data, "\"%xT-%xO\"", + r->headers_out.last_modified_time, + r->headers_out.content_length_n) + - etag->value.data; + + r->headers_out.etag = etag; + + return NGX_OK; +} + + +ngx_int_t ngx_http_send_response(ngx_http_request_t *r, ngx_uint_t status, ngx_str_t *ct, ngx_http_complex_value_t *cv) { Modified: trunk/src/http/ngx_http_core_module.h =================================================================== --- trunk/src/http/ngx_http_core_module.h 2012-07-07 21:24:01 UTC (rev 4748) +++ trunk/src/http/ngx_http_core_module.h 2012-07-09 00:13:06 UTC (rev 4749) @@ -480,6 +480,7 @@ void *ngx_http_test_content_type(ngx_http_request_t *r, ngx_hash_t *types_hash); ngx_int_t ngx_http_set_content_type(ngx_http_request_t *r); void ngx_http_set_exten(ngx_http_request_t *r); +ngx_int_t ngx_http_set_etag(ngx_http_request_t *r); ngx_int_t ngx_http_send_response(ngx_http_request_t *r, ngx_uint_t status, ngx_str_t *ct, ngx_http_complex_value_t *cv); u_char *ngx_http_map_uri_to_path(ngx_http_request_t *r, ngx_str_t *name, From mikegagnon at gmail.com Mon Jul 9 00:19:40 2012 From: mikegagnon at gmail.com (Mike Gagnon) Date: Sun, 8 Jul 2012 17:19:40 -0700 Subject: Get $request_body before content handlers? In-Reply-To: References: Message-ID: I think I found it now: location / { lua_need_request_body on; client_max_body_size 100k; client_body_buffer_size 100k; access_by_lua ' -- check the client IP address is in our black list if ngx.var.remote_addr == "132.5.72.3" then ngx.exit(ngx.HTTP_FORBIDDEN) end -- check if the request body contains bad words if ngx.var.request_body and string.match(ngx.var.request_body, "fsck") then return ngx.redirect("/terms_of_use.html") end -- tests passed '; On Sun, Jul 8, 2012 at 4:28 PM, Mike Gagnon wrote: > On Sat, Jul 7, 2012 at 8:19 PM, agentzh wrote: > >> > Is it possible to hack nginx such that the rewrite phase is delayed >> until >> > after the request_body is available? I am writing a module that analyzes >> > requests during the rewrite phase to determine where to route them. The >> goal >> > is to use online machine learning to detect suspicious requests and >> re-route >> > them to a quarantine. http://mikegagnon.com/2012/06/08/beer-garden/ >> > >> >> We're just using ngx_lua to do suspicious request filtering in rewrite >> and/or access phases. It's convenient (and also rather efficient) to >> use the various Lua APIs for Nginx provided by ngx_lua. See >> >> http://wiki.nginx.org/HttpLuaModule >> >> > Oh, yeah I ment to ask, but forgot. I'm curious to learn more about your > code to filter suspicious requests. I looked at > http://wiki.nginx.org/HttpLuaModule but did not see anything specifically > regarding filting suspicious requests. > > Thanks again! > > Mike Gagnon > -------------- next part -------------- An HTML attachment was scrubbed... URL: From agentzh at gmail.com Mon Jul 9 04:51:09 2012 From: agentzh at gmail.com (agentzh) Date: Sun, 8 Jul 2012 21:51:09 -0700 Subject: Get $request_body before content handlers? In-Reply-To: References: Message-ID: Hello! On Sun, Jul 8, 2012 at 2:38 PM, Mike Gagnon wrote: > > Thanks for the pointer! I just looked at the source for > form-input-nginx-module. > > It gives me the impression that the function > ngx_http_read_client_request_body() isn't guaranteed to read the complete > request_body before it is time to find the value for a set_form_input > variable. In other words. it seems possible that the directive > "set_form_input $data" might not work if the request_body isn't fully read > before ngx_http_set_form_input() is called. > No, you're wrong here. The request body is read in ngx_form_input's own rewrite phase handler, which is always run before the standard ngx_rewrite module's handler. The ngx_http_set_form_input() function is run in the ngx_rewrite's handler, by injecting callbacks into ngx_rewrite's location configuration by means the ngx_devel_kit's set_var submodule. That's the magic going on here. The 3rd-party module ngx_eval also relies on the relative running order with the standard ngx_rewrite module on the same "rewrite" phase. > I gathered this impression because it looks like ctx->done is only set after > request_body is fully read. However, the function ngx_http_set_form_input() > only advances to the function ngx_http_form_input_arg() if ctx->done is set. > The running order is already guaranteed here so this is totally fine :) > I would like to ensure that the request_body is fully read before my module > attempts to read it during the rewrite phase. > This is surely guaranteed or things can break very easily in production environments ;) > Thanks for the Lua tips. Lua has a reputation for speed, but I am worried it > won't be as performant as a well engineered C module. Normally, I wouldn't > be concerned with minor speed improvements but I am specifically trying > building my module to withstand CPU overload attacks. Within my context, it > is critical that my module be able to classify incoming requests quickly. > Most of the heavy lifting is already done in pure C in ngx_lua. Lua is just the glue so the performance is totally fine especially when you're using LuaJIT 2.0 with ngx_lua. > Do you think I am under-estimating Lua's performance capability? > You can try it out on your side ;) Best regards, -agentzh From agentzh at gmail.com Mon Jul 9 04:59:56 2012 From: agentzh at gmail.com (agentzh) Date: Sun, 8 Jul 2012 21:59:56 -0700 Subject: Get $request_body before content handlers? In-Reply-To: References: Message-ID: Hello! On Sun, Jul 8, 2012 at 5:19 PM, Mike Gagnon wrote: > location / { > lua_need_request_body on; > > client_max_body_size 100k; > client_body_buffer_size 100k; > > access_by_lua ' > -- check the client IP address is in our black list > if ngx.var.remote_addr == "132.5.72.3" then > ngx.exit(ngx.HTTP_FORBIDDEN) > end > > -- check if the request body contains bad words > if ngx.var.request_body and > string.match(ngx.var.request_body, "fsck") > then > return ngx.redirect("/terms_of_use.html") > end > > -- tests passed > '; > Just a few comments on your code snippet: 1. It's not recommended to turn lua_need_request_body on yourself. Call ngx.req.read_body() or ngx.req.socket() (or even ngx.req.discard_body()) explicitly :) 2. If client_max_body_size is greater than client_body_buffer_size (which is not in your case), always check if ngx.req.get_body_data() returns nil and try ngx.req.get_body_file() instead in that case. Nginx could buffer your request body into temporary files when the body is too large to be hold in the request body buffer. 3. You may consider streaming processing on the request body using the ngx.req.socket() API with the ngx.req.init_body(), ngx.req.append_body(), and ngx.req.finish_body() on the "req-body" git branch in the ngx_lua repository. With this, you can immediately start checking stuffs while you're reading the request body, chunk by chunk, without waiting for the whole request body to be buffered first. Best regards, -agentzh From atribble at amazon.com Mon Jul 9 09:03:57 2012 From: atribble at amazon.com (Tribble, Alex) Date: Mon, 9 Jul 2012 02:03:57 -0700 Subject: [PATCH] Fix for ticket #106: Correctly handle multiple X-Forwarded-For headers In-Reply-To: Message-ID: How do other people feel about this patch? I would love to see it get into the upstream, since I'm currently maintaining a local branch for it. On 6/26/12 10:36 AM, "Tribble, Alex" wrote: >It looks good to me - thank you very much for doing this. > >Attached patch applies to the stable-1.2 branch. > >On 6/24/12 11:23 PM, "Ruslan Ermilov" wrote: > >>On Tue, Jun 19, 2012 at 06:47:56PM -0700, Tribble, Alex wrote: >>> When nginx gets multiple X-Forwarded-For headers in a single request, >>>it >>> only keeps the last one in r->headers_in (and thus in >>> $http_x_forwarded_for, $proxy_add_x_forwarded_for). Reverse proxies >>>behind >>> an nginx instance sometimes need the entire X-Forwarded-For chain - >>>part >>> of which is discarded in this case. >>> >>> Per RFC 2616, it's equivalent to concatenate each header value >>>(separated >>> by a comma) and send the concatenated value to the upstream: >>> 4.2 >>> -snip- >>> Multiple message-header fields with the same field-name MAY be >>> present in a message if and only if the entire field-value for that >>> header field is defined as a comma-separated list [i.e., #(values)]. >>> It MUST be possible to combine the multiple header fields into one >>> "field-name: field-value" pair, without changing the semantics of >>>the >>> message, by appending each subsequent field-value to the first, each >>> separated by a comma. The order in which header fields with the same >>> field-name are received is therefore significant to the >>> interpretation of the combined field value, and thus a proxy MUST >>>NOT >>> change the order of these field values when a message is forwarded. >>> -snip- >>> >>> Attached is a patch that does exactly this, in the case of multiple >>>headers. >>> Please let me know if you have any comments about this patch - I'm >>>happy >>> to make any changes you suggest. >>> >>> Relevant bug report: >>> http://trac.nginx.org/nginx/ticket/106 >> >>How's this patch instead? >> >> > From goelvivek2011 at gmail.com Mon Jul 9 09:10:17 2012 From: goelvivek2011 at gmail.com (vivek goel) Date: Mon, 9 Jul 2012 14:40:17 +0530 Subject: How to upgrade nginx binary on fly Message-ID: I am trying to upgrade nginx binary on fly. But when I am giving signal to upgrade the binary it is giving following error: 2012/07/09 14:34:39 [crit] 22688#0: the changing binary signal is ignored: you should shutdown or terminate before either old or new binary's process My core configuration look like this: user vivek; worker_processes 2; events { worker_connections 1024; } regards Vivek Goel -------------- next part -------------- An HTML attachment was scrubbed... URL: From goelvivek2011 at gmail.com Mon Jul 9 09:15:45 2012 From: goelvivek2011 at gmail.com (vivek goel) Date: Mon, 9 Jul 2012 14:45:45 +0530 Subject: How to upgrade nginx binary on fly In-Reply-To: References: Message-ID: ok found I need to fire following command after SIGUSR2 kill -WINCH $(cat nginx.pid.oldbin) kill -QUIT $(cat nginx.pid.oldbin) regards Vivek Goel On Mon, Jul 9, 2012 at 2:40 PM, vivek goel wrote: > I am trying to upgrade nginx binary on fly. > But when I am giving signal to upgrade the binary it is giving following > error: > > 2012/07/09 14:34:39 [crit] 22688#0: the changing binary signal is ignored: > you should shutdown or terminate before either old or new binary's process > > My core configuration look like this: > > user vivek; > worker_processes 2; > events { > worker_connections 1024; > } > > > > regards > Vivek Goel > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ru at nginx.com Mon Jul 9 10:18:10 2012 From: ru at nginx.com (Ruslan Ermilov) Date: Mon, 9 Jul 2012 14:18:10 +0400 Subject: How to upgrade nginx binary on fly In-Reply-To: References: Message-ID: <20120709101810.GA1050@lo0.su> On Mon, Jul 09, 2012 at 02:45:45PM +0530, vivek goel wrote: > ok found I need to fire following command after SIGUSR2 > kill -WINCH $(cat nginx.pid.oldbin) > kill -QUIT $(cat nginx.pid.oldbin) > > regards > Vivek Goel Just in case: http://nginx.org/en/docs/control.html#upgrade > On Mon, Jul 9, 2012 at 2:40 PM, vivek goel <[1]goelvivek2011 at gmail.com> > wrote: > > I am trying to upgrade nginx binary on fly. > But when I am giving signal to upgrade? the binary it is giving > following error: > > 2012/07/09 14:34:39 [crit] 22688#0: the changing binary signal is > ignored: you should shutdown or terminate before either old or new > binary's process > > My core configuration look like this: > > user? vivek; > worker_processes? 2; > events { > ??? worker_connections? 1024; > } > > regards > Vivek Goel From mdounin at mdounin.ru Mon Jul 9 14:53:42 2012 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Mon, 9 Jul 2012 14:53:42 +0000 Subject: [nginx] svn commit: r4750 - trunk/src/http Message-ID: <20120709145342.D81C83F9FAB@mail.nginx.com> Author: mdounin Date: 2012-07-09 14:53:42 +0000 (Mon, 09 Jul 2012) New Revision: 4750 URL: http://trac.nginx.org/nginx/changeset/4750/nginx Log: Entity tags: the "etag" directive. It allows to disable generation of nginx's own entity tags, while still handling ETags in cache properly. This may be useful e.g. if one want to serve static files from servers with different ETag generation algorithms. Modified: trunk/src/http/ngx_http_core_module.c trunk/src/http/ngx_http_core_module.h Modified: trunk/src/http/ngx_http_core_module.c =================================================================== --- trunk/src/http/ngx_http_core_module.c 2012-07-09 00:13:06 UTC (rev 4749) +++ trunk/src/http/ngx_http_core_module.c 2012-07-09 14:53:42 UTC (rev 4750) @@ -650,6 +650,13 @@ offsetof(ngx_http_core_loc_conf_t, chunked_transfer_encoding), NULL }, + { ngx_string("etag"), + NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, + ngx_conf_set_flag_slot, + NGX_HTTP_LOC_CONF_OFFSET, + offsetof(ngx_http_core_loc_conf_t, etag), + NULL }, + { ngx_string("error_page"), NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF |NGX_CONF_2MORE, @@ -1811,7 +1818,14 @@ ngx_int_t ngx_http_set_etag(ngx_http_request_t *r) { - ngx_table_elt_t *etag; + ngx_table_elt_t *etag; + ngx_http_core_loc_conf_t *clcf; + + clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); + + if (!clcf->etag) { + return NGX_OK; + } etag = ngx_list_push(&r->headers_out.headers); if (etag == NULL) { @@ -3539,6 +3553,7 @@ clcf->recursive_error_pages = NGX_CONF_UNSET; clcf->server_tokens = NGX_CONF_UNSET; clcf->chunked_transfer_encoding = NGX_CONF_UNSET; + clcf->etag = NGX_CONF_UNSET; clcf->types_hash_max_size = NGX_CONF_UNSET_UINT; clcf->types_hash_bucket_size = NGX_CONF_UNSET_UINT; @@ -3800,6 +3815,7 @@ ngx_conf_merge_value(conf->server_tokens, prev->server_tokens, 1); ngx_conf_merge_value(conf->chunked_transfer_encoding, prev->chunked_transfer_encoding, 1); + ngx_conf_merge_value(conf->etag, prev->etag, 1); ngx_conf_merge_ptr_value(conf->open_file_cache, prev->open_file_cache, NULL); Modified: trunk/src/http/ngx_http_core_module.h =================================================================== --- trunk/src/http/ngx_http_core_module.h 2012-07-09 00:13:06 UTC (rev 4749) +++ trunk/src/http/ngx_http_core_module.h 2012-07-09 14:53:42 UTC (rev 4750) @@ -392,6 +392,7 @@ ngx_flag_t recursive_error_pages; /* recursive_error_pages */ ngx_flag_t server_tokens; /* server_tokens */ ngx_flag_t chunked_transfer_encoding; /* chunked_transfer_encoding */ + ngx_flag_t etag; /* etag */ #if (NGX_HTTP_GZIP) ngx_flag_t gzip_vary; /* gzip_vary */ From mdounin at mdounin.ru Mon Jul 9 17:04:37 2012 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Mon, 9 Jul 2012 17:04:37 +0000 Subject: [nginx] svn commit: r4751 - trunk/src/http/modules Message-ID: <20120709170437.79CD23FA03C@mail.nginx.com> Author: mdounin Date: 2012-07-09 17:04:37 +0000 (Mon, 09 Jul 2012) New Revision: 4751 URL: http://trac.nginx.org/nginx/changeset/4751/nginx Log: Entity tags: empty etags handling in If-Range. Entity tag may be of length 2 as per RFC 2616, i.e. double quotes only. Pointed out by Ruslan Ermilov. Modified: trunk/src/http/modules/ngx_http_range_filter_module.c Modified: trunk/src/http/modules/ngx_http_range_filter_module.c =================================================================== --- trunk/src/http/modules/ngx_http_range_filter_module.c 2012-07-09 14:53:42 UTC (rev 4750) +++ trunk/src/http/modules/ngx_http_range_filter_module.c 2012-07-09 17:04:37 UTC (rev 4751) @@ -179,7 +179,7 @@ if_range = &r->headers_in.if_range->value; - if (if_range->len > 2 && if_range->data[if_range->len - 1] == '"') { + if (if_range->len >= 2 && if_range->data[if_range->len - 1] == '"') { if (r->headers_out.etag == NULL) { goto next_filter; From toli at webforge.bg Tue Jul 10 08:31:45 2012 From: toli at webforge.bg (Anatoli Marinov) Date: Tue, 10 Jul 2012 11:31:45 +0300 Subject: missing module context Message-ID: <4FFBE871.5020003@webforge.bg> Hello Colleagues, I am working on a project, that uses nginx as http proxy and I have written many nginx modules. For several months till now I am looking for a bug in one of my modules but I cannot find it. It appears very rare but even so it should be fixed. I added many log messages to debug the issue. I found that some time the module context is null even it has been set before. I am using context functions as usual: 1. In rewrite phase : ctx = ngx_pcalloc(r->pool, sizeof(ngx_http_my_ctx_t)); ngx_http_set_ctx(r, ctx, ngx_http_my_module); 2. In log phase I am trying to get back my context : ctx = ngx_http_get_module_ctx(r, ngx_http_my_module); In this place ctx is NULL. What is your opinion? Am am using this sequence on many places and it works as I expected but in this modules sometimes it fails. I think there could be a memory corruption issue. There could be a code that may write on request's context array and overwrite the context pointer. Is there a way to check this? Nginx uses its own memory pool system and tools like valgrind is not longer usable. Please advise me how to find this issue... All ideas are welcome! Best Regards Anatoli Marinov From ne at vbart.ru Tue Jul 10 10:17:11 2012 From: ne at vbart.ru (Valentin V. Bartenev) Date: Tue, 10 Jul 2012 14:17:11 +0400 Subject: missing module context In-Reply-To: <4FFBE871.5020003@webforge.bg> References: <4FFBE871.5020003@webforge.bg> Message-ID: <201207101417.11958.ne@vbart.ru> On Tuesday 10 July 2012 12:31:45 Anatoli Marinov wrote: > Hello Colleagues, > I am working on a project, that uses nginx as http proxy and I have > written many nginx modules. For several months till now I am looking for > a bug in one of my modules but I cannot find it. It appears very rare > but even so it should be fixed. > > I added many log messages to debug the issue. I found that some time the > module context is null even it has been set before. I am using context > functions as usual: > 1. In rewrite phase : > ctx = ngx_pcalloc(r->pool, sizeof(ngx_http_my_ctx_t)); > ngx_http_set_ctx(r, ctx, ngx_http_my_module); > > 2. In log phase I am trying to get back my context : > ctx = ngx_http_get_module_ctx(r, ngx_http_my_module); > In this place ctx is NULL. > > What is your opinion? Am am using this sequence on many places and it > works as I expected but in this modules sometimes it fails. > I think there could be a memory corruption issue. There could be a code > that may write on request's context array and overwrite the context > pointer. Is there a way to check this? Nginx uses its own memory pool > system and tools like valgrind is not longer usable. > > Please advise me how to find this issue... > > All ideas are welcome! > Best Regards > The request context doesn't shared between subrequests. If you set ctx for subrequest and then trying to retrieve it for main request you will get NULL. wbr, Valentin V. Bartenev From ne at vbart.ru Tue Jul 10 10:24:54 2012 From: ne at vbart.ru (Valentin V. Bartenev) Date: Tue, 10 Jul 2012 14:24:54 +0400 Subject: missing module context In-Reply-To: <201207101417.11958.ne@vbart.ru> References: <4FFBE871.5020003@webforge.bg> <201207101417.11958.ne@vbart.ru> Message-ID: <201207101424.54857.ne@vbart.ru> On Tuesday 10 July 2012 14:17:11 Valentin V. Bartenev wrote: > On Tuesday 10 July 2012 12:31:45 Anatoli Marinov wrote: > > Hello Colleagues, > > I am working on a project, that uses nginx as http proxy and I have > > written many nginx modules. For several months till now I am looking for > > a bug in one of my modules but I cannot find it. It appears very rare > > but even so it should be fixed. > > > > I added many log messages to debug the issue. I found that some time the > > module context is null even it has been set before. I am using context > > functions as usual: > > 1. In rewrite phase : > > ctx = ngx_pcalloc(r->pool, sizeof(ngx_http_my_ctx_t)); > > ngx_http_set_ctx(r, ctx, ngx_http_my_module); > > > > 2. In log phase I am trying to get back my context : > > ctx = ngx_http_get_module_ctx(r, ngx_http_my_module); > > In this place ctx is NULL. > > > > What is your opinion? Am am using this sequence on many places and it > > works as I expected but in this modules sometimes it fails. > > I think there could be a memory corruption issue. There could be a code > > that may write on request's context array and overwrite the context > > pointer. Is there a way to check this? Nginx uses its own memory pool > > system and tools like valgrind is not longer usable. > > > > Please advise me how to find this issue... > > > > All ideas are welcome! > > Best Regards > > The request context doesn't shared between subrequests. If you set ctx for > subrequest and then trying to retrieve it for main request you will get > NULL. > Btw, it also cleared by the internal redirect. wbr, Valentin V. Bartenev From toli at webforge.bg Tue Jul 10 11:53:34 2012 From: toli at webforge.bg (Anatoli Marinov) Date: Tue, 10 Jul 2012 14:53:34 +0300 Subject: missing module context In-Reply-To: <201207101424.54857.ne@vbart.ru> References: <4FFBE871.5020003@webforge.bg> <201207101417.11958.ne@vbart.ru> <201207101424.54857.ne@vbart.ru> Message-ID: <4FFC17BE.5070801@webforge.bg> I think I have only 1 request without any sub requests and also do not use internal redirects. On 07/10/2012 01:24 PM, Valentin V. Bartenev wrote: > On Tuesday 10 July 2012 14:17:11 Valentin V. Bartenev wrote: > >> On Tuesday 10 July 2012 12:31:45 Anatoli Marinov wrote: >> >>> Hello Colleagues, >>> I am working on a project, that uses nginx as http proxy and I have >>> written many nginx modules. For several months till now I am looking for >>> a bug in one of my modules but I cannot find it. It appears very rare >>> but even so it should be fixed. >>> >>> I added many log messages to debug the issue. I found that some time the >>> module context is null even it has been set before. I am using context >>> functions as usual: >>> 1. In rewrite phase : >>> ctx = ngx_pcalloc(r->pool, sizeof(ngx_http_my_ctx_t)); >>> ngx_http_set_ctx(r, ctx, ngx_http_my_module); >>> >>> 2. In log phase I am trying to get back my context : >>> ctx = ngx_http_get_module_ctx(r, ngx_http_my_module); >>> In this place ctx is NULL. >>> >>> What is your opinion? Am am using this sequence on many places and it >>> works as I expected but in this modules sometimes it fails. >>> I think there could be a memory corruption issue. There could be a code >>> that may write on request's context array and overwrite the context >>> pointer. Is there a way to check this? Nginx uses its own memory pool >>> system and tools like valgrind is not longer usable. >>> >>> Please advise me how to find this issue... >>> >>> All ideas are welcome! >>> Best Regards >>> >> The request context doesn't shared between subrequests. If you set ctx for >> subrequest and then trying to retrieve it for main request you will get >> NULL. >> >> > Btw, it also cleared by the internal redirect. > > wbr, Valentin V. Bartenev > > _______________________________________________ > nginx-devel mailing list > nginx-devel at nginx.org > http://mailman.nginx.org/mailman/listinfo/nginx-devel > From mdounin at mdounin.ru Tue Jul 10 12:20:10 2012 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Tue, 10 Jul 2012 12:20:10 +0000 Subject: [nginx] svn commit: r4752 - trunk/docs/xml/nginx Message-ID: <20120710122010.A57833F9FAB@mail.nginx.com> Author: mdounin Date: 2012-07-10 12:20:10 +0000 (Tue, 10 Jul 2012) New Revision: 4752 URL: http://trac.nginx.org/nginx/changeset/4752/nginx Log: nginx-1.3.3-RELEASE Modified: trunk/docs/xml/nginx/changes.xml Modified: trunk/docs/xml/nginx/changes.xml =================================================================== --- trunk/docs/xml/nginx/changes.xml 2012-07-09 17:04:37 UTC (rev 4751) +++ trunk/docs/xml/nginx/changes.xml 2012-07-10 12:20:10 UTC (rev 4752) @@ -9,6 +9,44 @@ nginx changelog + + + + +????????? entity tags ? ????????? etag. + + +entity tags support and the "etag" directive. + + + + + +??? ????????????? ????????? map ? ?????????? hostnames +?? ?????????????? ???????? ????? ? ???????? ????????. + + +trailing dot in a source value was not ignored +if the "map" directive was used with the "hostnames" parameter. + + + + + +??? ????????? ??????? ??? ?????????????? ???????? location, +???? ??????? ? ??????????? location ?????????? +????? ????????? URI ? ??????? ????????? rewrite. + + +incorrect location might be used to process a request +if a URI was changed via a "rewrite" directive +before an internal redirect to a named location. + + + + + + From mdounin at mdounin.ru Tue Jul 10 12:20:31 2012 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Tue, 10 Jul 2012 12:20:31 +0000 Subject: [nginx] svn commit: r4753 - tags Message-ID: <20120710122031.34ABE3F9FAB@mail.nginx.com> Author: mdounin Date: 2012-07-10 12:20:30 +0000 (Tue, 10 Jul 2012) New Revision: 4753 URL: http://trac.nginx.org/nginx/changeset/4753/nginx Log: release-1.3.3 tag Added: tags/release-1.3.3/ From ru at nginx.com Tue Jul 10 12:40:36 2012 From: ru at nginx.com (ru at nginx.com) Date: Tue, 10 Jul 2012 12:40:36 +0000 Subject: [nginx] svn commit: r4754 - trunk/docs/text Message-ID: <20120710124036.5280C3FA017@mail.nginx.com> Author: ru Date: 2012-07-10 12:40:35 +0000 (Tue, 10 Jul 2012) New Revision: 4754 URL: http://trac.nginx.org/nginx/changeset/4754/nginx Log: Synchronized the license text with the FreeBSD's bsd-style-copyright. Modified: trunk/docs/text/LICENSE Modified: trunk/docs/text/LICENSE =================================================================== --- trunk/docs/text/LICENSE 2012-07-10 12:20:30 UTC (rev 4753) +++ trunk/docs/text/LICENSE 2012-07-10 12:40:35 UTC (rev 4754) @@ -1,6 +1,7 @@ /* * Copyright (C) 2002-2012 Igor Sysoev * Copyright (C) 2011,2012 Nginx, Inc. + * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -11,10 +12,10 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) From ne at vbart.ru Wed Jul 11 16:08:40 2012 From: ne at vbart.ru (Valentin V. Bartenev) Date: Wed, 11 Jul 2012 20:08:40 +0400 Subject: missing module context In-Reply-To: <4FFC17BE.5070801@webforge.bg> References: <4FFBE871.5020003@webforge.bg> <201207101424.54857.ne@vbart.ru> <4FFC17BE.5070801@webforge.bg> Message-ID: <201207112008.40830.ne@vbart.ru> On Tuesday 10 July 2012 15:53:34 Anatoli Marinov wrote: > I think I have only 1 request without any sub requests and also do not > use internal redirects. > Also the ctx of your module will be NULL if the rewrite phase doesn't happen. wbr, Valentin V. Bartenev From aaron.bedra at gmail.com Wed Jul 11 20:06:33 2012 From: aaron.bedra at gmail.com (Aaron Bedra) Date: Wed, 11 Jul 2012 15:06:33 -0500 Subject: Module development question regarding ngx_http_get_module_loc_conf Message-ID: Hello, I have been banging my head against the wall trying to figure this out. The full code to my module is at https://gist.github.com/3087852. It is obviously still a work in progress, but I'm stuck. I'm trying to add an argument to my directive. I have read the guides and looked at other modules and everyone seems to say to do the same thing. Basically, when I call rlcf = ngx_http_get_module_loc_conf(r, ngx_http_repsheet_module); the values set in ngx_http_repsheet aren't there anymore. I have confirmed that they are getting set in via gdb. I'm guessing that I am forgetting to do something or have overlooked something stupid here, but I just can't seem to find it. Any help is greatly appreciated. Cheers, Aaron -------------- next part -------------- An HTML attachment was scrubbed... URL: From ne at vbart.ru Wed Jul 11 20:41:19 2012 From: ne at vbart.ru (Valentin V. Bartenev) Date: Thu, 12 Jul 2012 00:41:19 +0400 Subject: Module development question regarding ngx_http_get_module_loc_conf In-Reply-To: References: Message-ID: <201207120041.19759.ne@vbart.ru> On Thursday 12 July 2012 00:06:33 Aaron Bedra wrote: > Hello, > > I have been banging my head against the wall trying to figure this out. The > full code to my module is at https://gist.github.com/3087852. It is > obviously still a work in progress, but I'm stuck. I'm trying to add an > argument to my directive. I have read the guides and looked at other > modules and everyone seems to say to do the same thing. > > Basically, when I call > > rlcf = ngx_http_get_module_loc_conf(r, ngx_http_repsheet_module); > > the values set in ngx_http_repsheet aren't there anymore. I have confirmed > that they are getting set in via gdb. I'm guessing that I am forgetting to > do something or have overlooked something stupid here, but I just can't > seem to find it. Any help is greatly appreciated. > You set your handler on NGX_HTTP_POST_READ_PHASE, that goes before NGX_HTTP_FIND_CONFIG_PHASE. wbr, Valentin V. Bartenev From aaron.bedra at gmail.com Wed Jul 11 21:00:11 2012 From: aaron.bedra at gmail.com (Aaron Bedra) Date: Wed, 11 Jul 2012 16:00:11 -0500 Subject: Module development question regarding ngx_http_get_module_loc_conf In-Reply-To: <201207120041.19759.ne@vbart.ru> References: <201207120041.19759.ne@vbart.ru> Message-ID: Oh wow, I didn't realize that. I just tried another phase (NGX_HTTP_PREACCESS_PHASE) and the configuration showed up as expected. Thanks so much for pointing this out! The only other question is what phase to put this in. When I use preaccess the header shows up twice. Cheers, Aaron On Wed, Jul 11, 2012 at 3:41 PM, Valentin V. Bartenev wrote: > On Thursday 12 July 2012 00:06:33 Aaron Bedra wrote: > > Hello, > > > > I have been banging my head against the wall trying to figure this out. > The > > full code to my module is at https://gist.github.com/3087852. It is > > obviously still a work in progress, but I'm stuck. I'm trying to add an > > argument to my directive. I have read the guides and looked at other > > modules and everyone seems to say to do the same thing. > > > > Basically, when I call > > > > rlcf = ngx_http_get_module_loc_conf(r, ngx_http_repsheet_module); > > > > the values set in ngx_http_repsheet aren't there anymore. I have > confirmed > > that they are getting set in via gdb. I'm guessing that I am forgetting > to > > do something or have overlooked something stupid here, but I just can't > > seem to find it. Any help is greatly appreciated. > > > > You set your handler on NGX_HTTP_POST_READ_PHASE, that goes > before NGX_HTTP_FIND_CONFIG_PHASE. > > wbr, Valentin V. Bartenev > > _______________________________________________ > nginx-devel mailing list > nginx-devel at nginx.org > http://mailman.nginx.org/mailman/listinfo/nginx-devel > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ne at vbart.ru Wed Jul 11 21:45:46 2012 From: ne at vbart.ru (Valentin V. Bartenev) Date: Thu, 12 Jul 2012 01:45:46 +0400 Subject: Module development question regarding ngx_http_get_module_loc_conf In-Reply-To: References: <201207120041.19759.ne@vbart.ru> Message-ID: <201207120145.46210.ne@vbart.ru> On Thursday 12 July 2012 01:00:11 Aaron Bedra wrote: > Oh wow, I didn't realize that. I just tried another phase > (NGX_HTTP_PREACCESS_PHASE) and the configuration showed up as expected. > Thanks so much for pointing this out! The only other question is what phase > to put this in. When I use preaccess the header shows up twice. It is because your module does not properly handle internal redirects (and subrequests btw). As an example, see the first lines of ngx_http_limit_req_handler() or ngx_http_limit_conn_handler(). Btw, if the purpose of your module is to add header, then it's better to develop a header filter. Also note, that is_abuser() blocks nginx process. wbr, Valentin V. Bartenev From aaron.bedra at gmail.com Wed Jul 11 22:18:52 2012 From: aaron.bedra at gmail.com (Aaron Bedra) Date: Wed, 11 Jul 2012 17:18:52 -0500 Subject: Module development question regarding ngx_http_get_module_loc_conf In-Reply-To: <201207120145.46210.ne@vbart.ru> References: <201207120041.19759.ne@vbart.ru> <201207120145.46210.ne@vbart.ru> Message-ID: <05CCA20C-AE5E-44F8-A33A-3ADCE131DF12@gmail.com> On Jul 11, 2012, at 4:45 PM, Valentin V. Bartenev wrote: > On Thursday 12 July 2012 01:00:11 Aaron Bedra wrote: >> Oh wow, I didn't realize that. I just tried another phase >> (NGX_HTTP_PREACCESS_PHASE) and the configuration showed up as expected. >> Thanks so much for pointing this out! The only other question is what phase >> to put this in. When I use preaccess the header shows up twice. > > It is because your module does not properly handle internal redirects (and > subrequests btw). > > As an example, see the first lines of ngx_http_limit_req_handler() or > ngx_http_limit_conn_handler(). Thanks! > Btw, if the purpose of your module is to add header, then it's better to develop > a header filter. I was unsure of that when I was reading things. I'll investigate this option as well. > Also note, that is_abuser() blocks nginx process. Yeah, I figured. I need to find a better way to do that. That's my plan after the module is working properly otherwise. Thanks again for your help! Cheers, Aaron From pgnet.dev+nginx at gmail.com Thu Jul 12 18:42:19 2012 From: pgnet.dev+nginx at gmail.com (pgndev) Date: Thu, 12 Jul 2012 11:42:19 -0700 Subject: "SSL compression" config & usage when SPDY's in use? Message-ID: I'm running nginx 1.3.3 + spdy/47 SPDY's enabled and functioning. At least it's seen in headers, detected by browsers, etc. In Chromium, SSL site-cert popup reports "The connection does not use SSL compression." Reading SSL, Compression, and You http://www.belshe.com/2010/11/18/ssl-compression-and-you/ Nginx memory usage with SSL http://www.toofishes.net/blog/nginx-memory-usage-ssl/ http://trac.nginx.org/nginx/changeset/4186/nginx http://trac.nginx.org/nginx/changeset/4187/nginx I'm a bit confused as to what the expected/preferred behavior is, re: SSL compression, I've built against, openssl version OpenSSL 1.0.1c 10 May 2012 so both SSL_OP_NO_COMPRESSION SSL_MODE_RELEASE_BUFFERS are certainly available. I understand they're disabled in nginx by default ... just unclear what should be done, and the result with it, when SPDY's in the loop. should Compression be ON? how, exactly, should that be config'd with spdy? any comment/clarification would be appreciated. thanks. From mdounin at mdounin.ru Thu Jul 12 21:30:59 2012 From: mdounin at mdounin.ru (Maxim Dounin) Date: Fri, 13 Jul 2012 01:30:59 +0400 Subject: "SSL compression" config & usage when SPDY's in use? In-Reply-To: References: Message-ID: <20120712213058.GJ31671@mdounin.ru> Hello! On Thu, Jul 12, 2012 at 11:42:19AM -0700, pgndev wrote: > I'm running > > nginx 1.3.3 + spdy/47 > > SPDY's enabled and functioning. At least it's seen in headers, > detected by browsers, etc. > > In Chromium, SSL site-cert popup reports > > "The connection does not use SSL compression." > > Reading > > SSL, Compression, and You > http://www.belshe.com/2010/11/18/ssl-compression-and-you/ > > Nginx memory usage with SSL > http://www.toofishes.net/blog/nginx-memory-usage-ssl/ > > http://trac.nginx.org/nginx/changeset/4186/nginx > > http://trac.nginx.org/nginx/changeset/4187/nginx > > I'm a bit confused as to what the expected/preferred behavior is, re: > SSL compression, > > I've built against, > > openssl version > OpenSSL 1.0.1c 10 May 2012 > > so both > > SSL_OP_NO_COMPRESSION > SSL_MODE_RELEASE_BUFFERS > > are certainly available. I understand they're disabled in nginx by > default ... just unclear what should be done, and the result with it, > when SPDY's in the loop. > > should Compression be ON? how, exactly, should that be config'd with spdy? > > any comment/clarification would be appreciated. SPDY changes nothing here. Or, more stictly, it makes SSL compression even more pointless, as it introduces headers compression on it's own layer. Maxim Dounin From pgnet.dev+nginx at gmail.com Thu Jul 12 22:04:01 2012 From: pgnet.dev+nginx at gmail.com (pgndev) Date: Thu, 12 Jul 2012 15:04:01 -0700 Subject: "SSL compression" config & usage when SPDY's in use? In-Reply-To: <20120712213058.GJ31671@mdounin.ru> References: <20120712213058.GJ31671@mdounin.ru> Message-ID: On Thu, Jul 12, 2012 at 2:30 PM, Maxim Dounin wrote: > SPDY changes nothing here. Or, more stictly, it makes SSL > compression even more pointless, as it introduces headers > compression on it's own layer. clear, thanks. leaving it alone ... From toli at webforge.bg Fri Jul 13 08:08:56 2012 From: toli at webforge.bg (Anatoli Marinov) Date: Fri, 13 Jul 2012 11:08:56 +0300 Subject: missing module context In-Reply-To: <201207112008.40830.ne@vbart.ru> References: <4FFBE871.5020003@webforge.bg> <201207101424.54857.ne@vbart.ru> <4FFC17BE.5070801@webforge.bg> <201207112008.40830.ne@vbart.ru> Message-ID: <4FFFD798.6050504@webforge.bg> I have custom logs and in the log file I see that rewrite phase passes successful and also there I see that context is created and attached in the request. On 07/11/2012 07:08 PM, Valentin V. Bartenev wrote: > On Tuesday 10 July 2012 15:53:34 Anatoli Marinov wrote: > >> I think I have only 1 request without any sub requests and also do not >> use internal redirects. >> >> > Also the ctx of your module will be NULL if the rewrite phase doesn't happen. > > wbr, Valentin V. Bartenev > > _______________________________________________ > nginx-devel mailing list > nginx-devel at nginx.org > http://mailman.nginx.org/mailman/listinfo/nginx-devel > From ru at nginx.com Tue Jul 17 04:42:39 2012 From: ru at nginx.com (ru at nginx.com) Date: Tue, 17 Jul 2012 04:42:39 +0000 Subject: [nginx] svn commit: r4755 - in trunk/src: core http/modules/perl Message-ID: <20120717044239.4DC3B3F9F2A@mail.nginx.com> Author: ru Date: 2012-07-17 04:42:38 +0000 (Tue, 17 Jul 2012) New Revision: 4755 URL: http://trac.nginx.org/nginx/changeset/4755/nginx Log: Version bump. Modified: trunk/src/core/nginx.h trunk/src/http/modules/perl/nginx.pm Modified: trunk/src/core/nginx.h =================================================================== --- trunk/src/core/nginx.h 2012-07-10 12:40:35 UTC (rev 4754) +++ trunk/src/core/nginx.h 2012-07-17 04:42:38 UTC (rev 4755) @@ -9,8 +9,8 @@ #define _NGINX_H_INCLUDED_ -#define nginx_version 1003003 -#define NGINX_VERSION "1.3.3" +#define nginx_version 1003004 +#define NGINX_VERSION "1.3.4" #define NGINX_VER "nginx/" NGINX_VERSION #define NGINX_VAR "NGINX" Modified: trunk/src/http/modules/perl/nginx.pm =================================================================== --- trunk/src/http/modules/perl/nginx.pm 2012-07-10 12:40:35 UTC (rev 4754) +++ trunk/src/http/modules/perl/nginx.pm 2012-07-17 04:42:38 UTC (rev 4755) @@ -50,7 +50,7 @@ HTTP_INSUFFICIENT_STORAGE ); -our $VERSION = '1.3.3'; +our $VERSION = '1.3.4'; require XSLoader; XSLoader::load('nginx', $VERSION); From ru at nginx.com Tue Jul 17 04:47:34 2012 From: ru at nginx.com (ru at nginx.com) Date: Tue, 17 Jul 2012 04:47:34 +0000 Subject: [nginx] svn commit: r4756 - trunk/src/http Message-ID: <20120717044734.BFE673F9F2A@mail.nginx.com> Author: ru Date: 2012-07-17 04:47:34 +0000 (Tue, 17 Jul 2012) New Revision: 4756 URL: http://trac.nginx.org/nginx/changeset/4756/nginx Log: Fixed sorting of listen addresses so that wildcard address is always at the end (closes #187). Failure to do so could result in several listen sockets to be created instead of only one listening on wildcard address. Reported by Roman Odaisky. Modified: trunk/src/http/ngx_http.c Modified: trunk/src/http/ngx_http.c =================================================================== --- trunk/src/http/ngx_http.c 2012-07-17 04:42:38 UTC (rev 4755) +++ trunk/src/http/ngx_http.c 2012-07-17 04:47:34 UTC (rev 4756) @@ -1613,6 +1613,11 @@ return 1; } + if (second->opt.wildcard) { + /* a wildcard address must be the last resort, shift it to the end */ + return -1; + } + if (first->opt.bind && !second->opt.bind) { /* shift explicit bind()ed addresses to the start */ return -1; From ricvgdev at gmail.com Wed Jul 18 20:24:30 2012 From: ricvgdev at gmail.com (Ricardo V G) Date: Wed, 18 Jul 2012 16:24:30 -0400 Subject: Possible cause and solution of 100% cpu and massive log file in Windows Message-ID: Hi, Recently one of my employer's products (Trend Micro) that includes nginx Windows binary had an issue similar to [1] where the error message "[alert] 2548#2552: WaitForMultipleObjects() failed (6: The handle is invalid)" is generated indefinitely hence creating a massive log file. This wasn't new. Previously a change was done to the configuration and it seemed that the issue was fixed. But it reappeared and I was asked to look into it. Here's what I think could be the problem along with the solution (patch) at the end of this email. When creating threads in a Windows system the following calls are made (using release 1.2.2): main() -> ngx_master_process_cycle() -> ngx_start_worker_processes() -> ngx_start_worker_processes() -> ngx_spawn_process() The issue appears in one documented case when ngx_start_worker_processes() fails to create a thread and the following error message is generated: [alert] 2548#2552: the event "ngx_master_2548" was not signaled for 5s When this message is generated, the execution jumps to the failed label using a goto in os/win32/ngx_process.c at line 150. From there on, the function attempts to close all opened handles and returns an error in the form of an invalid process/thread ID. It's important to note that the thread handle is closed if necessary but the global variable that holds it is not cleared (i.e. the global array ngx_processes[] defined in os/win32/ngx_process.c at line 17 keeps all handles). ngx_pid_t ngx_spawn_process(ngx_cycle_t *cycle, char *name, ngx_int_t respawn) { [...] rc = WaitForMultipleObjects(2, events, 0, 5000); [...] switch (rc) { [...] case WAIT_FAILED: ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, "WaitForSingleObject(\"%s\") failed", ngx_master_process_event_name); goto failed; } [...] failed: [...] if (ngx_processes[s].handle) { ngx_close_handle(ngx_processes[s].handle); } return NGX_INVALID_PID; } With the error in hand, ngx_start_worker_processes() in os/win32/ngx_process_cycle.c breaks the loop and returns with the number of threads that were successfully started. static ngx_int_t ngx_start_worker_processes(ngx_cycle_t *cycle, ngx_int_t type) { [...] for (n = 0; n < ccf->worker_processes; n++) { if (ngx_spawn_process(cycle, "worker", type) == NGX_INVALID_PID) { break; } } return n; } Finally ngx_master_process_cycle(), defined in os/win32/ngx_process_cycle.c, checks if there are any threads and exits if none has started. But if there are any threads that were successfully started then it continues. At this point, ngx_master_process_cycle() enters a forever loop where a call is made to WaitForMultipleObjects() using all the handles obtained from ngx_processes[] including the handle that was already closed by ngx_start_worker_processes(). void ngx_master_process_cycle(ngx_cycle_t *cycle) { [...] if (ngx_start_worker_processes(cycle, NGX_PROCESS_RESPAWN) == 0) { exit(2); } [...] for ( ;; ) { [...] for (n = 0; n < ngx_last_process; n++) { if (ngx_processes[n].handle) { events[nev++] = ngx_processes[n].handle; } } [...] ev = WaitForMultipleObjects(nev, events, 0, timeout); [...] if (ev == WAIT_FAILED) { ngx_log_error(NGX_LOG_ALERT, cycle->log, err, "WaitForMultipleObjects() failed"); continue; } [...] } } Because the handle is invalid, WaitForMultipleObjects() returns immediately with WAIT_FAILED triggering the first error shown in this email followed by a "continue" statement which goes back at the start of the loop again still with the invalid handle. This will be repeated forever since the handle is always invalid. I believe that the simplest fix that doesn't modify the logic of the program is to clear the thread handle in ngx_process.c failed section once they have been closed by setting the variable zero as shown below. What do you think? /ricardo [1] nginx windows freezes with 100% CPU and massive error log http://forum.nginx.org/read.php?2,27839,27839 --- a/src/os/win32/ngx_process.c +++ b/src/os/win32/ngx_process.c @@ -196,6 +196,7 @@ failed: if (ngx_processes[s].handle) { ngx_close_handle(ngx_processes[s].handle); + ngx_processes[s].handle = 0; } return NGX_INVALID_PID; From robertle at semistable.com Thu Jul 19 09:48:59 2012 From: robertle at semistable.com (Robert Lemmen) Date: Thu, 19 Jul 2012 10:48:59 +0100 Subject: various body filter questions Message-ID: <20120719094859.GA3770@teethgrinder.mine.nu> hi everyone, I need to run an nginx with a custom body filter, for the sake of argument let's say I want to replace "robert" with "bob" in every file that ends with ".txt". I played around a bit and looked at the various tutorials and documentation on the net. I have managed to get it basically working, but am looking for your input to get it "correct": a) I create a module context and store it via ngx_http_set_ctx(). how do I clean it up? or do I not need to? does everything allocated with ngx_pcalloc(r->pool, ...) get freed when the request is sorted? b) I would like to handle HEAD requests as well, but I can't just do it with a filter. In the header filter I don't have the actual data in the file, so I can't do the substitutions, so I don't know what the content-length will be. what to do? I was thinking doing a GET sub-request and then simply just return the headers. which is a bit wastefull but might be the only way to determine the content-length. would that be the way to go? if so, then it seems wastefull to first do the HEAD request and then in the filter of the response do a subrequest and ignore the response to the HEAD. can I make it not do the first request at all? woudl that mean it needs to be a handler rather than a a filter? somewhere on the web I read that subrequest can only be done from filters... c) in the body filter, I want to read the buffer chain and modify it or create a new one. but I don't get all the details of the buffer chain. assuming "ngx_chain_t *in" as a parameter of the filter: - if in->next != 0 (and so on), does that mean these buffers are parts of the actual file? so e.g. in->buf could hold the first half of teh file and in->next->buf the second half? - what are the semantics of the different fields in in->buf? what's the difference between pos/last and start/end? what do the different flags (temporary, memory, mmap, recycled, in_file, flush, sync) mean? - what's the difference between last_buf, last_in_chain? is it not the same as in->next == 0? - it might be easier for me to read the buffers and create new ones, rather than changing the existing ones. do I need to do any sort of cleanup? - are the buffers always complete? how would I know? I assume that if I download a 10GB file nginx doesn't just copy it into memory... - how does sendfile work in nginx? if I do a body filter I of course need to make sure sendfile is never used. thanks robert -- Robert Lemmen http://www.semistable.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 198 bytes Desc: Digital signature URL: From mdounin at mdounin.ru Thu Jul 19 13:52:24 2012 From: mdounin at mdounin.ru (Maxim Dounin) Date: Thu, 19 Jul 2012 17:52:24 +0400 Subject: various body filter questions In-Reply-To: <20120719094859.GA3770@teethgrinder.mine.nu> References: <20120719094859.GA3770@teethgrinder.mine.nu> Message-ID: <20120719135224.GC31671@mdounin.ru> Hello! On Thu, Jul 19, 2012 at 10:48:59AM +0100, Robert Lemmen wrote: > hi everyone, > > I need to run an nginx with a custom body filter, for the sake of > argument let's say I want to replace "robert" with "bob" in every file > that ends with ".txt". I played around a bit and looked at the various > tutorials and documentation on the net. I have managed to get it > basically working, but am looking for your input to get it "correct": > > a) I create a module context and store it via ngx_http_set_ctx(). how do > I clean it up? or do I not need to? Usually you don't need to. If you really want for some reason, you may use ngx_http_set_ctx() with NULL. > does everything allocated with > ngx_pcalloc(r->pool, ...) get freed when the request is sorted? Yes. Everything allocated from a pool is freed on the pool destruction. > b) I would like to handle HEAD requests as well, but I can't just do it > with a filter. In the header filter I don't have the actual data in the > file, so I can't do the substitutions, so I don't know what the > content-length will be. what to do? I was thinking doing a GET Usual aproach is to just remove Content-Length header from an answer. As even with GET you can't forecast response length before you've done processing full response, which in turn means your module will just don't work with anything but small responses. [...] > c) in the body filter, I want to read the buffer chain and modify it or > create a new one. but I don't get all the details of the buffer chain. > assuming "ngx_chain_t *in" as a parameter of the filter: > - if in->next != 0 (and so on), does that mean these buffers are parts > of the actual file? so e.g. in->buf could hold the first half of teh > file and in->next->buf the second half? Not file, response. Otherwise yes, there may be more than one buffer in a chain passed to a body filter. Moreover, it may be more than one call to a body filter. You have to handle all buffers in the input chain(s) passed to your body filter. > - what are the semantics of the different fields in in->buf? what's the > difference between pos/last and start/end? what do the different flags > (temporary, memory, mmap, recycled, in_file, flush, sync) mean? The pos/last are bounds of memory used in a buffer, start/end - memory region allocated. Various flags specify various buffer properties, try looking code for details. > - what's the difference between last_buf, last_in_chain? is it not the > same as in->next == 0? The last_in_chain flag marks last buffer of a subrequest response, last_buf - last buffer in a main request response. It's not the same as in->next == NULL as the latter means nothing, see above. > - it might be easier for me to read the buffers and create new ones, > rather than changing the existing ones. do I need to do any sort of > cleanup? Yes. If you don't pass original buffer to a next filter and instead copy it's contents you have to mark buffer as sent by moving b->pos to b->last. Failure to do so will result in hang on large responses as eventually underlying module will run out of buffers and will wait for previously passed buffers to be sent. > - are the buffers always complete? how would I know? I assume that if I > download a 10GB file nginx doesn't just copy it into memory... Single buffer chain passed to a body filter doesn't necessary represent full response. Number and size of buffers used to copy files to memory (once one of a filters needs it) may be controlled with output_buffers directive, see http://nginx.org/r/output_buffers. > - how does sendfile work in nginx? if I do a body filter I of course > need to make sure sendfile is never used. As long as buffers aren't with file-based content sendfile is not used. You shouldn't care about this as long as you correctly modify buffer chain(s). Maxim Dounin From yizhou136 at gmail.com Fri Jul 20 04:11:51 2012 From: yizhou136 at gmail.com (Joy zhou) Date: Fri, 20 Jul 2012 12:11:51 +0800 Subject: a little bug in ngx_event_expire_timers Message-ID: hi everyone: I have found a little bug at method ngx_event_expire_timers of the file "src/event/ngx_event_timer.c " 84 for ( ;; ) { 85 86 ngx_mutex_lock(ngx_event_timer_mutex); 87 88 root = ngx_event_timer_rbtree.root; 89 90 if (root == sentinel) { 91 return; 92 } [...] } The above code should add "ngx_mutex_unlock(ngx_event_timer_mutex);" at 90 line, Because the ngx_event_timer_mutex has locked at begin , but returned without unlock , is it right? -------------- next part -------------- An HTML attachment was scrubbed... URL: From ru at nginx.com Fri Jul 20 06:07:26 2012 From: ru at nginx.com (Ruslan Ermilov) Date: Fri, 20 Jul 2012 10:07:26 +0400 Subject: a little bug in ngx_event_expire_timers In-Reply-To: References: Message-ID: <20120720060726.GA47268@lo0.su> On Fri, Jul 20, 2012 at 12:11:51PM +0800, Joy zhou wrote: > hi everyone: > ?? > ? I have found a little bug at method ngx_event_expire_timers? of? the > file "src/event/ngx_event_timer.c " > ?? > ?? > ???? 84???? for ( ;; ) { > ???? 85 > ???? 86???????? ngx_mutex_lock(ngx_event_timer_mutex); > ???? 87 > ???? 88???????? root = ngx_event_timer_rbtree.root; > ???? 89 > ???? 90???????? if (root == sentinel) { > ???? 91???????????? return; > ???? 92???????? } > ???? > ?????????????? [...] > ??????????? } > ???????????? > ?? The above code should add? > "ngx_mutex_unlock(ngx_event_timer_mutex);" at 90 line, > ?? Because the ngx_event_timer_mutex has locked at begin , but returned > without unlock , is it right???????? Only theoretically. Practically, ngx_mutex_lock() is a no-op in nginx. From ru at nginx.com Fri Jul 20 08:22:00 2012 From: ru at nginx.com (ru at nginx.com) Date: Fri, 20 Jul 2012 08:22:00 +0000 Subject: [nginx] svn commit: r4757 - trunk/src/http/modules Message-ID: <20120720082200.1F2B33FA05C@mail.nginx.com> Author: ru Date: 2012-07-20 08:21:59 +0000 (Fri, 20 Jul 2012) New Revision: 4757 URL: http://trac.nginx.org/nginx/changeset/4757/nginx Log: Fixed debugging messages to account that limit_zone was renamed to limit_conn. Modified: trunk/src/http/modules/ngx_http_limit_conn_module.c Modified: trunk/src/http/modules/ngx_http_limit_conn_module.c =================================================================== --- trunk/src/http/modules/ngx_http_limit_conn_module.c 2012-07-17 04:47:34 UTC (rev 4756) +++ trunk/src/http/modules/ngx_http_limit_conn_module.c 2012-07-20 08:21:59 UTC (rev 4757) @@ -238,7 +238,7 @@ } ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, - "limit zone: %08XD %d", node->key, lc->conn); + "limit conn: %08XD %d", node->key, lc->conn); ngx_shmtx_unlock(&shpool->mutex); @@ -358,7 +358,7 @@ ngx_shmtx_lock(&shpool->mutex); ngx_log_debug2(NGX_LOG_DEBUG_HTTP, lccln->shm_zone->shm.log, 0, - "limit zone cleanup: %08XD %d", node->key, lc->conn); + "limit conn cleanup: %08XD %d", node->key, lc->conn); lc->conn--; From pass86 at gmail.com Fri Jul 20 10:35:00 2012 From: pass86 at gmail.com (Pass86) Date: Fri, 20 Jul 2012 18:35:00 +0800 Subject: a little bug in ngx_event_expire_timers In-Reply-To: <20120720060726.GA47268@lo0.su> References: <20120720060726.GA47268@lo0.su> Message-ID: <4B94046F-69DC-4AC3-8068-866D1BCFFFCF@gmail.com> not using lock, why coding? ???? iPhone ? 2012-7-20?14:07?Ruslan Ermilov ??? > On Fri, Jul 20, 2012 at 12:11:51PM +0800, Joy zhou wrote: >> hi everyone: >> >> I have found a little bug at method ngx_event_expire_timers of the >> file "src/event/ngx_event_timer.c " >> >> >> 84 for ( ;; ) { >> 85 >> 86 ngx_mutex_lock(ngx_event_timer_mutex); >> 87 >> 88 root = ngx_event_timer_rbtree.root; >> 89 >> 90 if (root == sentinel) { >> 91 return; >> 92 } >> >> [...] >> } >> >> The above code should add >> "ngx_mutex_unlock(ngx_event_timer_mutex);" at 90 line, >> Because the ngx_event_timer_mutex has locked at begin , but returned >> without unlock , is it right? > > Only theoretically. Practically, ngx_mutex_lock() is a no-op in nginx. > > _______________________________________________ > nginx-devel mailing list > nginx-devel at nginx.org > http://mailman.nginx.org/mailman/listinfo/nginx-devel From yizhou136 at gmail.com Sat Jul 21 13:35:26 2012 From: yizhou136 at gmail.com (Joy zhou) Date: Sat, 21 Jul 2012 21:35:26 +0800 Subject: nginx-devel Digest, Vol 33, Issue 20 In-Reply-To: References: Message-ID: it well be locked in the case of multiple threads. 2012/7/20 > Send nginx-devel mailing list submissions to > nginx-devel at nginx.org > > To subscribe or unsubscribe via the World Wide Web, visit > http://mailman.nginx.org/mailman/listinfo/nginx-devel > or, via email, send a message with subject or body 'help' to > nginx-devel-request at nginx.org > > You can reach the person managing the list at > nginx-devel-owner at nginx.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of nginx-devel digest..." > > > Today's Topics: > > 1. Re: various body filter questions (Maxim Dounin) > 2. a little bug in ngx_event_expire_timers (Joy zhou) > 3. Re: a little bug in ngx_event_expire_timers (Ruslan Ermilov) > 4. [nginx] svn commit: r4757 - trunk/src/http/modules (ru at nginx.com) > 5. Re: a little bug in ngx_event_expire_timers (Pass86) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Thu, 19 Jul 2012 17:52:24 +0400 > From: Maxim Dounin > To: nginx-devel at nginx.org > Subject: Re: various body filter questions > Message-ID: <20120719135224.GC31671 at mdounin.ru> > Content-Type: text/plain; charset=us-ascii > > Hello! > > On Thu, Jul 19, 2012 at 10:48:59AM +0100, Robert Lemmen wrote: > > > hi everyone, > > > > I need to run an nginx with a custom body filter, for the sake of > > argument let's say I want to replace "robert" with "bob" in every file > > that ends with ".txt". I played around a bit and looked at the various > > tutorials and documentation on the net. I have managed to get it > > basically working, but am looking for your input to get it "correct": > > > > a) I create a module context and store it via ngx_http_set_ctx(). how do > > I clean it up? or do I not need to? > > Usually you don't need to. If you really want for some reason, > you may use ngx_http_set_ctx() with NULL. > > > does everything allocated with > > ngx_pcalloc(r->pool, ...) get freed when the request is sorted? > > Yes. Everything allocated from a pool is freed on the pool > destruction. > > > b) I would like to handle HEAD requests as well, but I can't just do it > > with a filter. In the header filter I don't have the actual data in the > > file, so I can't do the substitutions, so I don't know what the > > content-length will be. what to do? I was thinking doing a GET > > Usual aproach is to just remove Content-Length header from an > answer. As even with GET you can't forecast response length > before you've done processing full response, which in turn means > your module will just don't work with anything but small > responses. > > [...] > > > c) in the body filter, I want to read the buffer chain and modify it or > > create a new one. but I don't get all the details of the buffer chain. > > assuming "ngx_chain_t *in" as a parameter of the filter: > > - if in->next != 0 (and so on), does that mean these buffers are parts > > of the actual file? so e.g. in->buf could hold the first half of teh > > file and in->next->buf the second half? > > Not file, response. Otherwise yes, there may be more than one > buffer in a chain passed to a body filter. Moreover, it may be > more than one call to a body filter. You have to handle all > buffers in the input chain(s) passed to your body filter. > > > - what are the semantics of the different fields in in->buf? what's the > > difference between pos/last and start/end? what do the different flags > > (temporary, memory, mmap, recycled, in_file, flush, sync) mean? > > The pos/last are bounds of memory used in a buffer, start/end - > memory region allocated. Various flags specify various buffer > properties, try looking code for details. > > > - what's the difference between last_buf, last_in_chain? is it not the > > same as in->next == 0? > > The last_in_chain flag marks last buffer of a subrequest response, > last_buf - last buffer in a main request response. It's not the > same as in->next == NULL as the latter means nothing, see above. > > > - it might be easier for me to read the buffers and create new ones, > > rather than changing the existing ones. do I need to do any sort of > > cleanup? > > Yes. If you don't pass original buffer to a next filter and > instead copy it's contents you have to mark buffer as sent by > moving b->pos to b->last. Failure to do so will result in hang > on large responses as eventually underlying module will run out of > buffers and will wait for previously passed buffers to be sent. > > > - are the buffers always complete? how would I know? I assume that if I > > download a 10GB file nginx doesn't just copy it into memory... > > Single buffer chain passed to a body filter doesn't necessary > represent full response. > > Number and size of buffers used to copy files to memory (once one > of a filters needs it) may be controlled with output_buffers > directive, see http://nginx.org/r/output_buffers. > > > - how does sendfile work in nginx? if I do a body filter I of course > > need to make sure sendfile is never used. > > As long as buffers aren't with file-based content sendfile is not > used. You shouldn't care about this as long as you correctly > modify buffer chain(s). > > Maxim Dounin > > > > ------------------------------ > > Message: 2 > Date: Fri, 20 Jul 2012 12:11:51 +0800 > From: Joy zhou > To: nginx-devel at nginx.org > Subject: a little bug in ngx_event_expire_timers > Message-ID: > DvqwPdBFQJY7KrUusvM3w at mail.gmail.com> > Content-Type: text/plain; charset="iso-8859-1" > > hi everyone: > > I have found a little bug at method ngx_event_expire_timers of the file > "src/event/ngx_event_timer.c " > > > 84 for ( ;; ) { > 85 > 86 ngx_mutex_lock(ngx_event_timer_mutex); > 87 > 88 root = ngx_event_timer_rbtree.root; > 89 > 90 if (root == sentinel) { > 91 return; > 92 } > > [...] > } > > The above code should add "ngx_mutex_unlock(ngx_event_timer_mutex);" at > 90 line, > Because the ngx_event_timer_mutex has locked at begin , but returned > without unlock , is it right? > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: < > http://mailman.nginx.org/pipermail/nginx-devel/attachments/20120720/cbcae94d/attachment-0001.html > > > > ------------------------------ > > Message: 3 > Date: Fri, 20 Jul 2012 10:07:26 +0400 > From: Ruslan Ermilov > To: nginx-devel at nginx.org > Subject: Re: a little bug in ngx_event_expire_timers > Message-ID: <20120720060726.GA47268 at lo0.su> > Content-Type: text/plain; charset=iso-8859-1 > > On Fri, Jul 20, 2012 at 12:11:51PM +0800, Joy zhou wrote: > > hi everyone: > > ?? > > ? I have found a little bug at method ngx_event_expire_timers? of? the > > file "src/event/ngx_event_timer.c " > > ?? > > ?? > > ???? 84???? for ( ;; ) { > > ???? 85 > > ???? 86???????? ngx_mutex_lock(ngx_event_timer_mutex); > > ???? 87 > > ???? 88???????? root = ngx_event_timer_rbtree.root; > > ???? 89 > > ???? 90???????? if (root == sentinel) { > > ???? 91???????????? return; > > ???? 92???????? } > > ???? > > ?????????????? [...] > > ??????????? } > > ???????????? > > ?? The above code should add? > > "ngx_mutex_unlock(ngx_event_timer_mutex);" at 90 line, > > ?? Because the ngx_event_timer_mutex has locked at begin , but > returned > > without unlock , is it right???????? > > Only theoretically. Practically, ngx_mutex_lock() is a no-op in nginx. > > > > ------------------------------ > > Message: 4 > Date: Fri, 20 Jul 2012 08:22:00 +0000 > From: ru at nginx.com > To: nginx-devel at nginx.org > Subject: [nginx] svn commit: r4757 - trunk/src/http/modules > Message-ID: <20120720082200.1F2B33FA05C at mail.nginx.com> > Content-Type: text/plain; charset=UTF-8 > > Author: ru > Date: 2012-07-20 08:21:59 +0000 (Fri, 20 Jul 2012) > New Revision: 4757 > URL: http://trac.nginx.org/nginx/changeset/4757/nginx > > Log: > Fixed debugging messages to account that limit_zone was renamed to > limit_conn. > > > Modified: > trunk/src/http/modules/ngx_http_limit_conn_module.c > > Modified: trunk/src/http/modules/ngx_http_limit_conn_module.c > =================================================================== > --- trunk/src/http/modules/ngx_http_limit_conn_module.c 2012-07-17 > 04:47:34 UTC (rev 4756) > +++ trunk/src/http/modules/ngx_http_limit_conn_module.c 2012-07-20 > 08:21:59 UTC (rev 4757) > @@ -238,7 +238,7 @@ > } > > ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, > - "limit zone: %08XD %d", node->key, lc->conn); > + "limit conn: %08XD %d", node->key, lc->conn); > > ngx_shmtx_unlock(&shpool->mutex); > > @@ -358,7 +358,7 @@ > ngx_shmtx_lock(&shpool->mutex); > > ngx_log_debug2(NGX_LOG_DEBUG_HTTP, lccln->shm_zone->shm.log, 0, > - "limit zone cleanup: %08XD %d", node->key, lc->conn); > + "limit conn cleanup: %08XD %d", node->key, lc->conn); > > lc->conn--; > > > > > ------------------------------ > > Message: 5 > Date: Fri, 20 Jul 2012 18:35:00 +0800 > From: Pass86 > To: "nginx-devel at nginx.org" > Subject: Re: a little bug in ngx_event_expire_timers > Message-ID: <4B94046F-69DC-4AC3-8068-866D1BCFFFCF at gmail.com> > Content-Type: text/plain; charset=GB2312 > > not using lock, why coding? > > ???? iPhone > > ? 2012-7-20?14:07?Ruslan Ermilov ??? > > > On Fri, Jul 20, 2012 at 12:11:51PM +0800, Joy zhou wrote: > >> hi everyone: > >> > >> I have found a little bug at method ngx_event_expire_timers of the > >> file "src/event/ngx_event_timer.c " > >> > >> > >> 84 for ( ;; ) { > >> 85 > >> 86 ngx_mutex_lock(ngx_event_timer_mutex); > >> 87 > >> 88 root = ngx_event_timer_rbtree.root; > >> 89 > >> 90 if (root == sentinel) { > >> 91 return; > >> 92 } > >> > >> [...] > >> } > >> > >> The above code should add > >> "ngx_mutex_unlock(ngx_event_timer_mutex);" at 90 line, > >> Because the ngx_event_timer_mutex has locked at begin , but > returned > >> without unlock , is it right? > > > > Only theoretically. Practically, ngx_mutex_lock() is a no-op in nginx. > > > > _______________________________________________ > > nginx-devel mailing list > > nginx-devel at nginx.org > > http://mailman.nginx.org/mailman/listinfo/nginx-devel > > > > ------------------------------ > > _______________________________________________ > nginx-devel mailing list > nginx-devel at nginx.org > http://mailman.nginx.org/mailman/listinfo/nginx-devel > > End of nginx-devel Digest, Vol 33, Issue 20 > ******************************************* > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mdounin at mdounin.ru Mon Jul 23 16:34:41 2012 From: mdounin at mdounin.ru (Maxim Dounin) Date: Mon, 23 Jul 2012 20:34:41 +0400 Subject: Possible cause and solution of 100% cpu and massive log file in Windows In-Reply-To: References: Message-ID: <20120723163440.GV31671@mdounin.ru> Hello! On Wed, Jul 18, 2012 at 04:24:30PM -0400, Ricardo V G wrote: > Recently one of my employer's products (Trend Micro) that includes > nginx Windows binary had an issue similar to [1] where the error > message "[alert] 2548#2552: WaitForMultipleObjects() failed (6: The > handle is invalid)" is generated indefinitely hence creating a massive > log file. This wasn't new. Previously a change was done to the > configuration and it seemed that the issue was fixed. But it > reappeared and I was asked to look into it. Here's what I think could > be the problem along with the solution (patch) at the end of this > email. > > When creating threads in a Windows system the following calls are made > (using release 1.2.2): > > main() -> > ngx_master_process_cycle() -> > ngx_start_worker_processes() -> > ngx_start_worker_processes() -> > ngx_spawn_process() > > The issue appears in one documented case when > ngx_start_worker_processes() fails to create a thread and the > following error message is generated: > > [alert] 2548#2552: the event "ngx_master_2548" was not signaled for 5s > > When this message is generated, the execution jumps to the failed > label using a goto in os/win32/ngx_process.c at line 150. From there > on, the function attempts to close all opened handles and returns an > error in the form of an invalid process/thread ID. It's important to > note that the thread handle is closed if necessary but the global > variable that holds it is not cleared (i.e. the global array > ngx_processes[] defined in os/win32/ngx_process.c at line 17 keeps all > handles). [...] Good catch, thanks. I've committed a slightly modified version of your patch. Could you please provide your full name for CHANGES? Maxim Dounin From mdounin at mdounin.ru Mon Jul 23 16:37:25 2012 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Mon, 23 Jul 2012 16:37:25 +0000 Subject: [nginx] svn commit: r4758 - trunk/src/os/win32 Message-ID: <20120723163725.3C7003F9E45@mail.nginx.com> Author: mdounin Date: 2012-07-23 16:37:24 +0000 (Mon, 23 Jul 2012) New Revision: 4758 URL: http://trac.nginx.org/nginx/changeset/4758/nginx Log: Win32: fixed cpu hog after process startup failure. If ngx_spawn_process() failed while starting a process, the handle of a handle of a processes was closed but left non-NULL in the ngx_processes[] array. The handle later was used in WaitForMultipleObjects() (if there were multiple worker processes configured and at least one worker process was started successfully), resulting in infinite loop. Reported by Ricardo V G: http://mailman.nginx.org/pipermail/nginx-devel/2012-July/002494.html Modified: trunk/src/os/win32/ngx_process.c Modified: trunk/src/os/win32/ngx_process.c =================================================================== --- trunk/src/os/win32/ngx_process.c 2012-07-20 08:21:59 UTC (rev 4757) +++ trunk/src/os/win32/ngx_process.c 2012-07-23 16:37:24 UTC (rev 4758) @@ -196,6 +196,7 @@ if (ngx_processes[s].handle) { ngx_close_handle(ngx_processes[s].handle); + ngx_processes[s].handle = NULL; } return NGX_INVALID_PID; From ricvgdev at gmail.com Mon Jul 23 16:44:47 2012 From: ricvgdev at gmail.com (Ricardo V G) Date: Mon, 23 Jul 2012 12:44:47 -0400 Subject: Possible cause and solution of 100% cpu and massive log file in Windows In-Reply-To: <20120723163440.GV31671@mdounin.ru> References: <20120723163440.GV31671@mdounin.ru> Message-ID: On Mon, Jul 23, 2012 at 12:34 PM, Maxim Dounin wrote: > Hello! > > On Wed, Jul 18, 2012 at 04:24:30PM -0400, Ricardo V G wrote: > >> Recently one of my employer's products (Trend Micro) that includes >> nginx Windows binary had an issue similar to [1] where the error >> message "[alert] 2548#2552: WaitForMultipleObjects() failed (6: The >> handle is invalid)" is generated indefinitely hence creating a massive >> log file. This wasn't new. Previously a change was done to the >> configuration and it seemed that the issue was fixed. But it >> reappeared and I was asked to look into it. Here's what I think could >> be the problem along with the solution (patch) at the end of this >> email. >> >> When creating threads in a Windows system the following calls are made >> (using release 1.2.2): >> >> main() -> >> ngx_master_process_cycle() -> >> ngx_start_worker_processes() -> >> ngx_start_worker_processes() -> >> ngx_spawn_process() >> >> The issue appears in one documented case when >> ngx_start_worker_processes() fails to create a thread and the >> following error message is generated: >> >> [alert] 2548#2552: the event "ngx_master_2548" was not signaled for 5s >> >> When this message is generated, the execution jumps to the failed >> label using a goto in os/win32/ngx_process.c at line 150. From there >> on, the function attempts to close all opened handles and returns an >> error in the form of an invalid process/thread ID. It's important to >> note that the thread handle is closed if necessary but the global >> variable that holds it is not cleared (i.e. the global array >> ngx_processes[] defined in os/win32/ngx_process.c at line 17 keeps all >> handles). > > [...] > > Good catch, thanks. I've committed a slightly modified version > of your patch. > > Could you please provide your full name for CHANGES? > > Maxim Dounin > You're welcome, I'm glad that I could help. Best, Ricardo Villalobos Guevara From richardson.greg at gmail.com Tue Jul 24 05:30:57 2012 From: richardson.greg at gmail.com (Greg Richardson) Date: Mon, 23 Jul 2012 22:30:57 -0700 Subject: SPDY + Lua + fastcgi failing Message-ID: Hello - Working with SPDY/47 and Lua to do a location.capture that ultimately calls fastcgi. The same setup does not produce an issue within http or TLS only server configs, but bails once the spdy flag is added. Doesn't appear to be related to the known SPDY limitations. nginx version: nginx/1.3.3 built by gcc 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5) TLS SNI support enabled configure arguments: --with-debug --with-http_ssl_module --with-openssl=/var/tmp/openssl-1.0.1c --add-module=/var/tmp/simpl-ngx_devel_kit-4192ba6/ --add-module=/var/tmp/substitutions4nginx-read-only/ --add-module=/var/tmp/agentzh-set-misc-nginx-module-658c235/ --add-module=/var/tmp/agentzh-echo-nginx-module-9259898/ --add-module=/var/tmp/chaoslawful-lua-nginx-module-c25689b/ Nginx config: http://pastie.org/private/sztfoeo2rrasohojscn7w Simple lua script: http://pastie.org/private/6y8ivr8bsadd2s5wuayww Debug log when spdy is enabled: http://pastie.org/private/yhmir7lmkv4b2b6lu07ka Portion of the debug log when nginx bails: 2012/07/24 04:39:45 [debug] 9971#0: *11 generic phase: 5 2012/07/24 04:39:45 [debug] 9971#0: *11 try files phase: 9 2012/07/24 04:39:45 [debug] 9971#0: *11 http script var: "/proxy/" 2012/07/24 04:39:45 [debug] 9971#0: *11 trying to use file: "/proxy/" "/usr/local/nginx/html/proxy/" 2012/07/24 04:39:45 [debug] 9971#0: *11 http script var: "/proxy/" 2012/07/24 04:39:45 [debug] 9971#0: *11 trying to use dir: "/proxy/" "/usr/local/nginx/html/proxy/" 2012/07/24 04:39:45 [debug] 9971#0: *11 http script copy: "/index.php" 2012/07/24 04:39:45 [debug] 9971#0: *11 http script var: "" 2012/07/24 04:39:45 [debug] 9971#0: *11 trying to use file: "/index.php" "/usr/local/nginx/html/index.php" 2012/07/24 04:39:45 [debug] 9971#0: *11 internal redirect: "/index.php?" 2012/07/24 04:39:45 [debug] 9971#0: *11 rewrite phase: 0 2012/07/24 04:39:45 [debug] 9971#0: *11 test location: "/" 2012/07/24 04:39:45 [debug] 9971#0: *11 test location: "proxy" 2012/07/24 04:39:45 [debug] 9971#0: *11 test location: "50x.html" 2012/07/24 04:39:45 [debug] 9971#0: *11 test location: ~ "\.php$" 2012/07/24 04:39:45 [debug] 9971#0: *11 using configuration "\.php$" 2012/07/24 04:39:45 [debug] 9971#0: *11 http cl:-1 max:1048576 2012/07/24 04:39:45 [debug] 9971#0: *11 rewrite phase: 2 2012/07/24 04:39:45 [debug] 9971#0: *11 post rewrite phase: 3 2012/07/24 04:39:45 [debug] 9971#0: *11 generic phase: 4 2012/07/24 04:39:45 [debug] 9971#0: *11 generic phase: 5 2012/07/24 04:39:45 [debug] 9971#0: *11 try files phase: 9 2012/07/24 04:39:45 [debug] 9971#0: *11 http script var: "/index.php" 2012/07/24 04:39:45 [debug] 9971#0: *11 trying to use file: "/index.php" "/usr/local/nginx/html/index.php" 2012/07/24 04:39:45 [debug] 9971#0: *11 try file uri: "/index.php" 2012/07/24 04:39:45 [debug] 9971#0: *11 http init upstream, client timer: 0 2012/07/24 04:39:45 [notice] 9963#0: signal 17 (SIGCHLD) received 2012/07/24 04:39:45 [alert] 9963#0: worker process 9971 exited on signal 11 2012/07/24 04:39:45 [debug] 9963#0: shmtx forced unlock 2012/07/24 04:39:45 [debug] 9963#0: wake up, sigio 0 2012/07/24 04:39:45 [debug] 9963#0: reap children 2012/07/24 04:39:45 [debug] 9963#0: child: 0 9971 e:0 t:1 d:0 r:1 j:0 2012/07/24 04:39:45 [debug] 9963#0: channel 3:10 2012/07/24 04:39:45 [notice] 9963#0: start worker process 9996 2012/07/24 04:39:45 [debug] 9963#0: sigsuspend 2012/07/24 04:39:45 [debug] 9996#0: malloc: 0000000002794230:6144 2012/07/24 04:39:45 [debug] 9996#0: malloc: 00007F0739019010:196608 2012/07/24 04:39:45 [debug] 9996#0: malloc: 00000000027DAE60:106496 2012/07/24 04:39:45 [debug] 9996#0: malloc: 00000000027F4E70:106496 Thanks! From nbubingo at gmail.com Tue Jul 24 07:34:39 2012 From: nbubingo at gmail.com (=?GB2312?B?0qbOsLHz?=) Date: Tue, 24 Jul 2012 15:34:39 +0800 Subject: About the format type specifiers Message-ID: 1. The type of 'ngx_msec_int_t', from the source code, It's defined like this: typedef ngx_int_t ngx_rbtree_key_int_t; typedef ngx_rbtree_key_int_t ngx_msec_int_t; So It should be an ngx_int_t. In the file of ngx_http_log_module.c, It appears like this: static u_char * ngx_http_log_request_time(ngx_http_request_t *r, u_char *buf, ngx_http_log_op_t *op) { ngx_time_t *tp; ngx_msec_int_t ms; tp = ngx_timeofday(); ms = (ngx_msec_int_t) ((tp->sec - r->start_sec) * 1000 + (tp->msec - r->start_msec)); ms = ngx_max(ms, 0); return ngx_sprintf(buf, "%T.%03M", ms / 1000, ms % 1000); } 2. The type of '' ngx_gid_t" and "ngx_uid_t", from the source code. They are defined like this: typedef uid_t ngx_uid_t; typedef gid_t ngx_gid_t; And I googled [1][2] about the types of uid_t and gid_t and They seem to unsigned integer. In the file of ngx_process_cycle.c, it appears like this: if (geteuid() == 0) { if (setgid(ccf->group) == -1) { ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, "setgid(%d) failed", ccf->group); /* fatal */ exit(2); } if (initgroups(ccf->username, ccf->group) == -1) { ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, "initgroups(%s, %d) failed", ccf->username, ccf->group); } if (setuid(ccf->user) == -1) { ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, "setuid(%d) failed", ccf->user); /* fatal */ exit(2); } } I want to know the correct format specifiers with ngx_msec_int_t, uid_t and gid_t. I'm a little confused with above codes. Thanks. [1] http://www.delorie.com/gnu/docs/glibc/libc_608.html [2] http://stackoverflow.com/questions/1922761/size-of-pid-t-uid-t-gid-t-on-linux From mdounin at mdounin.ru Tue Jul 24 10:44:49 2012 From: mdounin at mdounin.ru (Maxim Dounin) Date: Tue, 24 Jul 2012 14:44:49 +0400 Subject: About the format type specifiers In-Reply-To: References: Message-ID: <20120724104449.GZ31671@mdounin.ru> Hello! On Tue, Jul 24, 2012 at 03:34:39PM +0800, ??? wrote: > 1. The type of 'ngx_msec_int_t', from the source code, It's defined like this: > > typedef ngx_int_t ngx_rbtree_key_int_t; > typedef ngx_rbtree_key_int_t ngx_msec_int_t; > > So It should be an ngx_int_t. > > In the file of ngx_http_log_module.c, It appears like this: > > static u_char * > ngx_http_log_request_time(ngx_http_request_t *r, u_char *buf, > ngx_http_log_op_t *op) > { > ngx_time_t *tp; > ngx_msec_int_t ms; > > tp = ngx_timeofday(); > > ms = (ngx_msec_int_t) > ((tp->sec - r->start_sec) * 1000 + (tp->msec - r->start_msec)); > ms = ngx_max(ms, 0); > > return ngx_sprintf(buf, "%T.%03M", ms / 1000, ms % 1000); > } In case of ngx_msec_int_t it's almost always possible to use %M which has identical size, as it's only used for intermediate computations and ensured to be non-negative. (Note the ngx_max(ms, 0) call in the code above.) > 2. The type of '' ngx_gid_t" and "ngx_uid_t", from the source code. > They are defined like this: > > typedef uid_t ngx_uid_t; > typedef gid_t ngx_gid_t; > > And I googled [1][2] about the types of uid_t and gid_t and They seem > to unsigned integer. Just a side note: no, POSIX doesn't define signedness of uid_t/gid_t. It only says they should be "integer types", see http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_types.h.html. > > In the file of ngx_process_cycle.c, it appears like this: > > if (geteuid() == 0) { > if (setgid(ccf->group) == -1) { > ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, > "setgid(%d) failed", ccf->group); > /* fatal */ > exit(2); > } > > if (initgroups(ccf->username, ccf->group) == -1) { > ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, > "initgroups(%s, %d) failed", > ccf->username, ccf->group); > } > > if (setuid(ccf->user) == -1) { > ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, > "setuid(%d) failed", ccf->user); > /* fatal */ > exit(2); > } > } > > I want to know the correct format specifiers with ngx_msec_int_t, > uid_t and gid_t. I'm a little confused with above codes. See above for ngx_msec_int_t. Most safe way to print ngx_uint_t/ngx_gid_t is probably to do so with intermediate cast to some defined big-enough type. Strictly speaking the above code isn't correct and might print garbage on some platforms. It probably worth adding explicit casts to int. Maxim Dounin From nbubingo at gmail.com Tue Jul 24 13:30:48 2012 From: nbubingo at gmail.com (=?GB2312?B?0qbOsLHz?=) Date: Tue, 24 Jul 2012 21:30:48 +0800 Subject: About the format type specifiers In-Reply-To: <20120724104449.GZ31671@mdounin.ru> References: <20120724104449.GZ31671@mdounin.ru> Message-ID: Thanks for your great explanation. Explicit casts should be good for us. 2012/7/24 Maxim Dounin : > Hello! > > On Tue, Jul 24, 2012 at 03:34:39PM +0800, ??? wrote: > >> 1. The type of 'ngx_msec_int_t', from the source code, It's defined like this: >> >> typedef ngx_int_t ngx_rbtree_key_int_t; >> typedef ngx_rbtree_key_int_t ngx_msec_int_t; >> >> So It should be an ngx_int_t. >> >> In the file of ngx_http_log_module.c, It appears like this: >> >> static u_char * >> ngx_http_log_request_time(ngx_http_request_t *r, u_char *buf, >> ngx_http_log_op_t *op) >> { >> ngx_time_t *tp; >> ngx_msec_int_t ms; >> >> tp = ngx_timeofday(); >> >> ms = (ngx_msec_int_t) >> ((tp->sec - r->start_sec) * 1000 + (tp->msec - r->start_msec)); >> ms = ngx_max(ms, 0); >> >> return ngx_sprintf(buf, "%T.%03M", ms / 1000, ms % 1000); >> } > > In case of ngx_msec_int_t it's almost always possible to use %M > which has identical size, as it's only used for intermediate > computations and ensured to be non-negative. (Note the > ngx_max(ms, 0) call in the code above.) > >> 2. The type of '' ngx_gid_t" and "ngx_uid_t", from the source code. >> They are defined like this: >> >> typedef uid_t ngx_uid_t; >> typedef gid_t ngx_gid_t; >> >> And I googled [1][2] about the types of uid_t and gid_t and They seem >> to unsigned integer. > > Just a side note: no, POSIX doesn't define signedness of > uid_t/gid_t. It only says they should be "integer types", see > http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_types.h.html. > >> >> In the file of ngx_process_cycle.c, it appears like this: >> >> if (geteuid() == 0) { >> if (setgid(ccf->group) == -1) { >> ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, >> "setgid(%d) failed", ccf->group); >> /* fatal */ >> exit(2); >> } >> >> if (initgroups(ccf->username, ccf->group) == -1) { >> ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, >> "initgroups(%s, %d) failed", >> ccf->username, ccf->group); >> } >> >> if (setuid(ccf->user) == -1) { >> ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, >> "setuid(%d) failed", ccf->user); >> /* fatal */ >> exit(2); >> } >> } >> >> I want to know the correct format specifiers with ngx_msec_int_t, >> uid_t and gid_t. I'm a little confused with above codes. > > See above for ngx_msec_int_t. Most safe way to print > ngx_uint_t/ngx_gid_t is probably to do so with intermediate cast > to some defined big-enough type. > > Strictly speaking the above code isn't correct and might print > garbage on some platforms. It probably worth adding explicit > casts to int. > > Maxim Dounin > > _______________________________________________ > nginx-devel mailing list > nginx-devel at nginx.org > http://mailman.nginx.org/mailman/listinfo/nginx-devel From ru at nginx.com Tue Jul 24 15:00:42 2012 From: ru at nginx.com (ru at nginx.com) Date: Tue, 24 Jul 2012 15:00:42 +0000 Subject: [nginx] svn commit: r4759 - trunk/auto/cc Message-ID: <20120724150042.8C1323F9F75@mail.nginx.com> Author: ru Date: 2012-07-24 15:00:42 +0000 (Tue, 24 Jul 2012) New Revision: 4759 URL: http://trac.nginx.org/nginx/changeset/4759/nginx Log: Replaced a number of "else if" with "elif". Modified: trunk/auto/cc/name Modified: trunk/auto/cc/name =================================================================== --- trunk/auto/cc/name 2012-07-23 16:37:24 UTC (rev 4758) +++ trunk/auto/cc/name 2012-07-24 15:00:42 UTC (rev 4759) @@ -32,14 +32,14 @@ NGX_CC_NAME=msvc10 echo " + using Microsoft Visual C++ 10 compiler" - else if `$NGX_WINE $CC -v 2>&1 \ + elif `$NGX_WINE $CC -v 2>&1 \ | grep '^Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 14' \ >/dev/null 2>&1`; then NGX_CC_NAME=msvc8 echo " + using Microsoft Visual C++ 8 compiler" - else if `$NGX_WINE $CC -v 2>&1 \ + elif `$NGX_WINE $CC -v 2>&1 \ | grep '^Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 13' \ >/dev/null 2>&1`; then @@ -50,52 +50,36 @@ NGX_CC_NAME=msvc echo " + using Microsoft Visual C++ compiler" fi - fi - fi -else -if [ "$CC" = wcl386 ]; then +elif [ "$CC" = wcl386 ]; then NGX_CC_NAME=owc echo " + using Open Watcom C compiler" -else -if [ "$CC" = bcc32 ]; then +elif [ "$CC" = bcc32 ]; then NGX_CC_NAME=bcc echo " + using Borland C++ compiler" -else -if `$CC -V 2>&1 | grep '^Intel(R) C' >/dev/null 2>&1`; then +elif `$CC -V 2>&1 | grep '^Intel(R) C' >/dev/null 2>&1`; then NGX_CC_NAME=icc echo " + using Intel C++ compiler" -else -if `$CC -v 2>&1 | grep 'gcc version' >/dev/null 2>&1`; then +elif `$CC -v 2>&1 | grep 'gcc version' >/dev/null 2>&1`; then NGX_CC_NAME=gcc echo " + using GNU C compiler" -else -if `$CC -V 2>&1 | grep 'Sun C' >/dev/null 2>&1`; then +elif `$CC -V 2>&1 | grep 'Sun C' >/dev/null 2>&1`; then NGX_CC_NAME=sunc echo " + using Sun C compiler" -else -if `$CC -V 2>&1 | grep '^Compaq C' >/dev/null 2>&1`; then +elif `$CC -V 2>&1 | grep '^Compaq C' >/dev/null 2>&1`; then NGX_CC_NAME=ccc echo " + using Compaq C compiler" -else -if `$CC -V 2>&1 | grep '^aCC: ' >/dev/null 2>&1`; then +elif `$CC -V 2>&1 | grep '^aCC: ' >/dev/null 2>&1`; then NGX_CC_NAME=acc echo " + using HP aC++ compiler" else NGX_CC_NAME=unknown -fi # acc -fi # ccc -fi # sunc -fi # icc -fi # gcc -fi # bcc -fi # owc -fi # msvc +fi From ru at nginx.com Tue Jul 24 15:09:55 2012 From: ru at nginx.com (ru at nginx.com) Date: Tue, 24 Jul 2012 15:09:55 +0000 Subject: [nginx] svn commit: r4760 - in trunk/src: core event event/modules http http/modules mail misc os/unix Message-ID: <20120724150955.482CA3F9F44@mail.nginx.com> Author: ru Date: 2012-07-24 15:09:54 +0000 (Tue, 24 Jul 2012) New Revision: 4760 URL: http://trac.nginx.org/nginx/changeset/4760/nginx Log: Fixed compilation with -Wmissing-prototypes. Modified: trunk/src/core/ngx_conf_file.c trunk/src/core/ngx_crypt.c trunk/src/event/modules/ngx_epoll_module.c trunk/src/event/modules/ngx_eventport_module.c trunk/src/event/modules/ngx_rtsig_module.c trunk/src/event/ngx_event.c trunk/src/http/modules/ngx_http_log_module.c trunk/src/http/modules/ngx_http_upstream_least_conn_module.c trunk/src/http/ngx_http_parse_time.c trunk/src/mail/ngx_mail_parse.c trunk/src/misc/ngx_cpp_test_module.cpp trunk/src/os/unix/ngx_atomic.h trunk/src/os/unix/ngx_posix_init.c trunk/src/os/unix/ngx_solaris_sendfilev_chain.c Modified: trunk/src/core/ngx_conf_file.c =================================================================== --- trunk/src/core/ngx_conf_file.c 2012-07-24 15:00:42 UTC (rev 4759) +++ trunk/src/core/ngx_conf_file.c 2012-07-24 15:09:54 UTC (rev 4760) @@ -1448,13 +1448,17 @@ } +#if 0 + char * ngx_conf_unsupported(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) { return "unsupported on this platform"; } +#endif + char * ngx_conf_deprecated(ngx_conf_t *cf, void *post, void *data) { Modified: trunk/src/core/ngx_crypt.c =================================================================== --- trunk/src/core/ngx_crypt.c 2012-07-24 15:00:42 UTC (rev 4759) +++ trunk/src/core/ngx_crypt.c 2012-07-24 15:09:54 UTC (rev 4760) @@ -6,6 +6,7 @@ #include #include +#include #include #if (NGX_HAVE_SHA1) #include Modified: trunk/src/event/modules/ngx_epoll_module.c =================================================================== --- trunk/src/event/modules/ngx_epoll_module.c 2012-07-24 15:00:42 UTC (rev 4759) +++ trunk/src/event/modules/ngx_epoll_module.c 2012-07-24 15:09:54 UTC (rev 4760) @@ -44,16 +44,25 @@ epoll_data_t data; }; + +int epoll_create(int size); + int epoll_create(int size) { return -1; } + +int epoll_ctl(int epfd, int op, int fd, struct epoll_event *event); + int epoll_ctl(int epfd, int op, int fd, struct epoll_event *event) { return -1; } + +int epoll_wait(int epfd, struct epoll_event *events, int nevents, int timeout); + int epoll_wait(int epfd, struct epoll_event *events, int nevents, int timeout) { return -1; @@ -76,11 +85,6 @@ }; -int eventfd(u_int initval) -{ - return -1; -} - #endif #endif Modified: trunk/src/event/modules/ngx_eventport_module.c =================================================================== --- trunk/src/event/modules/ngx_eventport_module.c 2012-07-24 15:00:42 UTC (rev 4759) +++ trunk/src/event/modules/ngx_eventport_module.c 2012-07-24 15:09:54 UTC (rev 4760) @@ -15,6 +15,12 @@ #define ushort_t u_short #define uint_t u_int +#ifndef CLOCK_REALTIME +#define CLOCK_REALTIME 0 +typedef int clockid_t; +typedef void * timer_t; +#endif + /* Solaris declarations */ #define PORT_SOURCE_AIO 1 @@ -24,7 +30,9 @@ #define PORT_SOURCE_ALERT 5 #define PORT_SOURCE_MQ 6 +#ifndef ETIME #define ETIME 64 +#endif #define SIGEV_PORT 4 @@ -50,39 +58,62 @@ #endif +int port_create(void); + int port_create(void) { return -1; } + int port_associate(int port, int source, uintptr_t object, int events, + void *user); + +int port_associate(int port, int source, uintptr_t object, int events, void *user) { return -1; } + +int port_dissociate(int port, int source, uintptr_t object); + int port_dissociate(int port, int source, uintptr_t object) { return -1; } + int port_getn(int port, port_event_t list[], uint_t max, uint_t *nget, + struct timespec *timeout); + +int port_getn(int port, port_event_t list[], uint_t max, uint_t *nget, struct timespec *timeout) { return -1; } + +int timer_create(clockid_t clock_id, struct sigevent *evp, timer_t *timerid); + int timer_create(clockid_t clock_id, struct sigevent *evp, timer_t *timerid) { return -1; } + int timer_settime(timer_t timerid, int flags, const struct itimerspec *value, + struct itimerspec *ovalue); + +int timer_settime(timer_t timerid, int flags, const struct itimerspec *value, struct itimerspec *ovalue) { return -1; } + +int timer_delete(timer_t timerid); + int timer_delete(timer_t timerid) { return -1; Modified: trunk/src/event/modules/ngx_rtsig_module.c =================================================================== --- trunk/src/event/modules/ngx_rtsig_module.c 2012-07-24 15:00:42 UTC (rev 4759) +++ trunk/src/event/modules/ngx_rtsig_module.c 2012-07-24 15:09:54 UTC (rev 4760) @@ -12,6 +12,13 @@ #if (NGX_TEST_BUILD_RTSIG) +#if (NGX_DARWIN) + +#define SIGRTMIN 33 +#define si_fd __pad[0] + +#else + #ifdef SIGRTMIN #define si_fd _reason.__spare__.__spare2__[0] #else @@ -19,11 +26,16 @@ #define si_fd __spare__[0] #endif +#endif + #define F_SETSIG 10 #define KERN_RTSIGNR 30 #define KERN_RTSIGMAX 31 int sigtimedwait(const sigset_t *set, siginfo_t *info, + const struct timespec *timeout); + +int sigtimedwait(const sigset_t *set, siginfo_t *info, const struct timespec *timeout) { return -1; Modified: trunk/src/event/ngx_event.c =================================================================== --- trunk/src/event/ngx_event.c 2012-07-24 15:00:42 UTC (rev 4759) +++ trunk/src/event/ngx_event.c 2012-07-24 15:09:54 UTC (rev 4760) @@ -567,7 +567,7 @@ #if !(NGX_WIN32) -void +static void ngx_timer_signal_handler(int signo) { ngx_event_timer_alarm = 1; Modified: trunk/src/http/modules/ngx_http_log_module.c =================================================================== --- trunk/src/http/modules/ngx_http_log_module.c 2012-07-24 15:00:42 UTC (rev 4759) +++ trunk/src/http/modules/ngx_http_log_module.c 2012-07-24 15:09:54 UTC (rev 4760) @@ -218,7 +218,7 @@ }; -ngx_int_t +static ngx_int_t ngx_http_log_handler(ngx_http_request_t *r) { u_char *line, *p; Modified: trunk/src/http/modules/ngx_http_upstream_least_conn_module.c =================================================================== --- trunk/src/http/modules/ngx_http_upstream_least_conn_module.c 2012-07-24 15:00:42 UTC (rev 4759) +++ trunk/src/http/modules/ngx_http_upstream_least_conn_module.c 2012-07-24 15:09:54 UTC (rev 4760) @@ -81,7 +81,7 @@ }; -ngx_int_t +static ngx_int_t ngx_http_upstream_init_least_conn(ngx_conf_t *cf, ngx_http_upstream_srv_conf_t *us) { Modified: trunk/src/http/ngx_http_parse_time.c =================================================================== --- trunk/src/http/ngx_http_parse_time.c 2012-07-24 15:00:42 UTC (rev 4759) +++ trunk/src/http/ngx_http_parse_time.c 2012-07-24 15:09:54 UTC (rev 4760) @@ -7,6 +7,7 @@ #include #include +#include static ngx_uint_t mday[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; Modified: trunk/src/mail/ngx_mail_parse.c =================================================================== --- trunk/src/mail/ngx_mail_parse.c 2012-07-24 15:00:42 UTC (rev 4759) +++ trunk/src/mail/ngx_mail_parse.c 2012-07-24 15:09:54 UTC (rev 4760) @@ -9,6 +9,9 @@ #include #include #include +#include +#include +#include ngx_int_t Modified: trunk/src/misc/ngx_cpp_test_module.cpp =================================================================== --- trunk/src/misc/ngx_cpp_test_module.cpp 2012-07-24 15:00:42 UTC (rev 4759) +++ trunk/src/misc/ngx_cpp_test_module.cpp 2012-07-24 15:09:54 UTC (rev 4760) @@ -20,6 +20,8 @@ // #include +void ngx_cpp_test_handler(void *data); + void ngx_cpp_test_handler(void *data) { Modified: trunk/src/os/unix/ngx_atomic.h =================================================================== --- trunk/src/os/unix/ngx_atomic.h 2012-07-24 15:00:42 UTC (rev 4759) +++ trunk/src/os/unix/ngx_atomic.h 2012-07-24 15:09:54 UTC (rev 4760) @@ -48,7 +48,9 @@ #include /* "bool" conflicts with perl's CORE/handy.h */ +#if 0 #undef bool +#endif #define NGX_HAVE_ATOMIC_OPS 1 Modified: trunk/src/os/unix/ngx_posix_init.c =================================================================== --- trunk/src/os/unix/ngx_posix_init.c 2012-07-24 15:00:42 UTC (rev 4759) +++ trunk/src/os/unix/ngx_posix_init.c 2012-07-24 15:09:54 UTC (rev 4760) @@ -98,6 +98,8 @@ } +#if 0 + ngx_int_t ngx_posix_post_conf_init(ngx_log_t *log) { @@ -122,3 +124,5 @@ return NGX_OK; } + +#endif Modified: trunk/src/os/unix/ngx_solaris_sendfilev_chain.c =================================================================== --- trunk/src/os/unix/ngx_solaris_sendfilev_chain.c 2012-07-24 15:00:42 UTC (rev 4759) +++ trunk/src/os/unix/ngx_solaris_sendfilev_chain.c 2012-07-24 15:09:54 UTC (rev 4760) @@ -29,6 +29,9 @@ return -1; } +ngx_chain_t *ngx_solaris_sendfilev_chain(ngx_connection_t *c, ngx_chain_t *in, + off_t limit); + #endif From ru at nginx.com Tue Jul 24 15:13:34 2012 From: ru at nginx.com (ru at nginx.com) Date: Tue, 24 Jul 2012 15:13:34 +0000 Subject: [nginx] svn commit: r4761 - trunk/auto/cc Message-ID: <20120724151335.0419F3F9F44@mail.nginx.com> Author: ru Date: 2012-07-24 15:13:34 +0000 (Tue, 24 Jul 2012) New Revision: 4761 URL: http://trac.nginx.org/nginx/changeset/4761/nginx Log: Added a commented out -Wmissing-prototypes to CFLAGS. It is commented out to not break builds with 3rd party modules. Modified: trunk/auto/cc/gcc Modified: trunk/auto/cc/gcc =================================================================== --- trunk/auto/cc/gcc 2012-07-24 15:09:54 UTC (rev 4760) +++ trunk/auto/cc/gcc 2012-07-24 15:13:34 UTC (rev 4761) @@ -149,6 +149,7 @@ CFLAGS="$CFLAGS -Wall -Wpointer-arith" #CFLAGS="$CFLAGS -Wconversion" #CFLAGS="$CFLAGS -Winline" +#CFLAGS="$CFLAGS -Wmissing-prototypes" case "$NGX_GCC_VER" in From ru at nginx.com Tue Jul 24 15:16:09 2012 From: ru at nginx.com (ru at nginx.com) Date: Tue, 24 Jul 2012 15:16:09 +0000 Subject: [nginx] svn commit: r4762 - trunk/auto Message-ID: <20120724151609.BE00A3F9FBE@mail.nginx.com> Author: ru Date: 2012-07-24 15:16:09 +0000 (Tue, 24 Jul 2012) New Revision: 4762 URL: http://trac.nginx.org/nginx/changeset/4762/nginx Log: Made sure to run configure in a "C" locale. Otherwise, we may fail to properly detect a version of compiler. Modified: trunk/auto/configure Modified: trunk/auto/configure =================================================================== --- trunk/auto/configure 2012-07-24 15:13:34 UTC (rev 4761) +++ trunk/auto/configure 2012-07-24 15:16:09 UTC (rev 4762) @@ -4,6 +4,9 @@ # Copyright (C) Nginx, Inc. +LC_ALL=C +export LC_ALL + . auto/options . auto/init . auto/sources From ru at nginx.com Tue Jul 24 15:17:04 2012 From: ru at nginx.com (ru at nginx.com) Date: Tue, 24 Jul 2012 15:17:04 +0000 Subject: [nginx] svn commit: r4763 - trunk/auto/cc Message-ID: <20120724151704.43C603F9FBE@mail.nginx.com> Author: ru Date: 2012-07-24 15:17:03 +0000 (Tue, 24 Jul 2012) New Revision: 4763 URL: http://trac.nginx.org/nginx/changeset/4763/nginx Log: Added the Clang compiler support. The -Werror is commented out to not break builds on Linux. Added: trunk/auto/cc/clang Modified: trunk/auto/cc/conf trunk/auto/cc/name Added: trunk/auto/cc/clang =================================================================== --- trunk/auto/cc/clang (rev 0) +++ trunk/auto/cc/clang 2012-07-24 15:17:03 UTC (rev 4763) @@ -0,0 +1,98 @@ + +# Copyright (C) Nginx, Inc. + + +# clang + + +NGX_CLANG_VER=`$CC -v 2>&1 | grep 'clang version' 2>&1 \ + | sed -e 's/^.*clang version \(.*\)/\1/'` + +echo " + clang version: $NGX_CLANG_VER" + +have=NGX_COMPILER value="\"clang $NGX_CLANG_VER\"" . auto/define + + +CC_TEST_FLAGS="-pipe" + + +# optimizations + +#NGX_CLANG_OPT="-O2" +#NGX_CLANG_OPT="-Oz" +NGX_CLANG_OPT="-O" + +case $CPU in + pentium) + # optimize for Pentium + CPU_OPT="-march=pentium" + NGX_CPU_CACHE_LINE=32 + ;; + + pentiumpro | pentium3) + # optimize for Pentium Pro, Pentium II and Pentium III + CPU_OPT="-march=pentiumpro" + NGX_CPU_CACHE_LINE=32 + ;; + + pentium4) + # optimize for Pentium 4 + CPU_OPT="-march=pentium4" + NGX_CPU_CACHE_LINE=128 + ;; + + athlon) + # optimize for Athlon + CPU_OPT="-march=athlon" + NGX_CPU_CACHE_LINE=64 + ;; + + opteron) + # optimize for Opteron + CPU_OPT="-march=opteron" + NGX_CPU_CACHE_LINE=64 + ;; + +esac + +CC_AUX_FLAGS="$CC_AUX_FLAGS $CPU_OPT" + + +CFLAGS="$CFLAGS -pipe $CPU_OPT" + +if [ ".$PCRE_OPT" = "." ]; then + PCRE_OPT="-O2 -pipe $CPU_OPT" +else + PCRE_OPT="$PCRE_OPT -pipe" +fi + +if [ ".$MD5_OPT" = "." ]; then + MD5_OPT="-O2 -pipe $CPU_OPT" +else + MD5_OPT="$MD5_OPT -pipe" +fi + +if [ ".$ZLIB_OPT" = "." ]; then + ZLIB_OPT="-O2 -pipe $CPU_OPT" +else + ZLIB_OPT="$ZLIB_OPT -pipe" +fi + + +# warnings + +CFLAGS="$CFLAGS $NGX_CLANG_OPT -Wall -Wextra -Wpointer-arith" +#CFLAGS="$CFLAGS -Wmissing-prototypes" + +# we have a lot of unused function arguments +CFLAGS="$CFLAGS -Wno-unused-parameter" + +# stop on warning +#CFLAGS="$CFLAGS -Werror" + +# debug +CFLAGS="$CFLAGS -g" + +if [ ".$CPP" = "." ]; then + CPP="$CC -E" +fi Modified: trunk/auto/cc/conf =================================================================== --- trunk/auto/cc/conf 2012-07-24 15:16:09 UTC (rev 4762) +++ trunk/auto/cc/conf 2012-07-24 15:17:03 UTC (rev 4763) @@ -56,6 +56,12 @@ . auto/cc/gcc ;; + clang) + # Clang C compiler + + . auto/cc/clang + ;; + icc) # Intel C++ compiler 7.1, 8.0, 8.1 Modified: trunk/auto/cc/name =================================================================== --- trunk/auto/cc/name 2012-07-24 15:16:09 UTC (rev 4762) +++ trunk/auto/cc/name 2012-07-24 15:17:03 UTC (rev 4763) @@ -67,6 +67,10 @@ NGX_CC_NAME=gcc echo " + using GNU C compiler" +elif `$CC -v 2>&1 | grep 'clang version' >/dev/null 2>&1`; then + NGX_CC_NAME=clang + echo " + using Clang C compiler" + elif `$CC -V 2>&1 | grep 'Sun C' >/dev/null 2>&1`; then NGX_CC_NAME=sunc echo " + using Sun C compiler" From ru at nginx.com Tue Jul 24 17:40:06 2012 From: ru at nginx.com (ru at nginx.com) Date: Tue, 24 Jul 2012 17:40:06 +0000 Subject: [nginx] svn commit: r4764 - trunk/src/event Message-ID: <20120724174006.BF7243F9F35@mail.nginx.com> Author: ru Date: 2012-07-24 17:40:06 +0000 (Tue, 24 Jul 2012) New Revision: 4764 URL: http://trac.nginx.org/nginx/changeset/4764/nginx Log: When "debug_connection" is configured with a domain name, only the first resolved address was used. Now all addresses will be used. Modified: trunk/src/event/ngx_event.c Modified: trunk/src/event/ngx_event.c =================================================================== --- trunk/src/event/ngx_event.c 2012-07-24 15:17:03 UTC (rev 4763) +++ trunk/src/event/ngx_event.c 2012-07-24 17:40:06 UTC (rev 4764) @@ -1062,51 +1062,92 @@ #if (NGX_DEBUG) ngx_event_conf_t *ecf = conf; - ngx_int_t rc; - ngx_str_t *value; - struct hostent *h; - ngx_cidr_t *cidr; + ngx_int_t rc; + ngx_str_t *value; + ngx_url_t u; + ngx_cidr_t c, *cidr; + ngx_uint_t i; + struct sockaddr_in *sin; +#if (NGX_HAVE_INET6) + struct sockaddr_in6 *sin6; +#endif value = cf->args->elts; - cidr = ngx_array_push(&ecf->debug_connection); - if (cidr == NULL) { - return NGX_CONF_ERROR; - } - #if (NGX_HAVE_UNIX_DOMAIN) if (ngx_strcmp(value[1].data, "unix:") == 0) { - cidr->family = AF_UNIX; - return NGX_CONF_OK; + cidr = ngx_array_push(&ecf->debug_connection); + if (cidr == NULL) { + return NGX_CONF_ERROR; + } + + cidr->family = AF_UNIX; + return NGX_CONF_OK; } #endif - rc = ngx_ptocidr(&value[1], cidr); + rc = ngx_ptocidr(&value[1], &c); - if (rc == NGX_DONE) { - ngx_conf_log_error(NGX_LOG_WARN, cf, 0, - "low address bits of %V are meaningless", &value[1]); - return NGX_CONF_OK; - } + if (rc != NGX_ERROR) { + if (rc == NGX_DONE) { + ngx_conf_log_error(NGX_LOG_WARN, cf, 0, + "low address bits of %V are meaningless", + &value[1]); + } - if (rc == NGX_OK) { + cidr = ngx_array_push(&ecf->debug_connection); + if (cidr == NULL) { + return NGX_CONF_ERROR; + } + + *cidr = c; + return NGX_CONF_OK; } - h = gethostbyname((char *) value[1].data); + ngx_memzero(&u, sizeof(ngx_url_t)); + u.host = value[1]; - if (h == NULL || h->h_addr_list[0] == NULL) { - ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, - "host \"%s\" not found", value[1].data); + if (ngx_inet_resolve_host(cf->pool, &u) != NGX_OK) { + if (u.err) { + ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, + "%s in debug_connection \"%V\"", + u.err, &u.host); + } + return NGX_CONF_ERROR; } - cidr->family = AF_INET; - cidr->u.in.mask = 0xffffffff; - cidr->u.in.addr = *(in_addr_t *)(h->h_addr_list[0]); + cidr = ngx_array_push_n(&ecf->debug_connection, u.naddrs); + if (cidr == NULL) { + return NGX_CONF_ERROR; + } + ngx_memzero(cidr, u.naddrs * sizeof(ngx_cidr_t)); + + for (i = 0; i < u.naddrs; i++) { + cidr[i].family = u.addrs[i].sockaddr->sa_family; + + switch (cidr[i].family) { + +#if (NGX_HAVE_INET6) + case AF_INET6: + sin6 = (struct sockaddr_in6 *) u.addrs[i].sockaddr; + cidr[i].u.in6.addr = sin6->sin6_addr; + ngx_memset(cidr[i].u.in6.mask.s6_addr, 0xff, 16); + break; +#endif + + default: /* AF_INET */ + sin = (struct sockaddr_in *) u.addrs[i].sockaddr; + cidr[i].u.in.addr = sin->sin_addr.s_addr; + cidr[i].u.in.mask = 0xffffffff; + break; + } + } + #else ngx_conf_log_error(NGX_LOG_WARN, cf, 0, From danfiala at centrum.cz Wed Jul 25 20:06:37 2012 From: danfiala at centrum.cz (Daniel Fiala) Date: Wed, 25 Jul 2012 22:06:37 +0200 Subject: Buffers of zero size and filter module Message-ID: Hi all. I try to implement a bit more complicated filter module for Nginx. Because of this I study source codes of existing http modules. I have to allocate my own buffers for filtered data, I cannot change supplied buffers in place. I have been surprised, that it is necessary to handle buffers of zero size in special way. For example, in ngx_http_charset_filter_module.c is the following code: if (ngx_buf_size(b) == 0) { *ll = ngx_alloc_chain_link(r->pool); if (*ll == NULL) { return NGX_ERROR; } (*ll)->buf = b; (*ll)->next = NULL; ll = &(*ll)->next; continue; } My questions are: * Can such buffers of zero size really appear? * Is the number of buffers of zero size small? As I understand, memory of the chain-link is not recycled until the http request is not fully processed. Thanks. Daniel -------------- next part -------------- An HTML attachment was scrubbed... URL: From ne at vbart.ru Wed Jul 25 21:29:28 2012 From: ne at vbart.ru (Valentin V. Bartenev) Date: Thu, 26 Jul 2012 01:29:28 +0400 Subject: Buffers of zero size and filter module In-Reply-To: References: Message-ID: <201207260129.28164.ne@vbart.ru> On Thursday 26 July 2012 00:06:37 Daniel Fiala wrote: [...] > My questions are: > > * Can such buffers of zero size really appear? Yes, they can. They often used to indicate the end of stream or to flush buffers. > * Is the number of buffers of zero size small? As I understand, memory of > the chain-link is not recycled until the http request is not fully > processed. But it is actively reused. If you look at the ngx_alloc_chain_link() function you will find that it tries to get a link from pool->chain, while ngx_free_chain() puts chain links to pool->chain. wbr, Valentin V. Bartenev From ru at nginx.com Thu Jul 26 14:47:43 2012 From: ru at nginx.com (ru at nginx.com) Date: Thu, 26 Jul 2012 14:47:43 +0000 Subject: [nginx] svn commit: r4765 - trunk/src/core Message-ID: <20120726144743.5C73C3F9EC2@mail.nginx.com> Author: ru Date: 2012-07-26 14:47:42 +0000 (Thu, 26 Jul 2012) New Revision: 4765 URL: http://trac.nginx.org/nginx/changeset/4765/nginx Log: Reduced the number of preprocessor directives. Modified: trunk/src/core/ngx_slab.c Modified: trunk/src/core/ngx_slab.c =================================================================== --- trunk/src/core/ngx_slab.c 2012-07-24 17:40:06 UTC (rev 4764) +++ trunk/src/core/ngx_slab.c 2012-07-26 14:47:42 UTC (rev 4765) @@ -45,10 +45,8 @@ #define ngx_slab_junk(p, size) ngx_memset(p, 0xA5, size) -#else +#elif (NGX_HAVE_DEBUG_MALLOC) -#if (NGX_HAVE_DEBUG_MALLOC) - #define ngx_slab_junk(p, size) \ if (ngx_debug_malloc) ngx_memset(p, 0xA5, size) @@ -58,8 +56,6 @@ #endif -#endif - static ngx_slab_page_t *ngx_slab_alloc_pages(ngx_slab_pool_t *pool, ngx_uint_t pages); static void ngx_slab_free_pages(ngx_slab_pool_t *pool, ngx_slab_page_t *page, From danfiala at centrum.cz Fri Jul 27 06:53:35 2012 From: danfiala at centrum.cz (Daniel Fiala) Date: Fri, 27 Jul 2012 08:53:35 +0200 Subject: Buffers of zero size and filter module In-Reply-To: <201207260129.28164.ne@vbart.ru> References: <201207260129.28164.ne@vbart.ru> Message-ID: Hello. On 25 July 2012 23:29, Valentin V. Bartenev wrote: > > * Is the number of buffers of zero size small? As I understand, memory of > > the chain-link is not recycled until the http request is not fully > > processed. > > But it is actively reused. If you look at the ngx_alloc_chain_link() > function you will find that it tries to get a link from pool->chain, > while ngx_free_chain() puts chain links to pool->chain. > > And is ngx_free_chain(.) really called form ngx_http_charset_filter_module.c ? It seems, that it has been added to ngx_chain_update_chains(.) ( http://mailman.nginx.org/pipermail/nginx-devel/2011-September/001178.html ), but this function is not used very often. Modules seem to process buffers own way. > wbr, Valentin V. Bartenev > KR, Daniel -------------- next part -------------- An HTML attachment was scrubbed... URL: From ne at vbart.ru Fri Jul 27 14:01:33 2012 From: ne at vbart.ru (Valentin V. Bartenev) Date: Fri, 27 Jul 2012 18:01:33 +0400 Subject: Buffers of zero size and filter module In-Reply-To: References: <201207260129.28164.ne@vbart.ru> Message-ID: <201207271801.34139.ne@vbart.ru> On Friday 27 July 2012 10:53:35 Daniel Fiala wrote: > Hello. > > On 25 July 2012 23:29, Valentin V. Bartenev wrote: > > > * Is the number of buffers of zero size small? As I understand, memory > > > of the chain-link is not recycled until the http request is not fully > > > processed. > > > > But it is actively reused. If you look at the ngx_alloc_chain_link() > > function you will find that it tries to get a link from pool->chain, > > while ngx_free_chain() puts chain links to pool->chain. > > And is ngx_free_chain(.) really called form > ngx_http_charset_filter_module.c ? No, charset filter doesn't call it. I spoke in general. The charset filter reuses chains for its own buffers, but doesn't free chains those were allocated for anything else. Since a chain is just two pointers, so that is not critical. > It seems, that it has been added to > ngx_chain_update_chains(.) > ( http://mailman.nginx.org/pipermail/nginx-devel/2011-September/001178.html > ), but this function is not used very often. Modules seem to process > buffers own way. > Sure, their own buffers they should process in own way. -- wbr, Valentin V. Bartenev From ru at nginx.com Sun Jul 29 19:38:26 2012 From: ru at nginx.com (ru at nginx.com) Date: Sun, 29 Jul 2012 19:38:26 +0000 Subject: [nginx] svn commit: r4766 - trunk/src/http Message-ID: <20120729193826.9708A3F9F39@mail.nginx.com> Author: ru Date: 2012-07-29 19:38:25 +0000 (Sun, 29 Jul 2012) New Revision: 4766 URL: http://trac.nginx.org/nginx/changeset/4766/nginx Log: ngx_http_upstream_add() should return NULL if an error occurs. Modified: trunk/src/http/ngx_http_upstream.c Modified: trunk/src/http/ngx_http_upstream.c =================================================================== --- trunk/src/http/ngx_http_upstream.c 2012-07-26 14:47:42 UTC (rev 4765) +++ trunk/src/http/ngx_http_upstream.c 2012-07-29 19:38:25 UTC (rev 4766) @@ -4422,12 +4422,12 @@ uscf->servers = ngx_array_create(cf->pool, 1, sizeof(ngx_http_upstream_server_t)); if (uscf->servers == NULL) { - return NGX_CONF_ERROR; + return NULL; } us = ngx_array_push(uscf->servers); if (us == NULL) { - return NGX_CONF_ERROR; + return NULL; } ngx_memzero(us, sizeof(ngx_http_upstream_server_t)); From ru at nginx.com Sun Jul 29 19:44:09 2012 From: ru at nginx.com (ru at nginx.com) Date: Sun, 29 Jul 2012 19:44:09 +0000 Subject: [nginx] svn commit: r4767 - trunk/src/http Message-ID: <20120729194409.DA42C3F9C1B@mail.nginx.com> Author: ru Date: 2012-07-29 19:44:09 +0000 (Sun, 29 Jul 2012) New Revision: 4767 URL: http://trac.nginx.org/nginx/changeset/4767/nginx Log: Slight optimization in ngx_http_upstream_add(): replaced an expression known to be constant with the constant value. Modified: trunk/src/http/ngx_http_upstream.c Modified: trunk/src/http/ngx_http_upstream.c =================================================================== --- trunk/src/http/ngx_http_upstream.c 2012-07-29 19:38:25 UTC (rev 4766) +++ trunk/src/http/ngx_http_upstream.c 2012-07-29 19:44:09 UTC (rev 4767) @@ -4433,7 +4433,7 @@ ngx_memzero(us, sizeof(ngx_http_upstream_server_t)); us->addrs = u->addrs; - us->naddrs = u->naddrs; + us->naddrs = 1; } uscfp = ngx_array_push(&umcf->upstreams); From ru at nginx.com Sun Jul 29 19:45:31 2012 From: ru at nginx.com (ru at nginx.com) Date: Sun, 29 Jul 2012 19:45:31 +0000 Subject: [nginx] svn commit: r4768 - trunk/auto/cc Message-ID: <20120729194531.0FC533F9E70@mail.nginx.com> Author: ru Date: 2012-07-29 19:45:30 +0000 (Sun, 29 Jul 2012) New Revision: 4768 URL: http://trac.nginx.org/nginx/changeset/4768/nginx Log: Removed extraneous GCC warning flags. Modified: trunk/auto/cc/gcc Modified: trunk/auto/cc/gcc =================================================================== --- trunk/auto/cc/gcc 2012-07-29 19:44:09 UTC (rev 4767) +++ trunk/auto/cc/gcc 2012-07-29 19:45:30 UTC (rev 4768) @@ -156,9 +156,6 @@ 3.* | 4.* ) # we have a lot of the unused function arguments CFLAGS="$CFLAGS -Wno-unused-parameter" - CFLAGS="$CFLAGS -Wunused-function" - CFLAGS="$CFLAGS -Wunused-variable" - CFLAGS="$CFLAGS -Wunused-value" # 4.2.1 shows the warning in wrong places #CFLAGS="$CFLAGS -Wunreachable-code" ;; From ru at nginx.com Sun Jul 29 19:59:06 2012 From: ru at nginx.com (ru at nginx.com) Date: Sun, 29 Jul 2012 19:59:06 +0000 Subject: [nginx] svn commit: r4769 - in trunk/src: core http Message-ID: <20120729195906.A80573FA0B7@mail.nginx.com> Author: ru Date: 2012-07-29 19:59:06 +0000 (Sun, 29 Jul 2012) New Revision: 4769 URL: http://trac.nginx.org/nginx/changeset/4769/nginx Log: Improved diagnostics when a directive is specified in the wrong context. Modified: trunk/src/core/ngx_conf_file.c trunk/src/core/ngx_conf_file.h trunk/src/http/ngx_http_core_module.c Modified: trunk/src/core/ngx_conf_file.c =================================================================== --- trunk/src/core/ngx_conf_file.c 2012-07-29 19:45:30 UTC (rev 4768) +++ trunk/src/core/ngx_conf_file.c 2012-07-29 19:59:06 UTC (rev 4769) @@ -282,24 +282,16 @@ { char *rv; void *conf, **confp; - ngx_uint_t i, multi; + ngx_uint_t i, found; ngx_str_t *name; ngx_command_t *cmd; name = cf->args->elts; - multi = 0; + found = 0; for (i = 0; ngx_modules[i]; i++) { - /* look up the directive in the appropriate modules */ - - if (ngx_modules[i]->type != NGX_CONF_MODULE - && ngx_modules[i]->type != cf->module_type) - { - continue; - } - cmd = ngx_modules[i]->commands; if (cmd == NULL) { continue; @@ -315,16 +307,18 @@ continue; } + found = 1; + if (ngx_modules[i]->type != NGX_CONF_MODULE + && ngx_modules[i]->type != cf->module_type) + { + continue; + } + /* is the directive's location right ? */ if (!(cmd->type & cf->cmd_type)) { - if (cmd->type & NGX_CONF_MULTI) { - multi = 1; - continue; - } - - goto not_allowed; + continue; } if (!(cmd->type & NGX_CONF_BLOCK) && last != NGX_OK) { @@ -408,17 +402,16 @@ } } - if (multi == 0) { + if (found) { ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, - "unknown directive \"%s\"", name->data); + "\"%s\" directive is not allowed here", name->data); return NGX_ERROR; } -not_allowed: + ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, + "unknown directive \"%s\"", name->data); - ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, - "\"%s\" directive is not allowed here", name->data); return NGX_ERROR; invalid: Modified: trunk/src/core/ngx_conf_file.h =================================================================== --- trunk/src/core/ngx_conf_file.h 2012-07-29 19:45:30 UTC (rev 4768) +++ trunk/src/core/ngx_conf_file.h 2012-07-29 19:59:06 UTC (rev 4769) @@ -45,7 +45,7 @@ #define NGX_CONF_ANY 0x00000400 #define NGX_CONF_1MORE 0x00000800 #define NGX_CONF_2MORE 0x00001000 -#define NGX_CONF_MULTI 0x00002000 +#define NGX_CONF_MULTI 0x00000000 /* compatibility */ #define NGX_DIRECT_CONF 0x00010000 Modified: trunk/src/http/ngx_http_core_module.c =================================================================== --- trunk/src/http/ngx_http_core_module.c 2012-07-29 19:45:30 UTC (rev 4768) +++ trunk/src/http/ngx_http_core_module.c 2012-07-29 19:59:06 UTC (rev 4769) @@ -222,7 +222,7 @@ NULL }, { ngx_string("server"), - NGX_HTTP_MAIN_CONF|NGX_CONF_BLOCK|NGX_CONF_MULTI|NGX_CONF_NOARGS, + NGX_HTTP_MAIN_CONF|NGX_CONF_BLOCK|NGX_CONF_NOARGS, ngx_http_core_server, 0, 0, From mdounin at mdounin.ru Mon Jul 30 10:35:26 2012 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Mon, 30 Jul 2012 10:35:26 +0000 Subject: [nginx] svn commit: r4770 - trunk/src/http Message-ID: <20120730103527.0C9193F9ED0@mail.nginx.com> Author: mdounin Date: 2012-07-30 10:35:26 +0000 (Mon, 30 Jul 2012) New Revision: 4770 URL: http://trac.nginx.org/nginx/changeset/4770/nginx Log: Upstream: hide_headers/pass_headers inheritance fix. Hide headers and pass headers arrays might not be inherited correctly into a nested location, e.g. in configuration like server { proxy_hide_header X-Foo; location / { location /nested/ { proxy_pass_header X-Pad; } } } the X-Foo header wasn't hidden in the location /nested/. Reported by Konstantin Svist, http://mailman.nginx.org/pipermail/nginx-ru/2012-July/047555.html Modified: trunk/src/http/ngx_http_upstream.c Modified: trunk/src/http/ngx_http_upstream.c =================================================================== --- trunk/src/http/ngx_http_upstream.c 2012-07-29 19:59:06 UTC (rev 4769) +++ trunk/src/http/ngx_http_upstream.c 2012-07-30 10:35:26 UTC (rev 4770) @@ -4541,6 +4541,9 @@ if (conf->hide_headers == NGX_CONF_UNSET_PTR && conf->pass_headers == NGX_CONF_UNSET_PTR) { + conf->hide_headers = prev->hide_headers; + conf->pass_headers = prev->pass_headers; + conf->hide_headers_hash = prev->hide_headers_hash; if (conf->hide_headers_hash.buckets @@ -4552,9 +4555,6 @@ return NGX_OK; } - conf->hide_headers = prev->hide_headers; - conf->pass_headers = prev->pass_headers; - } else { if (conf->hide_headers == NGX_CONF_UNSET_PTR) { conf->hide_headers = prev->hide_headers; From vbart at nginx.com Mon Jul 30 11:42:03 2012 From: vbart at nginx.com (vbart at nginx.com) Date: Mon, 30 Jul 2012 11:42:03 +0000 Subject: [nginx] svn commit: r4771 - trunk/src/http Message-ID: <20120730114203.CC6A43F9F5E@mail.nginx.com> Author: vbart Date: 2012-07-30 11:42:03 +0000 (Mon, 30 Jul 2012) New Revision: 4771 URL: http://trac.nginx.org/nginx/changeset/4771/nginx Log: ngx_http_find_virtual_server() should return NGX_DECLINED if virtual server not found. Modified: trunk/src/http/ngx_http_request.c Modified: trunk/src/http/ngx_http_request.c =================================================================== --- trunk/src/http/ngx_http_request.c 2012-07-30 10:35:26 UTC (rev 4770) +++ trunk/src/http/ngx_http_request.c 2012-07-30 11:42:03 UTC (rev 4771) @@ -1831,7 +1831,7 @@ #endif - return NGX_OK; + return NGX_DECLINED; found: From ru at nginx.com Mon Jul 30 12:27:06 2012 From: ru at nginx.com (ru at nginx.com) Date: Mon, 30 Jul 2012 12:27:06 +0000 Subject: [nginx] svn commit: r4772 - in trunk/src: core http mail Message-ID: <20120730122706.C8AED3F9C5F@mail.nginx.com> Author: ru Date: 2012-07-30 12:27:06 +0000 (Mon, 30 Jul 2012) New Revision: 4772 URL: http://trac.nginx.org/nginx/changeset/4772/nginx Log: Core: ipv6only is now on by default. There is a general consensus that this change results in better consistency between different operating systems and differently tuned operating systems. Note: this changes the width and meaning of the ipv6only field of the ngx_listening_t structure. 3rd party modules that create their own listening sockets might need fixing. Modified: trunk/src/core/ngx_connection.c trunk/src/core/ngx_connection.h trunk/src/http/ngx_http_core_module.c trunk/src/http/ngx_http_core_module.h trunk/src/mail/ngx_mail.h trunk/src/mail/ngx_mail_core_module.c Modified: trunk/src/core/ngx_connection.c =================================================================== --- trunk/src/core/ngx_connection.c 2012-07-30 11:42:03 UTC (rev 4771) +++ trunk/src/core/ngx_connection.c 2012-07-30 12:27:06 UTC (rev 4772) @@ -336,10 +336,10 @@ #if (NGX_HAVE_INET6 && defined IPV6_V6ONLY) - if (ls[i].sockaddr->sa_family == AF_INET6 && ls[i].ipv6only) { + if (ls[i].sockaddr->sa_family == AF_INET6) { int ipv6only; - ipv6only = (ls[i].ipv6only == 1); + ipv6only = ls[i].ipv6only; if (setsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY, (const void *) &ipv6only, sizeof(int)) Modified: trunk/src/core/ngx_connection.h =================================================================== --- trunk/src/core/ngx_connection.h 2012-07-30 11:42:03 UTC (rev 4771) +++ trunk/src/core/ngx_connection.h 2012-07-30 12:27:06 UTC (rev 4772) @@ -64,7 +64,7 @@ unsigned addr_ntop:1; #if (NGX_HAVE_INET6 && defined IPV6_V6ONLY) - unsigned ipv6only:2; + unsigned ipv6only:1; #endif unsigned keepalive:2; Modified: trunk/src/http/ngx_http_core_module.c =================================================================== --- trunk/src/http/ngx_http_core_module.c 2012-07-30 11:42:03 UTC (rev 4771) +++ trunk/src/http/ngx_http_core_module.c 2012-07-30 12:27:06 UTC (rev 4772) @@ -3912,6 +3912,9 @@ lsopt.setfib = -1; #endif lsopt.wildcard = u.wildcard; +#if (NGX_HAVE_INET6 && defined IPV6_V6ONLY) + lsopt.ipv6only = 1; +#endif (void) ngx_sock_ntop(&lsopt.u.sockaddr, lsopt.addr, NGX_SOCKADDR_STRLEN, 1); @@ -4031,7 +4034,7 @@ lsopt.ipv6only = 1; } else if (ngx_strcmp(&value[n].data[10], "ff") == 0) { - lsopt.ipv6only = 2; + lsopt.ipv6only = 0; } else { ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, Modified: trunk/src/http/ngx_http_core_module.h =================================================================== --- trunk/src/http/ngx_http_core_module.h 2012-07-30 11:42:03 UTC (rev 4771) +++ trunk/src/http/ngx_http_core_module.h 2012-07-30 12:27:06 UTC (rev 4772) @@ -76,7 +76,7 @@ unsigned ssl:1; #endif #if (NGX_HAVE_INET6 && defined IPV6_V6ONLY) - unsigned ipv6only:2; + unsigned ipv6only:1; #endif unsigned so_keepalive:2; Modified: trunk/src/mail/ngx_mail.h =================================================================== --- trunk/src/mail/ngx_mail.h 2012-07-30 11:42:03 UTC (rev 4771) +++ trunk/src/mail/ngx_mail.h 2012-07-30 12:27:06 UTC (rev 4772) @@ -39,7 +39,7 @@ unsigned ssl:1; #endif #if (NGX_HAVE_INET6 && defined IPV6_V6ONLY) - unsigned ipv6only:2; + unsigned ipv6only:1; #endif unsigned so_keepalive:2; #if (NGX_HAVE_KEEPALIVE_TUNABLE) @@ -100,7 +100,7 @@ unsigned ssl:1; #endif #if (NGX_HAVE_INET6 && defined IPV6_V6ONLY) - unsigned ipv6only:2; + unsigned ipv6only:1; #endif unsigned so_keepalive:2; #if (NGX_HAVE_KEEPALIVE_TUNABLE) Modified: trunk/src/mail/ngx_mail_core_module.c =================================================================== --- trunk/src/mail/ngx_mail_core_module.c 2012-07-30 11:42:03 UTC (rev 4771) +++ trunk/src/mail/ngx_mail_core_module.c 2012-07-30 12:27:06 UTC (rev 4772) @@ -374,6 +374,10 @@ ls->wildcard = u.wildcard; ls->ctx = cf->ctx; +#if (NGX_HAVE_INET6 && defined IPV6_V6ONLY) + ls->ipv6only = 1; +#endif + for (m = 0; ngx_modules[m]; m++) { if (ngx_modules[m]->type != NGX_MAIL_MODULE) { continue; @@ -413,7 +417,7 @@ ls->ipv6only = 1; } else if (ngx_strcmp(&value[i].data[10], "ff") == 0) { - ls->ipv6only = 2; + ls->ipv6only = 0; } else { ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, From vshebordaev at mail.ru Mon Jul 30 18:24:49 2012 From: vshebordaev at mail.ru (Vladimir Shebordaev) Date: Mon, 30 Jul 2012 22:24:49 +0400 Subject: early ngx_memcpy() with NGX_MEMCPY_LIMIT patch Message-ID: Hi, ngx_memcpy() is invoked before ngx_cycle has been initialized, so the server can segfault there when NGX_MEMCPY_LIMIT is enabled. diff -Naur rev4754/src/core/ngx_string.c ticket55/src/core/ngx_string.c --- rev4754/src/core/ngx_string.c 2012-07-16 23:15:16.613980918 +0400 +++ ticket55/src/core/ngx_string.c 2012-07-23 15:41:02.863561192 +0400 @@ -1830,7 +1830,8 @@ ngx_memcpy(void *dst, void *src, size_t n) { if (n > NGX_MEMCPY_LIMIT) { - ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, 0, "memcpy %uz bytes", n); + if (ngx_cycle) + ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, 0, "memcpy %uz bytes", n); ngx_debug_point(); } -- Regards, Vladimir From vshebordaev at mail.ru Mon Jul 30 18:26:27 2012 From: vshebordaev at mail.ru (Vladimir Shebordaev) Date: Mon, 30 Jul 2012 22:26:27 +0400 Subject: a minor build patch to facilitate debugging Message-ID: Hi, I think it would be nice to disable optimitazions and enable full debugging options when NGX_DEBUG is set diff -Naur rev4754/auto/cc/gcc ticket55/auto/cc/gcc --- rev4754/auto/cc/gcc 2012-07-16 23:15:16.733977245 +0400 +++ ticket55/auto/cc/gcc 2012-07-23 08:50:14.420222679 +0400 @@ -50,7 +50,12 @@ #NGX_GCC_OPT="-O2" #NGX_GCC_OPT="-Os" +if [ -n "$NGX_DEBUG" ]; then +NGX_GCC_OPT="-ggdb3" +else NGX_GCC_OPT="-O" +fi + #CFLAGS="$CFLAGS -fomit-frame-pointer" -- Regards, Vladimir From ru at nginx.com Mon Jul 30 20:44:53 2012 From: ru at nginx.com (Ruslan Ermilov) Date: Tue, 31 Jul 2012 00:44:53 +0400 Subject: ngx_listening_t API change Message-ID: <20120730204453.GB28776@lo0.su> Hi, The ipv6only field of the ngx_listening_t structure was changed to accept only 0 or 1 to mean turn IPV6_V6ONLY off or on, respectively. The old semantics of 0 (leave IPV6_V6ONLY at OS default) is no longer supported. 3rd party modules that create their own listening sockets might need fixing. At least the following modules (authors Cc:ed) are known to be affected by this change: rtmp, tcp proxy. Please see the following commit for details: http://trac.nginx.org/nginx/changeset/4772/nginx From mdounin at mdounin.ru Mon Jul 30 22:03:23 2012 From: mdounin at mdounin.ru (Maxim Dounin) Date: Tue, 31 Jul 2012 02:03:23 +0400 Subject: early ngx_memcpy() with NGX_MEMCPY_LIMIT patch In-Reply-To: References: Message-ID: <20120730220323.GH40452@mdounin.ru> Hello! On Mon, Jul 30, 2012 at 10:24:49PM +0400, Vladimir Shebordaev wrote: > Hi, > > ngx_memcpy() is invoked before ngx_cycle has been initialized, so the server > can segfault there when NGX_MEMCPY_LIMIT is enabled. > > diff -Naur rev4754/src/core/ngx_string.c ticket55/src/core/ngx_string.c > --- rev4754/src/core/ngx_string.c 2012-07-16 23:15:16.613980918 +0400 > +++ ticket55/src/core/ngx_string.c 2012-07-23 15:41:02.863561192 +0400 > @@ -1830,7 +1830,8 @@ > ngx_memcpy(void *dst, void *src, size_t n) > { > if (n > NGX_MEMCPY_LIMIT) { > - ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, 0, "memcpy %uz bytes", n); > + if (ngx_cycle) > + ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, 0, "memcpy > %uz bytes", n); > ngx_debug_point(); > } This change is certainly not enough for nginx to survive too low NGX_MEMCPY_LIMIT set, e.g. due to the fact that ngx_debug_point() needs ngx_cycle as well (and actually much more than this: it depends on a ngx_core_module config to be available via ngx_cycle). I would rather suggest to don't try to define NGX_MEMCPY_LIMIT unless you understand possible implications. Maxim Dounin From mdounin at mdounin.ru Mon Jul 30 22:16:57 2012 From: mdounin at mdounin.ru (Maxim Dounin) Date: Tue, 31 Jul 2012 02:16:57 +0400 Subject: a minor build patch to facilitate debugging In-Reply-To: References: Message-ID: <20120730221657.GI40452@mdounin.ru> Hello! On Mon, Jul 30, 2012 at 10:26:27PM +0400, Vladimir Shebordaev wrote: > Hi, > > I think it would be nice to disable optimitazions and enable full > debugging options when NGX_DEBUG is set These are quite orthogonal things. The --with-debug option enables debug logging. It's up to you to disable optimizations if you wan't to (--with-cc-opt="-O0") and/or enable additional debugging flags as understood by your compiler and debugger, but certainly not something should be done by default due to --with-debug. > > diff -Naur rev4754/auto/cc/gcc ticket55/auto/cc/gcc > --- rev4754/auto/cc/gcc 2012-07-16 23:15:16.733977245 +0400 > +++ ticket55/auto/cc/gcc 2012-07-23 08:50:14.420222679 +0400 > @@ -50,7 +50,12 @@ > > #NGX_GCC_OPT="-O2" > #NGX_GCC_OPT="-Os" > +if [ -n "$NGX_DEBUG" ]; then This is a wrong test for sure, as NGX_DEBUG is never empty, it's either NO or YES. > +NGX_GCC_OPT="-ggdb3" > +else > NGX_GCC_OPT="-O" > +fi > + > > #CFLAGS="$CFLAGS -fomit-frame-pointer" Maxim Dounin From vshebordaev at mail.ru Mon Jul 30 22:19:29 2012 From: vshebordaev at mail.ru (Vladimir Shebordaev) Date: Tue, 31 Jul 2012 02:19:29 +0400 Subject: early ngx_memcpy() with NGX_MEMCPY_LIMIT patch In-Reply-To: <20120730220323.GH40452@mdounin.ru> References: <20120730220323.GH40452@mdounin.ru> Message-ID: 2012/7/31 Maxim Dounin : > Hello! > > On Mon, Jul 30, 2012 at 10:24:49PM +0400, Vladimir Shebordaev wrote: > >> Hi, >> >> ngx_memcpy() is invoked before ngx_cycle has been initialized, so the server >> can segfault there when NGX_MEMCPY_LIMIT is enabled. >> >> diff -Naur rev4754/src/core/ngx_string.c ticket55/src/core/ngx_string.c >> --- rev4754/src/core/ngx_string.c 2012-07-16 23:15:16.613980918 +0400 >> +++ ticket55/src/core/ngx_string.c 2012-07-23 15:41:02.863561192 +0400 >> @@ -1830,7 +1830,8 @@ >> ngx_memcpy(void *dst, void *src, size_t n) >> { >> if (n > NGX_MEMCPY_LIMIT) { >> - ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, 0, "memcpy %uz bytes", n); >> + if (ngx_cycle) >> + ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, 0, "memcpy %uz bytes", n); >> ngx_debug_point(); >> } > > This change is certainly not enough for nginx to survive too low > NGX_MEMCPY_LIMIT set, e.g. due to the fact that ngx_debug_point() > needs ngx_cycle as well (and actually much more than this: it > depends on a ngx_core_module config to be available via ngx_cycle). > > I would rather suggest to don't try to define NGX_MEMCPY_LIMIT > unless you understand possible implications. Thanks, it was just helpful. > > Maxim Dounin > From vshebordaev at mail.ru Mon Jul 30 22:31:54 2012 From: vshebordaev at mail.ru (Vladimir Shebordaev) Date: Tue, 31 Jul 2012 02:31:54 +0400 Subject: a minor build patch to facilitate debugging In-Reply-To: <20120730221657.GI40452@mdounin.ru> References: <20120730221657.GI40452@mdounin.ru> Message-ID: 2012/7/31 Maxim Dounin : > Hello! > > On Mon, Jul 30, 2012 at 10:26:27PM +0400, Vladimir Shebordaev wrote: > >> Hi, >> >> I think it would be nice to disable optimitazions and enable full >> debugging options when NGX_DEBUG is set > > These are quite orthogonal things. The --with-debug option > enables debug logging. It's up to you to disable optimizations if > you wan't to (--with-cc-opt="-O0") and/or enable additional > debugging flags as understood by your compiler and debugger, but > certainly not something should be done by default due to --with-debug. > >> >> diff -Naur rev4754/auto/cc/gcc ticket55/auto/cc/gcc >> --- rev4754/auto/cc/gcc 2012-07-16 23:15:16.733977245 +0400 >> +++ ticket55/auto/cc/gcc 2012-07-23 08:50:14.420222679 +0400 >> @@ -50,7 +50,12 @@ >> >> #NGX_GCC_OPT="-O2" >> #NGX_GCC_OPT="-Os" >> +if [ "$NGX_DEBUG" = YES ]; then > > This is a wrong test for sure, as NGX_DEBUG is never empty, it's > either NO or YES. > Sure, sorry, it is an excerpt from my working tree where I set the flag on make command line. But when you enable debugging in the server you might want to also run it under the debugger. It seems useful anyways. At least for gcc. >> +NGX_GCC_OPT="-ggdb3" >> +else >> NGX_GCC_OPT="-O" >> +fi >> + >> >> #CFLAGS="$CFLAGS -fomit-frame-pointer" > > Maxim Dounin > From danfiala at centrum.cz Tue Jul 31 06:56:19 2012 From: danfiala at centrum.cz (Daniel Fiala) Date: Tue, 31 Jul 2012 08:56:19 +0200 Subject: Dependency of 3rd party module Message-ID: Hi all. I am developing some 3rd party module for Nginx. I would like to enable configuration/compilation of my module only if http_ssl_module is enabled. Moreover, if http_ssl_module is not set, then configure should write an error message and failed. Is there any way how to do this? Thanks a lot, Daniel -------------- next part -------------- An HTML attachment was scrubbed... URL: From ru at nginx.com Tue Jul 31 12:38:37 2012 From: ru at nginx.com (ru at nginx.com) Date: Tue, 31 Jul 2012 12:38:37 +0000 Subject: [nginx] svn commit: r4773 - trunk/docs/xml/nginx Message-ID: <20120731123837.D57B13F9E47@mail.nginx.com> Author: ru Date: 2012-07-31 12:38:37 +0000 (Tue, 31 Jul 2012) New Revision: 4773 URL: http://trac.nginx.org/nginx/changeset/4773/nginx Log: nginx-1.3.4-RELEASE Modified: trunk/docs/xml/nginx/changes.xml Modified: trunk/docs/xml/nginx/changes.xml =================================================================== --- trunk/docs/xml/nginx/changes.xml 2012-07-30 12:27:06 UTC (rev 4772) +++ trunk/docs/xml/nginx/changes.xml 2012-07-31 12:38:37 UTC (rev 4773) @@ -9,6 +9,69 @@ nginx changelog + + + + +?????? ?? ????????? IPv6-??????? ???????? ipv6only +??????? ?? ?????????. + + +the "ipv6only" parameter is now turned on by default for +listening IPv6 sockets. + + + + + +????????? ??????????? Clang. + + +the Clang compiler support. + + + + + +????? ??????????? ?????? ????????? ??????.
+??????? ?????? ?????????. +
+ +extra listening sockets might be created.
+Thanks to Roman Odaisky. +
+
+ + + +nginx/Windows ??? ????????? ?????????, ???? ??? ??????? ???????? ???????? +??????????? ??????.
+??????? Ricardo Villalobos Guevara. +
+ +nginx/Windows might hog CPU if a worker process failed to start.
+Thanks to Ricardo Villalobos Guevara. +
+
+ + + +????????? proxy_pass_header, fastcgi_pass_header, scgi_pass_header, +uwsgi_pass_header, proxy_hide_header, fastcgi_hide_header, +scgi_hide_header ? uwsgi_hide_header +????? ????????????? ???????????. + + +the "proxy_pass_header", "fastcgi_pass_header", "scgi_pass_header", +"uwsgi_pass_header", "proxy_hide_header", "fastcgi_hide_header", +"scgi_hide_header", and "uwsgi_hide_header" directives +might be inherited incorrectly. + + + +
+ + From ru at nginx.com Tue Jul 31 12:38:57 2012 From: ru at nginx.com (ru at nginx.com) Date: Tue, 31 Jul 2012 12:38:57 +0000 Subject: [nginx] svn commit: r4774 - tags Message-ID: <20120731123857.5CCB73FA20B@mail.nginx.com> Author: ru Date: 2012-07-31 12:38:57 +0000 (Tue, 31 Jul 2012) New Revision: 4774 URL: http://trac.nginx.org/nginx/changeset/4774/nginx Log: release-1.3.4 tag Added: tags/release-1.3.4/ From ru at nginx.com Tue Jul 31 13:13:52 2012 From: ru at nginx.com (ru at nginx.com) Date: Tue, 31 Jul 2012 13:13:52 +0000 Subject: [nginx] svn commit: r4775 - trunk/misc Message-ID: <20120731131352.F04CD3F9F9F@mail.nginx.com> Author: ru Date: 2012-07-31 13:13:52 +0000 (Tue, 31 Jul 2012) New Revision: 4775 URL: http://trac.nginx.org/nginx/changeset/4775/nginx Log: Updated PCRE used for win32 builds. Modified: trunk/misc/GNUmakefile Modified: trunk/misc/GNUmakefile =================================================================== --- trunk/misc/GNUmakefile 2012-07-31 12:38:57 UTC (rev 4774) +++ trunk/misc/GNUmakefile 2012-07-31 13:13:52 UTC (rev 4775) @@ -8,7 +8,7 @@ OBJS = objs.msvc8 OPENSSL = openssl-1.0.1c ZLIB = zlib-1.2.5 -PCRE = pcre-8.30 +PCRE = pcre-8.31 release: From mdounin at mdounin.ru Tue Jul 31 13:26:54 2012 From: mdounin at mdounin.ru (Maxim Dounin) Date: Tue, 31 Jul 2012 17:26:54 +0400 Subject: Dependency of 3rd party module In-Reply-To: References: Message-ID: <20120731132654.GQ40452@mdounin.ru> Hello! On Tue, Jul 31, 2012 at 08:56:19AM +0200, Daniel Fiala wrote: > Hi all. > I am developing some 3rd party module for Nginx. I would like to enable > configuration/compilation of my module only if http_ssl_module is enabled. > Moreover, if http_ssl_module is not set, then configure should write an > error message and failed. Is there any way how to do this? You may check HTTP_SSL variable in your module's config script (and trigger failure if it isn't set to "YES"). See auto/options for details. Maxim Dounin From ru at nginx.com Tue Jul 31 21:47:56 2012 From: ru at nginx.com (ru at nginx.com) Date: Tue, 31 Jul 2012 21:47:56 +0000 Subject: [nginx] svn commit: r4776 - in trunk/src: core http/modules/perl Message-ID: <20120731214757.03E2E3FA211@mail.nginx.com> Author: ru Date: 2012-07-31 21:47:56 +0000 (Tue, 31 Jul 2012) New Revision: 4776 URL: http://trac.nginx.org/nginx/changeset/4776/nginx Log: Version bump. Modified: trunk/src/core/nginx.h trunk/src/http/modules/perl/nginx.pm Modified: trunk/src/core/nginx.h =================================================================== --- trunk/src/core/nginx.h 2012-07-31 13:13:52 UTC (rev 4775) +++ trunk/src/core/nginx.h 2012-07-31 21:47:56 UTC (rev 4776) @@ -9,8 +9,8 @@ #define _NGINX_H_INCLUDED_ -#define nginx_version 1003004 -#define NGINX_VERSION "1.3.4" +#define nginx_version 1003005 +#define NGINX_VERSION "1.3.5" #define NGINX_VER "nginx/" NGINX_VERSION #define NGINX_VAR "NGINX" Modified: trunk/src/http/modules/perl/nginx.pm =================================================================== --- trunk/src/http/modules/perl/nginx.pm 2012-07-31 13:13:52 UTC (rev 4775) +++ trunk/src/http/modules/perl/nginx.pm 2012-07-31 21:47:56 UTC (rev 4776) @@ -50,7 +50,7 @@ HTTP_INSUFFICIENT_STORAGE ); -our $VERSION = '1.3.4'; +our $VERSION = '1.3.5'; require XSLoader; XSLoader::load('nginx', $VERSION); From ru at nginx.com Tue Jul 31 21:49:23 2012 From: ru at nginx.com (ru at nginx.com) Date: Tue, 31 Jul 2012 21:49:23 +0000 Subject: [nginx] svn commit: r4777 - trunk/docs Message-ID: <20120731214923.8D7C73F9F85@mail.nginx.com> Author: ru Date: 2012-07-31 21:49:23 +0000 (Tue, 31 Jul 2012) New Revision: 4777 URL: http://trac.nginx.org/nginx/changeset/4777/nginx Log: Simplified makefile that builds CHANGES. Modified: trunk/docs/GNUmakefile Modified: trunk/docs/GNUmakefile =================================================================== --- trunk/docs/GNUmakefile 2012-07-31 21:47:56 UTC (rev 4776) +++ trunk/docs/GNUmakefile 2012-07-31 21:49:23 UTC (rev 4777) @@ -5,25 +5,7 @@ TEMP= tmp CP= $(HOME)/java -define XSLScript - java -cp $(CP)/xsls/saxon.jar:$(CP)/xsls/xsls.jar \ - com.pault.StyleSheet \ - -x com.pault.XX -y com.pault.XX \ - $(1) docs/xsls/dump.xsls \ - | sed 's/ *$$//;/^ *$$/N;/\n *$$/D' > $(2) - if [ ! -s $(2) ]; then rm $(2); fi; test -s $(2) -endef - -define XSLT - xmllint --noout --valid $2 - xsltproc -o $3 \ - $(shell echo $4 \\ - | sed -e "s/\([^= ]*\)=\([^= ]*\)/--param \1 \"'\2'\"/g") \ - $1 $2 -endef - - all: changes changes: $(TEMP)/$(NGINX)/CHANGES.ru \ @@ -34,24 +16,28 @@ docs/xml/change_log_conf.xml \ docs/xslt/changes.xslt - test -d $(TEMP)/$(NGINX) || mkdir -p $(TEMP)/$(NGINX) + mkdir -p $(TEMP)/$(NGINX) xsltproc --stringparam lang ru \ - -o $(TEMP)/$(NGINX)/CHANGES.ru \ - docs/xslt/changes.xslt docs/xml/nginx/changes.xml + -o $@ docs/xslt/changes.xslt docs/xml/nginx/changes.xml $(TEMP)/$(NGINX)/CHANGES: docs/xml/nginx/changes.xml \ docs/xml/change_log_conf.xml \ docs/xslt/changes.xslt - test -d $(TEMP)/$(NGINX) || mkdir -p $(TEMP)/$(NGINX) + mkdir -p $(TEMP)/$(NGINX) xsltproc --stringparam lang en \ - -o $(TEMP)/$(NGINX)/CHANGES \ - docs/xslt/changes.xslt docs/xml/nginx/changes.xml + -o $@ docs/xslt/changes.xslt docs/xml/nginx/changes.xml -docs/xslt/changes.xslt: docs/xsls/changes.xsls +docs/xslt/changes.xslt: docs/xsls/changes.xsls docs/xsls/dump.xsls - $(call XSLScript, docs/xsls/changes.xsls, $@) + java -cp $(CP)/xsls/saxon.jar:$(CP)/xsls/xsls.jar \ + com.pault.StyleSheet \ + -x com.pault.XX -y com.pault.XX \ + $< docs/xsls/dump.xsls \ + | sed 's/ *$$//;/^ *$$/N;/\n *$$/D' > $@ + + if [ ! -s $@ ]; then rm $@; fi; test -s $@