From vbart at nginx.com Mon Dec 5 08:06:16 2011 From: vbart at nginx.com (vbart at nginx.com) Date: Mon, 5 Dec 2011 08:06:16 +0000 Subject: [nginx] svn commit: r4324 - in trunk: auto src/core src/http src/mail Message-ID: Author: vbart Date: 2011-12-05 08:06:15 +0000 (Mon, 05 Dec 2011) New Revision: 4324 Modified: trunk/auto/unix trunk/src/core/ngx_connection.c trunk/src/core/ngx_connection.h trunk/src/http/ngx_http.c trunk/src/http/ngx_http_core_module.c trunk/src/http/ngx_http_core_module.h trunk/src/mail/ngx_mail.c trunk/src/mail/ngx_mail.h trunk/src/mail/ngx_mail_core_module.c Log: Added the "so_keepalive=" parameter to the "listen" directive. The "so_keepalive" directive in mail module was deprecated. Thanks to Vsevolod Stakhov for initial work. Modified: trunk/auto/unix =================================================================== --- trunk/auto/unix 2011-11-30 10:01:11 UTC (rev 4323) +++ trunk/auto/unix 2011-12-05 08:06:15 UTC (rev 4324) @@ -328,6 +328,20 @@ . auto/feature +ngx_feature="TCP_KEEPIDLE, TCP_KEEPINTVL, TCP_KEEPCNT" +ngx_feature_name="NGX_HAVE_KEEPALIVE_TUNABLE" +ngx_feature_run=no +ngx_feature_incs="#include + #include + #include " +ngx_feature_path= +ngx_feature_libs= +ngx_feature_test="setsockopt(0, IPPROTO_TCP, TCP_KEEPIDLE, NULL, 0); + setsockopt(0, IPPROTO_TCP, TCP_KEEPINTVL, NULL, 0); + setsockopt(0, IPPROTO_TCP, TCP_KEEPCNT, NULL, 0)" +. auto/feature + + ngx_feature="accept4()" ngx_feature_name="NGX_HAVE_ACCEPT4" ngx_feature_run=no Modified: trunk/src/core/ngx_connection.c =================================================================== --- trunk/src/core/ngx_connection.c 2011-11-30 10:01:11 UTC (rev 4323) +++ trunk/src/core/ngx_connection.c 2011-12-05 08:06:15 UTC (rev 4324) @@ -462,6 +462,7 @@ void ngx_configure_listening_sockets(ngx_cycle_t *cycle) { + int keepalive; ngx_uint_t i; ngx_listening_t *ls; @@ -499,6 +500,56 @@ } } + if (ls[i].keepalive) { + keepalive = (ls[i].keepalive == 1) ? 1 : 0; + + if (setsockopt(ls[i].fd, SOL_SOCKET, SO_KEEPALIVE, + (const void *) &keepalive, sizeof(int)) + == -1) + { + ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_socket_errno, + "setsockopt(SO_KEEPALIVE, %d) %V failed, ignored", + keepalive, &ls[i].addr_text); + } + } + +#if (NGX_HAVE_KEEPALIVE_TUNABLE) + + if (ls[i].keepidle) { + if (setsockopt(ls[i].fd, IPPROTO_TCP, TCP_KEEPIDLE, + (const void *) &ls[i].keepidle, sizeof(int)) + == -1) + { + ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_socket_errno, + "setsockopt(TCP_KEEPIDLE, %d) %V failed, ignored", + ls[i].keepidle, &ls[i].addr_text); + } + } + + if (ls[i].keepintvl) { + if (setsockopt(ls[i].fd, IPPROTO_TCP, TCP_KEEPINTVL, + (const void *) &ls[i].keepintvl, sizeof(int)) + == -1) + { + ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_socket_errno, + "setsockopt(TCP_KEEPINTVL, %d) %V failed, ignored", + ls[i].keepintvl, &ls[i].addr_text); + } + } + + if (ls[i].keepcnt) { + if (setsockopt(ls[i].fd, IPPROTO_TCP, TCP_KEEPCNT, + (const void *) &ls[i].keepcnt, sizeof(int)) + == -1) + { + ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_socket_errno, + "setsockopt(TCP_KEEPCNT, %d) %V failed, ignored", + ls[i].keepcnt, &ls[i].addr_text); + } + } + +#endif + #if (NGX_HAVE_SETFIB) if (ls[i].setfib != -1) { if (setsockopt(ls[i].fd, SOL_SOCKET, SO_SETFIB, Modified: trunk/src/core/ngx_connection.h =================================================================== --- trunk/src/core/ngx_connection.h 2011-11-30 10:01:11 UTC (rev 4323) +++ trunk/src/core/ngx_connection.h 2011-12-05 08:06:15 UTC (rev 4324) @@ -27,6 +27,11 @@ int backlog; int rcvbuf; int sndbuf; +#if (NGX_HAVE_KEEPALIVE_TUNABLE) + int keepidle; + int keepintvl; + int keepcnt; +#endif /* handler of accepted connection */ ngx_connection_handler_pt handler; @@ -60,6 +65,7 @@ #if (NGX_HAVE_INET6 && defined IPV6_V6ONLY) unsigned ipv6only:2; #endif + unsigned keepalive:2; #if (NGX_HAVE_DEFERRED_ACCEPT) unsigned deferred_accept:1; Modified: trunk/src/http/ngx_http.c =================================================================== --- trunk/src/http/ngx_http.c 2011-11-30 10:01:11 UTC (rev 4323) +++ trunk/src/http/ngx_http.c 2011-12-05 08:06:15 UTC (rev 4324) @@ -1762,6 +1762,13 @@ ls->rcvbuf = addr->opt.rcvbuf; ls->sndbuf = addr->opt.sndbuf; + ls->keepalive = addr->opt.so_keepalive; +#if (NGX_HAVE_KEEPALIVE_TUNABLE) + ls->keepidle = addr->opt.tcp_keepidle; + ls->keepintvl = addr->opt.tcp_keepintvl; + ls->keepcnt = addr->opt.tcp_keepcnt; +#endif + #if (NGX_HAVE_DEFERRED_ACCEPT && defined SO_ACCEPTFILTER) ls->accept_filter = addr->opt.accept_filter; #endif Modified: trunk/src/http/ngx_http_core_module.c =================================================================== --- trunk/src/http/ngx_http_core_module.c 2011-11-30 10:01:11 UTC (rev 4323) +++ trunk/src/http/ngx_http_core_module.c 2011-12-05 08:06:15 UTC (rev 4324) @@ -3815,6 +3815,97 @@ #endif } + if (ngx_strncmp(value[n].data, "so_keepalive=", 13) == 0) { + + if (ngx_strcmp(&value[n].data[13], "on") == 0) { + lsopt.so_keepalive = 1; + + } else if (ngx_strcmp(&value[n].data[13], "off") == 0) { + lsopt.so_keepalive = 2; + + } else { + +#if (NGX_HAVE_KEEPALIVE_TUNABLE) + u_char *p, *end; + ngx_str_t s; + + end = value[n].data + value[n].len; + s.data = value[n].data + 13; + + p = ngx_strlchr(s.data, end, ':'); + if (p == NULL) { + p = end; + } + + if (p > s.data) { + s.len = p - s.data; + + lsopt.tcp_keepidle = ngx_parse_time(&s, 1); + if (lsopt.tcp_keepidle == NGX_ERROR) { + goto invalid_so_keepalive; + } + } + + s.data = (p < end) ? (p + 1) : end; + + p = ngx_strlchr(s.data, end, ':'); + if (p == NULL) { + p = end; + } + + if (p > s.data) { + s.len = p - s.data; + + lsopt.tcp_keepintvl = ngx_parse_time(&s, 1); + if (lsopt.tcp_keepintvl == NGX_ERROR) { + goto invalid_so_keepalive; + } + } + + s.data = (p < end) ? (p + 1) : end; + + if (s.data < end) { + s.len = end - s.data; + + lsopt.tcp_keepcnt = ngx_atoi(s.data, s.len); + if (lsopt.tcp_keepcnt == NGX_ERROR) { + goto invalid_so_keepalive; + } + } + + if (lsopt.tcp_keepidle == 0 && lsopt.tcp_keepintvl == 0 + && lsopt.tcp_keepcnt == 0) + { + goto invalid_so_keepalive; + } + + lsopt.so_keepalive = 1; + +#else + + ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, + "the \"so_keepalive\" parameter accepts " + "only \"on\" or \"off\" on this platform"); + return NGX_CONF_ERROR; + +#endif + } + + lsopt.set = 1; + lsopt.bind = 1; + + continue; + +#if (NGX_HAVE_KEEPALIVE_TUNABLE) + invalid_so_keepalive: + + ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, + "invalid so_keepalive value: \"%s\"", + &value[n].data[13]); + return NGX_CONF_ERROR; +#endif + } + ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "invalid parameter \"%V\"", &value[n]); return NGX_CONF_ERROR; Modified: trunk/src/http/ngx_http_core_module.h =================================================================== --- trunk/src/http/ngx_http_core_module.h 2011-11-30 10:01:11 UTC (rev 4323) +++ trunk/src/http/ngx_http_core_module.h 2011-12-05 08:06:15 UTC (rev 4324) @@ -77,6 +77,7 @@ #if (NGX_HAVE_INET6 && defined IPV6_V6ONLY) unsigned ipv6only:2; #endif + unsigned so_keepalive:2; int backlog; int rcvbuf; @@ -84,6 +85,11 @@ #if (NGX_HAVE_SETFIB) int setfib; #endif +#if (NGX_HAVE_KEEPALIVE_TUNABLE) + int tcp_keepidle; + int tcp_keepintvl; + int tcp_keepcnt; +#endif #if (NGX_HAVE_DEFERRED_ACCEPT && defined SO_ACCEPTFILTER) char *accept_filter; Modified: trunk/src/mail/ngx_mail.c =================================================================== --- trunk/src/mail/ngx_mail.c 2011-11-30 10:01:11 UTC (rev 4323) +++ trunk/src/mail/ngx_mail.c 2011-12-05 08:06:15 UTC (rev 4324) @@ -308,6 +308,12 @@ addr->ctx = listen->ctx; addr->bind = listen->bind; addr->wildcard = listen->wildcard; + addr->so_keepalive = listen->so_keepalive; +#if (NGX_HAVE_KEEPALIVE_TUNABLE) + addr->tcp_keepidle = listen->tcp_keepidle; + addr->tcp_keepintvl = listen->tcp_keepintvl; + addr->tcp_keepcnt = listen->tcp_keepcnt; +#endif #if (NGX_MAIL_SSL) addr->ssl = listen->ssl; #endif @@ -373,6 +379,13 @@ ls->log.data = &ls->addr_text; ls->log.handler = ngx_accept_log_error; + ls->keepalive = addr[i].so_keepalive; +#if (NGX_HAVE_KEEPALIVE_TUNABLE) + ls->keepidle = addr[i].tcp_keepidle; + ls->keepintvl = addr[i].tcp_keepintvl; + ls->keepcnt = addr[i].tcp_keepcnt; +#endif + #if (NGX_HAVE_INET6 && defined IPV6_V6ONLY) ls->ipv6only = addr[i].ipv6only; #endif Modified: trunk/src/mail/ngx_mail.h =================================================================== --- trunk/src/mail/ngx_mail.h 2011-11-30 10:01:11 UTC (rev 4323) +++ trunk/src/mail/ngx_mail.h 2011-12-05 08:06:15 UTC (rev 4324) @@ -40,6 +40,12 @@ #if (NGX_HAVE_INET6 && defined IPV6_V6ONLY) unsigned ipv6only:2; #endif + unsigned so_keepalive:2; +#if (NGX_HAVE_KEEPALIVE_TUNABLE) + int tcp_keepidle; + int tcp_keepintvl; + int tcp_keepcnt; +#endif } ngx_mail_listen_t; @@ -95,6 +101,12 @@ #if (NGX_HAVE_INET6 && defined IPV6_V6ONLY) unsigned ipv6only:2; #endif + unsigned so_keepalive:2; +#if (NGX_HAVE_KEEPALIVE_TUNABLE) + int tcp_keepidle; + int tcp_keepintvl; + int tcp_keepcnt; +#endif } ngx_mail_conf_addr_t; Modified: trunk/src/mail/ngx_mail_core_module.c =================================================================== --- trunk/src/mail/ngx_mail_core_module.c 2011-11-30 10:01:11 UTC (rev 4323) +++ trunk/src/mail/ngx_mail_core_module.c 2011-12-05 08:06:15 UTC (rev 4324) @@ -24,6 +24,12 @@ void *conf); +static ngx_conf_deprecated_t ngx_conf_deprecated_so_keepalive = { + ngx_conf_deprecated, "so_keepalive", + "so_keepalive\" parameter of the \"listen" +}; + + static ngx_command_t ngx_mail_core_commands[] = { { ngx_string("server"), @@ -52,7 +58,7 @@ ngx_conf_set_flag_slot, NGX_MAIL_SRV_CONF_OFFSET, offsetof(ngx_mail_core_srv_conf_t, so_keepalive), - NULL }, + &ngx_conf_deprecated_so_keepalive }, { ngx_string("timeout"), NGX_MAIL_MAIN_CONF|NGX_MAIL_SRV_CONF|NGX_CONF_TAKE1, @@ -446,6 +452,96 @@ #endif } + if (ngx_strncmp(value[i].data, "so_keepalive=", 13) == 0) { + + if (ngx_strcmp(&value[i].data[13], "on") == 0) { + ls->so_keepalive = 1; + + } else if (ngx_strcmp(&value[i].data[13], "off") == 0) { + ls->so_keepalive = 2; + + } else { + +#if (NGX_HAVE_KEEPALIVE_TUNABLE) + u_char *p, *end; + ngx_str_t s; + + end = value[i].data + value[i].len; + s.data = value[i].data + 13; + + p = ngx_strlchr(s.data, end, ':'); + if (p == NULL) { + p = end; + } + + if (p > s.data) { + s.len = p - s.data; + + ls->tcp_keepidle = ngx_parse_time(&s, 1); + if (ls->tcp_keepidle == NGX_ERROR) { + goto invalid_so_keepalive; + } + } + + s.data = (p < end) ? (p + 1) : end; + + p = ngx_strlchr(s.data, end, ':'); + if (p == NULL) { + p = end; + } + + if (p > s.data) { + s.len = p - s.data; + + ls->tcp_keepintvl = ngx_parse_time(&s, 1); + if (ls->tcp_keepintvl == NGX_ERROR) { + goto invalid_so_keepalive; + } + } + + s.data = (p < end) ? (p + 1) : end; + + if (s.data < end) { + s.len = end - s.data; + + ls->tcp_keepcnt = ngx_atoi(s.data, s.len); + if (ls->tcp_keepcnt == NGX_ERROR) { + goto invalid_so_keepalive; + } + } + + if (ls->tcp_keepidle == 0 && ls->tcp_keepintvl == 0 + && ls->tcp_keepcnt == 0) + { + goto invalid_so_keepalive; + } + + ls->so_keepalive = 1; + +#else + + ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, + "the \"so_keepalive\" parameter accepts " + "only \"on\" or \"off\" on this platform"); + return NGX_CONF_ERROR; + +#endif + } + + ls->bind = 1; + + continue; + +#if (NGX_HAVE_KEEPALIVE_TUNABLE) + invalid_so_keepalive: + + ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, + "invalid so_keepalive value: \"%s\"", + &value[i].data[13]); + return NGX_CONF_ERROR; +#endif + } + ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "the invalid \"%V\" parameter", &value[i]); return NGX_CONF_ERROR; From piotr.sikora at frickle.com Mon Dec 5 15:17:37 2011 From: piotr.sikora at frickle.com (Piotr Sikora) Date: Mon, 5 Dec 2011 16:17:37 +0100 Subject: Nginx cache grouped by keys In-Reply-To: References: Message-ID: <58F48B2E3FC842D5B05533B1C72E3862@Desktop> Hello Wandenberg, thank you for your patches and sorry for the late reply. I've been toying with various ideas on how to improve cache purging mechanism (with prefixes, wildcards and/or cache groups) for the last 2 years, but to be honest, I wasn't happy with any of them... And while your approach is probably the best you can do with current cache implementation, it's far from perfect, simply because it needs to walk the disk, which makes it useable only for very small cache groups. If nginx guys decide that your approach is acceptable and include it in the core, then I have no problem with adding support for it in ngx_cache_purge, but to be honest, I would prefer to see some kind of persistent cache index instead ;) Best regards, Piotr Sikora < piotr.sikora at frickle.com > From brian at akins.org Mon Dec 5 21:21:12 2011 From: brian at akins.org (Brian Akins) Date: Mon, 5 Dec 2011 16:21:12 -0500 Subject: Nginx cache grouped by keys In-Reply-To: <58F48B2E3FC842D5B05533B1C72E3862@Desktop> References: <58F48B2E3FC842D5B05533B1C72E3862@Desktop> Message-ID: On Mon, Dec 5, 2011 at 10:17 AM, Piotr Sikora wrote: > If nginx guys decide that your approach is acceptable and include it in > the core, then I have no problem with adding support for it in > ngx_cache_purge, but to be honest, I would prefer to see some kind of > persistent cache index instead ;) > Is there enough info about the cache exposed that you could stash the "index" in something like redis? (or whatever your db-like thing of choice) -------------- next part -------------- An HTML attachment was scrubbed... URL: From piotr.sikora at frickle.com Mon Dec 5 21:37:21 2011 From: piotr.sikora at frickle.com (Piotr Sikora) Date: Mon, 5 Dec 2011 22:37:21 +0100 Subject: Nginx cache grouped by keys In-Reply-To: References: <58F48B2E3FC842D5B05533B1C72E3862@Desktop> Message-ID: Hey, > Is there enough info about the cache exposed that you could stash the > "index" in something like redis? (or whatever your db-like thing of > choice) Yes. Best regards, Piotr Sikora < piotr.sikora at frickle.com > From ne at vbart.ru Tue Dec 6 08:42:10 2011 From: ne at vbart.ru (Valentin V. Bartenev) Date: Tue, 6 Dec 2011 12:42:10 +0400 Subject: [PATCH] Ignore response header entries with zero hash in ngx_http_varaible_headers In-Reply-To: References: Message-ID: <201112061242.10500.ne@vbart.ru> Hello, agentzh. On Wednesday 09 November 2011 13:49:51 agentzh wrote: > On Sat, Oct 1, 2011 at 2:08 AM, agentzh wrote: > > Thank you for the review. I've already updated the patch per your > > suggestion and tested on my side :) > > Markus Linnala has found a memory overflow issue in my previous patch. > Here attaches an updated one for nginx 1.0.9. Thank you for the patch. Based on it, I wrote a slightly more optimized version. Would you please take a look? Also, It would be great if you try it. Thanks! wbr, Valentin V. Bartenev // NGINX Team Index: src/http/ngx_http_variables.c =================================================================== --- src/http/ngx_http_variables.c (revision 4323) +++ src/http/ngx_http_variables.c (working copy) @@ -640,8 +640,8 @@ static ngx_int_t ngx_http_variable_headers(ngx_http_request_t *r, ngx_http_variable_value_t *v, uintptr_t data) { - ssize_t len; - u_char *p; + size_t len; + u_char *p, *end; ngx_uint_t i, n; ngx_array_t *a; ngx_table_elt_t **h; @@ -649,18 +649,30 @@ ngx_http_variable_headers(ngx_http_request_t *r, n a = (ngx_array_t *) ((char *) r + data); n = a->nelts; + h = a->elts; - if (n == 0) { + len = 0; + + for (i = 0; i < n; i++) { + + if (h[i]->hash == 0) { + continue; + } + + len += h[i]->value.len + sizeof("; ") - 1; + } + + if (len == 0) { v->not_found = 1; return NGX_OK; } + len -= sizeof("; ") - 1; + v->valid = 1; v->no_cacheable = 0; v->not_found = 0; - h = a->elts; - if (n == 1) { v->len = (*h)->value.len; v->data = (*h)->value.data; @@ -668,12 +680,6 @@ ngx_http_variable_headers(ngx_http_request_t *r, n return NGX_OK; } - len = - (ssize_t) (sizeof("; ") - 1); - - for (i = 0; i < n; i++) { - len += h[i]->value.len + sizeof("; ") - 1; - } - p = ngx_pnalloc(r->pool, len); if (p == NULL) { return NGX_ERROR; @@ -682,10 +688,17 @@ ngx_http_variable_headers(ngx_http_request_t *r, n v->len = len; v->data = p; + end = p + len; + for (i = 0; /* void */ ; i++) { + + if (h[i]->hash == 0) { + continue; + } + p = ngx_copy(p, h[i]->value.data, h[i]->value.len); - if (i == n - 1) { + if (p == end) { break; } @@ -738,6 +751,10 @@ ngx_http_variable_unknown_header(ngx_http_variable i = 0; } + if (header[i].hash == 0) { + continue; + } + for (n = 0; n + prefix < var->len && n < header[i].key.len; n++) { ch = header[i].key.data[n]; From mdounin at mdounin.ru Tue Dec 6 13:22:33 2011 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Tue, 6 Dec 2011 13:22:33 +0000 Subject: [nginx] svn commit: r4325 - in trunk/src: core http/modules/perl Message-ID: <20111206132233.5FBED3F9C23@mail.nginx.com> Author: mdounin Date: 2011-12-06 13:22:32 +0000 (Tue, 06 Dec 2011) New Revision: 4325 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 2011-12-05 08:06:15 UTC (rev 4324) +++ trunk/src/core/nginx.h 2011-12-06 13:22:32 UTC (rev 4325) @@ -8,8 +8,8 @@ #define _NGINX_H_INCLUDED_ -#define nginx_version 1001010 -#define NGINX_VERSION "1.1.10" +#define nginx_version 1001011 +#define NGINX_VERSION "1.1.11" #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 2011-12-05 08:06:15 UTC (rev 4324) +++ trunk/src/http/modules/perl/nginx.pm 2011-12-06 13:22:32 UTC (rev 4325) @@ -48,7 +48,7 @@ HTTP_INSUFFICIENT_STORAGE ); -our $VERSION = '1.1.10'; +our $VERSION = '1.1.11'; require XSLoader; XSLoader::load('nginx', $VERSION); From mdounin at mdounin.ru Tue Dec 6 13:23:37 2011 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Tue, 6 Dec 2011 13:23:37 +0000 Subject: [nginx] svn commit: r4326 - trunk/src/http Message-ID: <20111206132337.5261B3F9C23@mail.nginx.com> Author: mdounin Date: 2011-12-06 13:23:37 +0000 (Tue, 06 Dec 2011) New Revision: 4326 Log: Fix for read_head with try_files and open_file_cache. The of.read_ahead wasn't set in try_files code path, causing read_ahead directive to be a nop if try_files and open_file_cache were used. 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 2011-12-06 13:22:32 UTC (rev 4325) +++ trunk/src/http/ngx_http_core_module.c 2011-12-06 13:23:37 UTC (rev 4326) @@ -1289,6 +1289,7 @@ ngx_memzero(&of, sizeof(ngx_open_file_info_t)); + of.read_ahead = clcf->read_ahead; of.directio = clcf->directio; of.valid = clcf->open_file_cache_valid; of.min_uses = clcf->open_file_cache_min_uses; From vbart at nginx.com Tue Dec 6 15:49:40 2011 From: vbart at nginx.com (vbart at nginx.com) Date: Tue, 6 Dec 2011 15:49:40 +0000 Subject: [nginx] svn commit: r4327 - trunk/src/core Message-ID: Author: vbart Date: 2011-12-06 15:49:40 +0000 (Tue, 06 Dec 2011) New Revision: 4327 Modified: trunk/src/core/ngx_regex.c Log: Removed unused function ngx_regex_capture_count(). The function has been unused since r3326. Modified: trunk/src/core/ngx_regex.c =================================================================== --- trunk/src/core/ngx_regex.c 2011-12-06 13:23:37 UTC (rev 4326) +++ trunk/src/core/ngx_regex.c 2011-12-06 15:49:40 UTC (rev 4327) @@ -137,23 +137,6 @@ ngx_int_t -ngx_regex_capture_count(ngx_regex_t *re) -{ - int rc, n; - - n = 0; - - rc = pcre_fullinfo(re, NULL, PCRE_INFO_CAPTURECOUNT, &n); - - if (rc < 0) { - return (ngx_int_t) rc; - } - - return (ngx_int_t) n; -} - - -ngx_int_t ngx_regex_exec_array(ngx_array_t *a, ngx_str_t *s, ngx_log_t *log) { ngx_int_t n; From valery+nginxen at grid.net.ru Tue Dec 6 16:23:34 2011 From: valery+nginxen at grid.net.ru (Valery Kholodkov) Date: Tue, 6 Dec 2011 16:23:34 +0000 (GMT) Subject: [nginx] svn commit: r4327 - trunk/src/core In-Reply-To: <20111206154942.3889B3F9CAB@mail.nginx.com> Message-ID: <17401008.5662.1323188614650.JavaMail.root@zone.mtgsy.net> FYI This function is used in upload module: https://github.com/vkholodkov/nginx-upload-module/blob/2.2/ngx_http_upload_module.c#L2656 ----- vbart at nginx.com wrote: > Author: vbart > Date: 2011-12-06 15:49:40 +0000 (Tue, 06 Dec 2011) > New Revision: 4327 > > Modified: > trunk/src/core/ngx_regex.c > Log: > Removed unused function ngx_regex_capture_count(). > The function has been unused since r3326. > > > Modified: trunk/src/core/ngx_regex.c > =================================================================== > --- trunk/src/core/ngx_regex.c 2011-12-06 13:23:37 UTC (rev 4326) > +++ trunk/src/core/ngx_regex.c 2011-12-06 15:49:40 UTC (rev 4327) > @@ -137,23 +137,6 @@ > > > ngx_int_t > -ngx_regex_capture_count(ngx_regex_t *re) > -{ > - int rc, n; > - > - n = 0; > - > - rc = pcre_fullinfo(re, NULL, PCRE_INFO_CAPTURECOUNT, &n); > - > - if (rc < 0) { > - return (ngx_int_t) rc; > - } > - > - return (ngx_int_t) n; > -} > - > - > -ngx_int_t > ngx_regex_exec_array(ngx_array_t *a, ngx_str_t *s, ngx_log_t *log) > { > ngx_int_t n; -- Regards, Valery Kholodkov From mdounin at mdounin.ru Tue Dec 6 16:26:17 2011 From: mdounin at mdounin.ru (Maxim Dounin) Date: Tue, 6 Dec 2011 20:26:17 +0400 Subject: [nginx] svn commit: r4327 - trunk/src/core In-Reply-To: <17401008.5662.1323188614650.JavaMail.root@zone.mtgsy.net> References: <20111206154942.3889B3F9CAB@mail.nginx.com> <17401008.5662.1323188614650.JavaMail.root@zone.mtgsy.net> Message-ID: <20111206162617.GJ67687@mdounin.ru> Hello! On Tue, Dec 06, 2011 at 04:23:34PM +0000, Valery Kholodkov wrote: > > FYI This function is used in upload module: > > https://github.com/vkholodkov/nginx-upload-module/blob/2.2/ngx_http_upload_module.c#L2656 No, it's in #else part of the: #if defined nginx_version && nginx_version >= 8025 The prototype for the function was nuked in 0.8.25 during named captures introduction (and corresponding regexp changes). Maxim Dounin > > ----- vbart at nginx.com wrote: > > Author: vbart > > Date: 2011-12-06 15:49:40 +0000 (Tue, 06 Dec 2011) > > New Revision: 4327 > > > > Modified: > > trunk/src/core/ngx_regex.c > > Log: > > Removed unused function ngx_regex_capture_count(). > > The function has been unused since r3326. > > > > > > Modified: trunk/src/core/ngx_regex.c > > =================================================================== > > --- trunk/src/core/ngx_regex.c 2011-12-06 13:23:37 UTC (rev 4326) > > +++ trunk/src/core/ngx_regex.c 2011-12-06 15:49:40 UTC (rev 4327) > > @@ -137,23 +137,6 @@ > > > > > > ngx_int_t > > -ngx_regex_capture_count(ngx_regex_t *re) > > -{ > > - int rc, n; > > - > > - n = 0; > > - > > - rc = pcre_fullinfo(re, NULL, PCRE_INFO_CAPTURECOUNT, &n); > > - > > - if (rc < 0) { > > - return (ngx_int_t) rc; > > - } > > - > > - return (ngx_int_t) n; > > -} > > - > > - > > -ngx_int_t > > ngx_regex_exec_array(ngx_array_t *a, ngx_str_t *s, ngx_log_t *log) > > { > > ngx_int_t n; > > -- > Regards, > Valery Kholodkov > > _______________________________________________ > nginx-devel mailing list > nginx-devel at nginx.org > http://mailman.nginx.org/mailman/listinfo/nginx-devel From valery+nginxen at grid.net.ru Tue Dec 6 16:33:45 2011 From: valery+nginxen at grid.net.ru (Valery Kholodkov) Date: Tue, 6 Dec 2011 16:33:45 +0000 (GMT) Subject: [nginx] svn commit: r4327 - trunk/src/core In-Reply-To: <20111206162617.GJ67687@mdounin.ru> Message-ID: <18547827.5664.1323189225415.JavaMail.root@zone.mtgsy.net> I stand corrected. Looks like it is finally time to remove it. Keep it up. ----- Maxim Dounin wrote: > Hello! > > On Tue, Dec 06, 2011 at 04:23:34PM +0000, Valery Kholodkov wrote: > > > > > FYI This function is used in upload module: > > > > https://github.com/vkholodkov/nginx-upload-module/blob/2.2/ngx_http_upload_module.c#L2656 > > No, it's in #else part of the: > > #if defined nginx_version && nginx_version >= 8025 > > The prototype for the function was nuked in 0.8.25 during named > captures introduction (and corresponding regexp changes). > > Maxim Dounin > > > > > ----- vbart at nginx.com wrote: > > > Author: vbart > > > Date: 2011-12-06 15:49:40 +0000 (Tue, 06 Dec 2011) > > > New Revision: 4327 > > > > > > Modified: > > > trunk/src/core/ngx_regex.c > > > Log: > > > Removed unused function ngx_regex_capture_count(). > > > The function has been unused since r3326. > > > > > > > > > Modified: trunk/src/core/ngx_regex.c > > > =================================================================== > > > --- trunk/src/core/ngx_regex.c 2011-12-06 13:23:37 UTC (rev 4326) > > > +++ trunk/src/core/ngx_regex.c 2011-12-06 15:49:40 UTC (rev 4327) > > > @@ -137,23 +137,6 @@ > > > > > > > > > ngx_int_t > > > -ngx_regex_capture_count(ngx_regex_t *re) > > > -{ > > > - int rc, n; > > > - > > > - n = 0; > > > - > > > - rc = pcre_fullinfo(re, NULL, PCRE_INFO_CAPTURECOUNT, &n); > > > - > > > - if (rc < 0) { > > > - return (ngx_int_t) rc; > > > - } > > > - > > > - return (ngx_int_t) n; > > > -} > > > - > > > - > > > -ngx_int_t > > > ngx_regex_exec_array(ngx_array_t *a, ngx_str_t *s, ngx_log_t *log) > > > { > > > ngx_int_t n; > > > > -- > > Regards, > > Valery Kholodkov > > > > _______________________________________________ > > 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 -- -- Regards, Valery Kholodkov From ru at nginx.com Tue Dec 6 21:07:10 2011 From: ru at nginx.com (ru at nginx.com) Date: Tue, 6 Dec 2011 21:07:10 +0000 Subject: [nginx] svn commit: r4328 - trunk/src/http/modules Message-ID: <20111206210710.CD7FE3F9C1D@mail.nginx.com> Author: ru Date: 2011-12-06 21:07:10 +0000 (Tue, 06 Dec 2011) New Revision: 4328 Log: - Improved error message when parsing of the "buffer" parameter of the "access_log" directive fails. - Added a warning if "log_format" is used in contexts other than "http". Modified: trunk/src/http/modules/ngx_http_log_module.c Modified: trunk/src/http/modules/ngx_http_log_module.c =================================================================== --- trunk/src/http/modules/ngx_http_log_module.c 2011-12-06 15:49:40 UTC (rev 4327) +++ trunk/src/http/modules/ngx_http_log_module.c 2011-12-06 21:07:10 UTC (rev 4328) @@ -971,7 +971,7 @@ if (buf == NGX_ERROR) { ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, - "invalid parameter \"%V\"", &value[3]); + "invalid buffer value \"%V\"", &name); return NGX_CONF_ERROR; } @@ -1004,6 +1004,12 @@ ngx_uint_t i; ngx_http_log_fmt_t *fmt; + if (cf->cmd_type != NGX_HTTP_MAIN_CONF) { + ngx_conf_log_error(NGX_LOG_WARN, cf, 0, + "the \"log_format\" directive may be used " + "only on \"http\" level"); + } + value = cf->args->elts; fmt = lmcf->formats.elts; From vbart at nginx.com Fri Dec 9 13:19:57 2011 From: vbart at nginx.com (vbart at nginx.com) Date: Fri, 9 Dec 2011 13:19:57 +0000 Subject: [nginx] svn commit: r4329 - trunk/src/http Message-ID: Author: vbart Date: 2011-12-09 13:19:57 +0000 (Fri, 09 Dec 2011) New Revision: 4329 Modified: trunk/src/http/ngx_http_upstream.c trunk/src/http/ngx_http_upstream.h Log: Added the ngx_http_upstream_param_set_slot(). Modified: trunk/src/http/ngx_http_upstream.c =================================================================== --- trunk/src/http/ngx_http_upstream.c 2011-12-06 21:07:10 UTC (rev 4328) +++ trunk/src/http/ngx_http_upstream.c 2011-12-09 13:19:57 UTC (rev 4329) @@ -4444,6 +4444,50 @@ } +char * +ngx_http_upstream_param_set_slot(ngx_conf_t *cf, ngx_command_t *cmd, + void *conf) +{ + char *p = conf; + + ngx_str_t *value; + ngx_array_t **a; + ngx_http_upstream_param_t *param; + + a = (ngx_array_t **) (p + cmd->offset); + + if (*a == NULL) { + *a = ngx_array_create(cf->pool, 4, sizeof(ngx_http_upstream_param_t)); + if (*a == NULL) { + return NGX_CONF_ERROR; + } + } + + param = ngx_array_push(*a); + if (param == NULL) { + return NGX_CONF_ERROR; + } + + value = cf->args->elts; + + param->key = value[1]; + param->value = value[2]; + param->skip_empty = 0; + + if (cf->args->nelts == 4) { + if (ngx_strcmp(value[3].data, "if_not_empty") != 0) { + ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, + "invalid parameter \"%V\"", &value[3]); + return NGX_CONF_ERROR; + } + + param->skip_empty = 1; + } + + return NGX_CONF_OK; +} + + ngx_int_t ngx_http_upstream_hide_headers_hash(ngx_conf_t *cf, ngx_http_upstream_conf_t *conf, ngx_http_upstream_conf_t *prev, Modified: trunk/src/http/ngx_http_upstream.h =================================================================== --- trunk/src/http/ngx_http_upstream.h 2011-12-06 21:07:10 UTC (rev 4328) +++ trunk/src/http/ngx_http_upstream.h 2011-12-09 13:19:57 UTC (rev 4329) @@ -328,6 +328,13 @@ } ngx_http_upstream_next_t; +typedef struct { + ngx_str_t key; + ngx_str_t value; + ngx_uint_t skip_empty; +} ngx_http_upstream_param_t; + + ngx_int_t ngx_http_upstream_header_variable(ngx_http_request_t *r, ngx_http_variable_value_t *v, uintptr_t data); @@ -337,6 +344,8 @@ ngx_url_t *u, ngx_uint_t flags); char *ngx_http_upstream_bind_set_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); +char *ngx_http_upstream_param_set_slot(ngx_conf_t *cf, ngx_command_t *cmd, + void *conf); ngx_int_t ngx_http_upstream_hide_headers_hash(ngx_conf_t *cf, ngx_http_upstream_conf_t *conf, ngx_http_upstream_conf_t *prev, ngx_str_t *default_hide_headers, ngx_hash_init_t *hash); From vbart at nginx.com Fri Dec 9 13:32:51 2011 From: vbart at nginx.com (vbart at nginx.com) Date: Fri, 9 Dec 2011 13:32:51 +0000 Subject: [nginx] svn commit: r4330 - trunk/src/http/modules Message-ID: Author: vbart Date: 2011-12-09 13:32:51 +0000 (Fri, 09 Dec 2011) New Revision: 4330 Modified: trunk/src/http/modules/ngx_http_fastcgi_module.c Log: FastCGI: added "if_not_empty" flag support to the "fastcgi_param" directive. Modified: trunk/src/http/modules/ngx_http_fastcgi_module.c =================================================================== --- trunk/src/http/modules/ngx_http_fastcgi_module.c 2011-12-09 13:19:57 UTC (rev 4329) +++ trunk/src/http/modules/ngx_http_fastcgi_module.c 2011-12-09 13:32:51 UTC (rev 4330) @@ -411,8 +411,8 @@ &ngx_http_fastcgi_next_upstream_masks }, { ngx_string("fastcgi_param"), - NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE2, - ngx_conf_set_keyval_slot, + NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE23, + ngx_http_upstream_param_set_slot, NGX_HTTP_LOC_CONF_OFFSET, offsetof(ngx_http_fastcgi_loc_conf_t, params_source), NULL }, @@ -708,7 +708,7 @@ u_char ch, *pos, *lowcase_key; size_t size, len, key_len, val_len, padding, allocated; - ngx_uint_t i, n, next, hash, header_params; + ngx_uint_t i, n, next, hash, skip_empty, header_params; ngx_buf_t *b; ngx_chain_t *cl, *body; ngx_list_part_t *part; @@ -739,11 +739,18 @@ lcode = *(ngx_http_script_len_code_pt *) le.ip; key_len = lcode(&le); + lcode = *(ngx_http_script_len_code_pt *) le.ip; + skip_empty = lcode(&le); + for (val_len = 0; *(uintptr_t *) le.ip; val_len += lcode(&le)) { lcode = *(ngx_http_script_len_code_pt *) le.ip; } le.ip += sizeof(uintptr_t); + if (skip_empty && val_len == 0) { + continue; + } + len += 1 + key_len + ((val_len > 127) ? 4 : 1) + val_len; } } @@ -893,11 +900,28 @@ lcode = *(ngx_http_script_len_code_pt *) le.ip; key_len = (u_char) lcode(&le); + lcode = *(ngx_http_script_len_code_pt *) le.ip; + skip_empty = lcode(&le); + for (val_len = 0; *(uintptr_t *) le.ip; val_len += lcode(&le)) { lcode = *(ngx_http_script_len_code_pt *) le.ip; } le.ip += sizeof(uintptr_t); + if (skip_empty && val_len == 0) { + e.skip = 1; + + while (*(uintptr_t *) e.ip) { + code = *(ngx_http_script_code_pt *) e.ip; + code((ngx_http_script_engine_t *) &e); + } + e.ip += sizeof(uintptr_t); + + e.skip = 0; + + continue; + } + *e.pos++ = (u_char) key_len; if (val_len > 127) { @@ -2370,9 +2394,9 @@ #if (NGX_HTTP_CACHE) ngx_array_t params_merged; #endif - ngx_keyval_t *src; ngx_hash_key_t *hk; ngx_hash_init_t hash; + ngx_http_upstream_param_t *src; ngx_http_script_compile_t sc; ngx_http_script_copy_code_t *copy; @@ -2433,9 +2457,11 @@ #if (NGX_HTTP_CACHE) if (conf->upstream.cache) { - ngx_keyval_t *h, *s; + ngx_keyval_t *h; + ngx_http_upstream_param_t *s; - if (ngx_array_init(¶ms_merged, cf->temp_pool, 4, sizeof(ngx_keyval_t)) + if (ngx_array_init(¶ms_merged, cf->temp_pool, 4, + sizeof(ngx_http_upstream_param_t)) != NGX_OK) { return NGX_ERROR; @@ -2469,7 +2495,9 @@ return NGX_ERROR; } - *s = *h; + s->key = h->key; + s->value = h->value; + s->skip_empty = 0; next: @@ -2511,7 +2539,16 @@ copy->code = (ngx_http_script_code_pt) ngx_http_script_copy_len_code; copy->len = src[i].key.len; + copy = ngx_array_push_n(conf->params_len, + sizeof(ngx_http_script_copy_code_t)); + if (copy == NULL) { + return NGX_ERROR; + } + copy->code = (ngx_http_script_code_pt) ngx_http_script_copy_len_code; + copy->len = src[i].skip_empty; + + size = (sizeof(ngx_http_script_copy_code_t) + src[i].key.len + sizeof(uintptr_t) - 1) & ~(sizeof(uintptr_t) - 1); From vbart at nginx.com Fri Dec 9 13:47:04 2011 From: vbart at nginx.com (vbart at nginx.com) Date: Fri, 9 Dec 2011 13:47:04 +0000 Subject: [nginx] svn commit: r4331 - trunk/src/http/modules Message-ID: Author: vbart Date: 2011-12-09 13:47:04 +0000 (Fri, 09 Dec 2011) New Revision: 4331 Modified: trunk/src/http/modules/ngx_http_uwsgi_module.c Log: uWSGI: added "if_not_empty" flag support to the "uwsgi_param" directive. Modified: trunk/src/http/modules/ngx_http_uwsgi_module.c =================================================================== --- trunk/src/http/modules/ngx_http_uwsgi_module.c 2011-12-09 13:32:51 UTC (rev 4330) +++ trunk/src/http/modules/ngx_http_uwsgi_module.c 2011-12-09 13:47:04 UTC (rev 4331) @@ -305,8 +305,8 @@ &ngx_http_uwsgi_next_upstream_masks }, { ngx_string("uwsgi_param"), - NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE2, - ngx_conf_set_keyval_slot, + NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE23, + ngx_http_upstream_param_set_slot, NGX_HTTP_LOC_CONF_OFFSET, offsetof(ngx_http_uwsgi_loc_conf_t, params_source), NULL }, @@ -553,7 +553,7 @@ { u_char ch, *lowcase_key; size_t key_len, val_len, len, allocated; - ngx_uint_t i, n, hash, header_params; + ngx_uint_t i, n, hash, skip_empty, header_params; ngx_buf_t *b; ngx_chain_t *cl, *body; ngx_list_part_t *part; @@ -583,11 +583,18 @@ lcode = *(ngx_http_script_len_code_pt *) le.ip; key_len = lcode(&le); + lcode = *(ngx_http_script_len_code_pt *) le.ip; + skip_empty = lcode(&le); + for (val_len = 0; *(uintptr_t *) le.ip; val_len += lcode (&le)) { lcode = *(ngx_http_script_len_code_pt *) le.ip; } le.ip += sizeof(uintptr_t); + if (skip_empty && val_len == 0) { + continue; + } + len += 2 + key_len + 2 + val_len; } } @@ -706,11 +713,28 @@ lcode = *(ngx_http_script_len_code_pt *) le.ip; key_len = (u_char) lcode (&le); + lcode = *(ngx_http_script_len_code_pt *) le.ip; + skip_empty = lcode(&le); + for (val_len = 0; *(uintptr_t *) le.ip; val_len += lcode(&le)) { lcode = *(ngx_http_script_len_code_pt *) le.ip; } le.ip += sizeof(uintptr_t); + if (skip_empty && val_len == 0) { + e.skip = 1; + + while (*(uintptr_t *) e.ip) { + code = *(ngx_http_script_code_pt *) e.ip; + code((ngx_http_script_engine_t *) &e); + } + e.ip += sizeof(uintptr_t); + + e.skip = 0; + + continue; + } + *e.pos++ = (u_char) (key_len & 0xff); *e.pos++ = (u_char) ((key_len >> 8) & 0xff); @@ -1379,9 +1403,9 @@ #if (NGX_HTTP_CACHE) ngx_array_t params_merged; #endif - ngx_keyval_t *src; ngx_hash_key_t *hk; ngx_hash_init_t hash; + ngx_http_upstream_param_t *src; ngx_http_script_compile_t sc; ngx_http_script_copy_code_t *copy; @@ -1442,9 +1466,11 @@ #if (NGX_HTTP_CACHE) if (conf->upstream.cache) { - ngx_keyval_t *h, *s; + ngx_keyval_t *h; + ngx_http_upstream_param_t *s; - if (ngx_array_init(¶ms_merged, cf->temp_pool, 4, sizeof(ngx_keyval_t)) + if (ngx_array_init(¶ms_merged, cf->temp_pool, 4, + sizeof(ngx_http_upstream_param_t)) != NGX_OK) { return NGX_ERROR; @@ -1478,7 +1504,9 @@ return NGX_ERROR; } - *s = *h; + s->key = h->key; + s->value = h->value; + s->skip_empty = 0; next: @@ -1520,7 +1548,16 @@ copy->code = (ngx_http_script_code_pt) ngx_http_script_copy_len_code; copy->len = src[i].key.len; + copy = ngx_array_push_n(conf->params_len, + sizeof(ngx_http_script_copy_code_t)); + if (copy == NULL) { + return NGX_ERROR; + } + copy->code = (ngx_http_script_code_pt) ngx_http_script_copy_len_code; + copy->len = src[i].skip_empty; + + size = (sizeof(ngx_http_script_copy_code_t) + src[i].key.len + sizeof(uintptr_t) - 1) & ~(sizeof(uintptr_t) - 1); From mdounin at mdounin.ru Fri Dec 9 13:54:46 2011 From: mdounin at mdounin.ru (Maxim Dounin) Date: Fri, 9 Dec 2011 17:54:46 +0400 Subject: [nginx] svn commit: r4331 - trunk/src/http/modules In-Reply-To: <20111209134706.720233F9C68@mail.nginx.com> References: <20111209134706.720233F9C68@mail.nginx.com> Message-ID: <20111209135446.GB67687@mdounin.ru> Hello! On Fri, Dec 09, 2011 at 01:47:04PM +0000, vbart at nginx.com wrote: > Author: vbart > Date: 2011-12-09 13:47:04 +0000 (Fri, 09 Dec 2011) > New Revision: 4331 > > Modified: > trunk/src/http/modules/ngx_http_uwsgi_module.c > Log: > uWSGI: added "if_not_empty" flag support to the "uwsgi_param" directive. "uWSGI" - ??? ???????? ???????, ???????? ?????????? "uwsgi" (all lowercase). Maxim Dounin From mdounin at mdounin.ru Fri Dec 9 13:56:10 2011 From: mdounin at mdounin.ru (Maxim Dounin) Date: Fri, 9 Dec 2011 17:56:10 +0400 Subject: [nginx] svn commit: r4331 - trunk/src/http/modules In-Reply-To: <20111209135446.GB67687@mdounin.ru> References: <20111209134706.720233F9C68@mail.nginx.com> <20111209135446.GB67687@mdounin.ru> Message-ID: <20111209135610.GC67687@mdounin.ru> Hello! On Fri, Dec 09, 2011 at 05:54:46PM +0400, Maxim Dounin wrote: > Hello! > > On Fri, Dec 09, 2011 at 01:47:04PM +0000, vbart at nginx.com wrote: > > > Author: vbart > > Date: 2011-12-09 13:47:04 +0000 (Fri, 09 Dec 2011) > > New Revision: 4331 > > > > Modified: > > trunk/src/http/modules/ngx_http_uwsgi_module.c > > Log: > > uWSGI: added "if_not_empty" flag support to the "uwsgi_param" directive. > > "uWSGI" - ??? ???????? ???????, ???????? ?????????? "uwsgi" (all > lowercase). Oops, sorry, this should be in english: "uWSGI" is a server name, protocol is named as "uwsgi" (all lowercase). Maxim Dounin From vbart at nginx.com Fri Dec 9 14:03:08 2011 From: vbart at nginx.com (vbart at nginx.com) Date: Fri, 9 Dec 2011 14:03:08 +0000 Subject: [nginx] svn commit: r4332 - trunk/src/http/modules Message-ID: Author: vbart Date: 2011-12-09 14:03:06 +0000 (Fri, 09 Dec 2011) New Revision: 4332 Modified: trunk/src/http/modules/ngx_http_scgi_module.c Log: SCGI: added "if_not_empty" flag support to the "scgi_param" directive. Modified: trunk/src/http/modules/ngx_http_scgi_module.c =================================================================== --- trunk/src/http/modules/ngx_http_scgi_module.c 2011-12-09 13:47:04 UTC (rev 4331) +++ trunk/src/http/modules/ngx_http_scgi_module.c 2011-12-09 14:03:06 UTC (rev 4332) @@ -278,8 +278,8 @@ &ngx_http_scgi_next_upstream_masks }, { ngx_string("scgi_param"), - NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE2, - ngx_conf_set_keyval_slot, + NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE23, + ngx_http_upstream_param_set_slot, NGX_HTTP_LOC_CONF_OFFSET, offsetof(ngx_http_scgi_loc_conf_t, params_source), NULL }, @@ -519,10 +519,10 @@ ngx_http_scgi_create_request(ngx_http_request_t *r) { u_char ch, *key, *val, *lowcase_key; - size_t len, allocated; + size_t len, key_len, val_len, allocated; ngx_buf_t *b; ngx_str_t *content_length; - ngx_uint_t i, n, hash, header_params; + ngx_uint_t i, n, hash, skip_empty, header_params; ngx_chain_t *cl, *body; ngx_list_part_t *part; ngx_table_elt_t *header, **ignored; @@ -554,15 +554,21 @@ while (*(uintptr_t *) le.ip) { lcode = *(ngx_http_script_len_code_pt *) le.ip; - len += lcode(&le); + key_len = lcode(&le); - while (*(uintptr_t *) le.ip) { + lcode = *(ngx_http_script_len_code_pt *) le.ip; + skip_empty = lcode(&le); + + for (val_len = 0; *(uintptr_t *) le.ip; val_len += lcode(&le)) { lcode = *(ngx_http_script_len_code_pt *) le.ip; - len += lcode(&le); } - len++; + le.ip += sizeof(uintptr_t); - le.ip += sizeof(uintptr_t); + if (skip_empty && val_len == 0) { + continue; + } + + len += key_len + val_len + 1; } } @@ -665,8 +671,35 @@ e.request = r; e.flushed = 1; - while (*(uintptr_t *) e.ip) { + le.ip = scf->params_len->elts; + while (*(uintptr_t *) le.ip) { + + lcode = *(ngx_http_script_len_code_pt *) le.ip; + lcode(&le); /* key length */ + + lcode = *(ngx_http_script_len_code_pt *) le.ip; + skip_empty = lcode(&le); + + for (val_len = 0; *(uintptr_t *) le.ip; val_len += lcode(&le)) { + lcode = *(ngx_http_script_len_code_pt *) le.ip; + } + le.ip += sizeof(uintptr_t); + + if (skip_empty && val_len == 0) { + e.skip = 1; + + while (*(uintptr_t *) e.ip) { + code = *(ngx_http_script_code_pt *) e.ip; + code((ngx_http_script_engine_t *) &e); + } + e.ip += sizeof(uintptr_t); + + e.skip = 0; + + continue; + } + #if (NGX_DEBUG) key = e.pos; #endif @@ -1323,9 +1356,9 @@ #if (NGX_HTTP_CACHE) ngx_array_t params_merged; #endif - ngx_keyval_t *src; ngx_hash_key_t *hk; ngx_hash_init_t hash; + ngx_http_upstream_param_t *src; ngx_http_script_compile_t sc; ngx_http_script_copy_code_t *copy; @@ -1386,9 +1419,11 @@ #if (NGX_HTTP_CACHE) if (conf->upstream.cache) { - ngx_keyval_t *h, *s; + ngx_keyval_t *h; + ngx_http_upstream_param_t *s; - if (ngx_array_init(¶ms_merged, cf->temp_pool, 4, sizeof(ngx_keyval_t)) + if (ngx_array_init(¶ms_merged, cf->temp_pool, 4, + sizeof(ngx_http_upstream_param_t)) != NGX_OK) { return NGX_ERROR; @@ -1422,7 +1457,9 @@ return NGX_ERROR; } - *s = *h; + s->key = h->key; + s->value = h->value; + s->skip_empty = 0; next: @@ -1464,7 +1501,16 @@ copy->code = (ngx_http_script_code_pt) ngx_http_script_copy_len_code; copy->len = src[i].key.len + 1; + copy = ngx_array_push_n(conf->params_len, + sizeof(ngx_http_script_copy_code_t)); + if (copy == NULL) { + return NGX_ERROR; + } + copy->code = (ngx_http_script_code_pt) ngx_http_script_copy_len_code; + copy->len = src[i].skip_empty; + + size = (sizeof(ngx_http_script_copy_code_t) + src[i].key.len + 1 + sizeof(uintptr_t) - 1) & ~(sizeof(uintptr_t) - 1); From ne at vbart.ru Fri Dec 9 14:08:32 2011 From: ne at vbart.ru (Valentin V. Bartenev) Date: Fri, 9 Dec 2011 18:08:32 +0400 Subject: [nginx] svn commit: r4331 - trunk/src/http/modules In-Reply-To: <20111209135610.GC67687@mdounin.ru> References: <20111209134706.720233F9C68@mail.nginx.com> <20111209135446.GB67687@mdounin.ru> <20111209135610.GC67687@mdounin.ru> Message-ID: <201112091808.32669.ne@vbart.ru> On Friday 09 December 2011 17:56:10 Maxim Dounin wrote: [...] > > "uWSGI" is a server name, protocol is named as "uwsgi" (all > lowercase). > Fixed. Thanks. wbr, Valentin V. Bartenev From vbart at nginx.com Fri Dec 9 14:38:11 2011 From: vbart at nginx.com (vbart at nginx.com) Date: Fri, 9 Dec 2011 14:38:11 +0000 Subject: [nginx] svn commit: r4333 - trunk/src/http Message-ID: Author: vbart Date: 2011-12-09 14:38:11 +0000 (Fri, 09 Dec 2011) New Revision: 4333 Modified: trunk/src/http/ngx_http_variables.c Log: Added the $https variable. Modified: trunk/src/http/ngx_http_variables.c =================================================================== --- trunk/src/http/ngx_http_variables.c 2011-12-09 14:03:06 UTC (rev 4332) +++ trunk/src/http/ngx_http_variables.c 2011-12-09 14:38:11 UTC (rev 4333) @@ -48,6 +48,8 @@ ngx_http_variable_value_t *v, uintptr_t data); static ngx_int_t ngx_http_variable_scheme(ngx_http_request_t *r, ngx_http_variable_value_t *v, uintptr_t data); +static ngx_int_t ngx_http_variable_https(ngx_http_request_t *r, + ngx_http_variable_value_t *v, uintptr_t data); static ngx_int_t ngx_http_variable_is_args(ngx_http_request_t *r, ngx_http_variable_value_t *v, uintptr_t data); static ngx_int_t ngx_http_variable_document_root(ngx_http_request_t *r, @@ -157,6 +159,8 @@ { ngx_string("scheme"), NULL, ngx_http_variable_scheme, 0, 0, 0 }, + { ngx_string("https"), NULL, ngx_http_variable_https, 0, 0, 0 }, + { ngx_string("request_uri"), NULL, ngx_http_variable_request, offsetof(ngx_http_request_t, unparsed_uri), 0, 0 }, @@ -1091,6 +1095,30 @@ static ngx_int_t +ngx_http_variable_https(ngx_http_request_t *r, + ngx_http_variable_value_t *v, uintptr_t data) +{ +#if (NGX_HTTP_SSL) + + if (r->connection->ssl) { + v->len = sizeof("on") - 1; + v->valid = 1; + v->no_cacheable = 0; + v->not_found = 0; + v->data = (u_char *) "on"; + + return NGX_OK; + } + +#endif + + *v = ngx_http_variable_null_value; + + return NGX_OK; +} + + +static ngx_int_t ngx_http_variable_is_args(ngx_http_request_t *r, ngx_http_variable_value_t *v, uintptr_t data) { From vbart at nginx.com Fri Dec 9 15:38:27 2011 From: vbart at nginx.com (vbart at nginx.com) Date: Fri, 9 Dec 2011 15:38:27 +0000 Subject: [nginx] svn commit: r4334 - trunk/conf Message-ID: Author: vbart Date: 2011-12-09 15:38:26 +0000 (Fri, 09 Dec 2011) New Revision: 4334 Modified: trunk/conf/fastcgi_params trunk/conf/scgi_params trunk/conf/uwsgi_params Log: Added HTTPS param with Apache-like behaviour to fastcgi/scgi/uwsgi_params (fixes #38). Modified: trunk/conf/fastcgi_params =================================================================== --- trunk/conf/fastcgi_params 2011-12-09 14:38:11 UTC (rev 4333) +++ trunk/conf/fastcgi_params 2011-12-09 15:38:26 UTC (rev 4334) @@ -9,6 +9,7 @@ fastcgi_param DOCUMENT_URI $document_uri; fastcgi_param DOCUMENT_ROOT $document_root; fastcgi_param SERVER_PROTOCOL $server_protocol; +fastcgi_param HTTPS $https if_not_empty; fastcgi_param GATEWAY_INTERFACE CGI/1.1; fastcgi_param SERVER_SOFTWARE nginx/$nginx_version; Modified: trunk/conf/scgi_params =================================================================== --- trunk/conf/scgi_params 2011-12-09 14:38:11 UTC (rev 4333) +++ trunk/conf/scgi_params 2011-12-09 15:38:26 UTC (rev 4334) @@ -8,6 +8,7 @@ scgi_param DOCUMENT_ROOT $document_root; scgi_param SCGI 1; scgi_param SERVER_PROTOCOL $server_protocol; +scgi_param HTTPS $https if_not_empty; scgi_param REMOTE_ADDR $remote_addr; scgi_param REMOTE_PORT $remote_port; Modified: trunk/conf/uwsgi_params =================================================================== --- trunk/conf/uwsgi_params 2011-12-09 14:38:11 UTC (rev 4333) +++ trunk/conf/uwsgi_params 2011-12-09 15:38:26 UTC (rev 4334) @@ -8,6 +8,7 @@ uwsgi_param PATH_INFO $document_uri; uwsgi_param DOCUMENT_ROOT $document_root; uwsgi_param SERVER_PROTOCOL $server_protocol; +uwsgi_param HTTPS $https if_not_empty; uwsgi_param REMOTE_ADDR $remote_addr; uwsgi_param REMOTE_PORT $remote_port; From vbart at nginx.com Fri Dec 9 16:17:12 2011 From: vbart at nginx.com (vbart at nginx.com) Date: Fri, 9 Dec 2011 16:17:12 +0000 Subject: [nginx] svn commit: r4335 - trunk/src/http Message-ID: Author: vbart Date: 2011-12-09 16:17:12 +0000 (Fri, 09 Dec 2011) New Revision: 4335 Modified: trunk/src/http/ngx_http_variables.c Log: Fixed: some of $sent_http_* variables may contain header entries that actually haven't been sent to a client. The ngx_http_variable_headers() and ngx_http_variable_unknown_header() functions did not ignore response header entries with zero "hash" field. Thanks to Yichun Zhang (agentzh). Modified: trunk/src/http/ngx_http_variables.c =================================================================== --- trunk/src/http/ngx_http_variables.c 2011-12-09 15:38:26 UTC (rev 4334) +++ trunk/src/http/ngx_http_variables.c 2011-12-09 16:17:12 UTC (rev 4335) @@ -644,8 +644,8 @@ ngx_http_variable_headers(ngx_http_request_t *r, ngx_http_variable_value_t *v, uintptr_t data) { - ssize_t len; - u_char *p; + size_t len; + u_char *p, *end; ngx_uint_t i, n; ngx_array_t *a; ngx_table_elt_t **h; @@ -653,18 +653,30 @@ a = (ngx_array_t *) ((char *) r + data); n = a->nelts; + h = a->elts; - if (n == 0) { + len = 0; + + for (i = 0; i < n; i++) { + + if (h[i]->hash == 0) { + continue; + } + + len += h[i]->value.len + sizeof("; ") - 1; + } + + if (len == 0) { v->not_found = 1; return NGX_OK; } + len -= sizeof("; ") - 1; + v->valid = 1; v->no_cacheable = 0; v->not_found = 0; - h = a->elts; - if (n == 1) { v->len = (*h)->value.len; v->data = (*h)->value.data; @@ -672,12 +684,6 @@ return NGX_OK; } - len = - (ssize_t) (sizeof("; ") - 1); - - for (i = 0; i < n; i++) { - len += h[i]->value.len + sizeof("; ") - 1; - } - p = ngx_pnalloc(r->pool, len); if (p == NULL) { return NGX_ERROR; @@ -686,10 +692,17 @@ v->len = len; v->data = p; + end = p + len; + for (i = 0; /* void */ ; i++) { + + if (h[i]->hash == 0) { + continue; + } + p = ngx_copy(p, h[i]->value.data, h[i]->value.len); - if (i == n - 1) { + if (p == end) { break; } @@ -742,6 +755,10 @@ i = 0; } + if (header[i].hash == 0) { + continue; + } + for (n = 0; n + prefix < var->len && n < header[i].key.len; n++) { ch = header[i].key.data[n]; From mdounin at mdounin.ru Sun Dec 11 16:01:22 2011 From: mdounin at mdounin.ru (Maxim Dounin) Date: Sun, 11 Dec 2011 19:01:22 +0300 Subject: [PATCH 0 of 5] cache patches Message-ID: Hello! Here are patch series which addresses several issues in cache (first 3 patches), and adds cache lock support (last 2). I'm planning to commit first 3 patches shortly, cache lock patches will remain experimental for a while. Review and testing appreciated. Maxim Dounin From mdounin at mdounin.ru Sun Dec 11 16:01:23 2011 From: mdounin at mdounin.ru (Maxim Dounin) Date: Sun, 11 Dec 2011 19:01:23 +0300 Subject: [PATCH 1 of 5] Cache: obsolete code removed In-Reply-To: References: Message-ID: <64e354fb95e4ea72f479.1323615683@vm-bsd.mdounin.ru> # HG changeset patch # User Maxim Dounin # Date 1323366109 -10800 # Node ID 64e354fb95e4ea72f479213ee4e8b4274413ce4f # Parent 8c96af2112c18a20e6206edb1e71998358ceeccb Cache: obsolete code removed. The ngx_http_cache() and ngx_http_no_cache_set_slot() functions were replaced by ngx_http_test_predicates() and ngx_http_set_predicate_slot() in 0.8.46 and no longer used since then. diff --git a/src/http/ngx_http_file_cache.c b/src/http/ngx_http_file_cache.c --- a/src/http/ngx_http_file_cache.c +++ b/src/http/ngx_http_file_cache.c @@ -1752,69 +1752,3 @@ ngx_http_file_cache_valid_set_slot(ngx_c return NGX_CONF_OK; } - - -ngx_int_t -ngx_http_cache(ngx_http_request_t *r, ngx_array_t *no_cache) -{ - ngx_str_t val; - ngx_uint_t i; - ngx_http_complex_value_t *cv; - - cv = no_cache->elts; - - for (i = 0; i < no_cache->nelts; i++) { - if (ngx_http_complex_value(r, &cv[i], &val) != NGX_OK) { - return NGX_ERROR; - } - - if (val.len && val.data[0] != '0') { - return NGX_DECLINED; - } - } - - return NGX_OK; -} - - -char * -ngx_http_no_cache_set_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) -{ - char *p = conf; - - ngx_str_t *value; - ngx_uint_t i; - ngx_array_t **a; - ngx_http_complex_value_t *cv; - ngx_http_compile_complex_value_t ccv; - - a = (ngx_array_t **) (p + cmd->offset); - - if (*a == NGX_CONF_UNSET_PTR) { - *a = ngx_array_create(cf->pool, 1, sizeof(ngx_http_complex_value_t)); - if (*a == NULL) { - return NGX_CONF_ERROR; - } - } - - value = cf->args->elts; - - for (i = 1; i < cf->args->nelts; i++) { - cv = ngx_array_push(*a); - if (cv == NULL) { - return NGX_CONF_ERROR; - } - - ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t)); - - ccv.cf = cf; - ccv.value = &value[i]; - ccv.complex_value = cv; - - if (ngx_http_compile_complex_value(&ccv) != NGX_OK) { - return NGX_CONF_ERROR; - } - } - - return NGX_CONF_OK; -} From mdounin at mdounin.ru Sun Dec 11 16:01:24 2011 From: mdounin at mdounin.ru (Maxim Dounin) Date: Sun, 11 Dec 2011 19:01:24 +0300 Subject: [PATCH 2 of 5] Cache: handling of cache files with long headers In-Reply-To: References: Message-ID: # HG changeset patch # User Maxim Dounin # Date 1323366111 -10800 # Node ID a013347f89334734a7a0f65031895be52d87a5a0 # Parent 64e354fb95e4ea72f479213ee4e8b4274413ce4f Cache: handling of cache files with long headers. There are two possible situations which can lead to this: response was cached with bigger proxy_buffer_size value (and nginx was restared since then, i.e. shared memory zone content was lost), or due to the race in the cache update code (see [1]) we've end up with fcn->body_start from a different response stored in shared memory zone. [1] http://mailman.nginx.org/pipermail/nginx-devel/2011-September/001287.html diff --git a/src/http/ngx_http_file_cache.c b/src/http/ngx_http_file_cache.c --- a/src/http/ngx_http_file_cache.c +++ b/src/http/ngx_http_file_cache.c @@ -386,6 +386,13 @@ ngx_http_file_cache_read(ngx_http_reques return NGX_DECLINED; } + if (h->body_start > c->body_start) { + ngx_log_error(NGX_LOG_CRIT, r->connection->log, 0, + "cache file \"%s\" has too long header", + c->file.name.data); + return NGX_DECLINED; + } + c->buf->last += n; c->valid_sec = h->valid_sec; From mdounin at mdounin.ru Sun Dec 11 16:01:25 2011 From: mdounin at mdounin.ru (Maxim Dounin) Date: Sun, 11 Dec 2011 19:01:25 +0300 Subject: [PATCH 3 of 5] Cache: only complain on long locked entries In-Reply-To: References: Message-ID: <71a5724d332ff7cc5935.1323615685@vm-bsd.mdounin.ru> # HG changeset patch # User Maxim Dounin # Date 1323615350 -10800 # Node ID 71a5724d332ff7cc5935e0f6c87e8a0036f3e682 # Parent a013347f89334734a7a0f65031895be52d87a5a0 Cache: only complain on long locked entries. There have been multiple reports of cases where a real locked entry was removed, resulting in a segmentation fault later in a worker which locked the entry. It looks like default inactive timeout isn't enough in real life. For now just ignore such locked entries, and move them to the top of the inactive queue to allow processing of other entries. diff --git a/src/http/ngx_http_file_cache.c b/src/http/ngx_http_file_cache.c --- a/src/http/ngx_http_file_cache.c +++ b/src/http/ngx_http_file_cache.c @@ -1113,12 +1113,12 @@ ngx_http_file_cache_expire(ngx_http_file /* * abnormally exited workers may leave locked cache entries, * and although it may be safe to remove them completely, - * we prefer to remove them from inactive queue and rbtree - * only, and to allow other leaks + * we prefer to just move them to the top of the inactive queue */ ngx_queue_remove(q); - ngx_rbtree_delete(&cache->sh->rbtree, &fcn->node); + fcn->expire = ngx_time() + cache->inactive; + ngx_queue_insert_head(&cache->sh->queue, &fcn->queue); ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, 0, "ignore long locked inactive cache entry %*s, count:%d", From mdounin at mdounin.ru Sun Dec 11 16:01:26 2011 From: mdounin at mdounin.ru (Maxim Dounin) Date: Sun, 11 Dec 2011 19:01:26 +0300 Subject: [PATCH 4 of 5] Cache locks initial implementation In-Reply-To: References: Message-ID: <9412a31366125763912d.1323615686@vm-bsd.mdounin.ru> # HG changeset patch # User Maxim Dounin # Date 1323615373 -10800 # Node ID 9412a31366125763912dff5d592d539eb6102139 # Parent 71a5724d332ff7cc5935e0f6c87e8a0036f3e682 Cache locks initial implementation. New directives: proxy_cache_lock on/off, proxy_cache_lock_timeout. With proxy_cache_lock set to on, only one request will be allowed to go to upstream, others will wait for up to proxy_cache_lock_timeout. Waiting requests are re-check if they have cache file ready (or are allowed to run) every 500ms. Note: we intentionally don't intercept NGX_DECLINED possibly returned by ngx_http_file_cache_read(). This needs more work (possibly safe, but needs further investigation). Anyway, it's exceptional situation. Note: probably there should be a way to disable caching of responses if there is already one request fetching resource to cache (without waiting at all). Two possible ways include another cache lock option ("no_cache") or using proxy_no_cache with some supplied variable. Note: probably there should be a way to lock updating requests as well. For now only "proxy_cache_use_stale updating" is available. diff --git a/src/http/modules/ngx_http_proxy_module.c b/src/http/modules/ngx_http_proxy_module.c --- a/src/http/modules/ngx_http_proxy_module.c +++ b/src/http/modules/ngx_http_proxy_module.c @@ -405,6 +405,20 @@ static ngx_command_t ngx_http_proxy_com offsetof(ngx_http_proxy_loc_conf_t, upstream.cache_methods), &ngx_http_upstream_cache_method_mask }, + { ngx_string("proxy_cache_lock"), + 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_proxy_loc_conf_t, upstream.cache_lock), + NULL }, + + { ngx_string("proxy_cache_lock_timeout"), + NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, + ngx_conf_set_msec_slot, + NGX_HTTP_LOC_CONF_OFFSET, + offsetof(ngx_http_proxy_loc_conf_t, upstream.cache_lock_timeout), + NULL }, + #endif { ngx_string("proxy_temp_path"), @@ -2459,6 +2473,8 @@ ngx_http_proxy_create_loc_conf(ngx_conf_ conf->upstream.cache_bypass = NGX_CONF_UNSET_PTR; conf->upstream.no_cache = NGX_CONF_UNSET_PTR; conf->upstream.cache_valid = NGX_CONF_UNSET_PTR; + conf->upstream.cache_lock = NGX_CONF_UNSET; + conf->upstream.cache_lock_timeout = NGX_CONF_UNSET_MSEC; #endif conf->upstream.hide_headers = NGX_CONF_UNSET_PTR; @@ -2705,6 +2721,12 @@ ngx_http_proxy_merge_loc_conf(ngx_conf_t conf->cache_key = prev->cache_key; } + ngx_conf_merge_value(conf->upstream.cache_lock, + prev->upstream.cache_lock, 0); + + ngx_conf_merge_msec_value(conf->upstream.cache_lock_timeout, + prev->upstream.cache_lock_timeout, 5000); + #endif if (conf->method.len == 0) { diff --git a/src/http/ngx_http_cache.h b/src/http/ngx_http_cache.h --- a/src/http/ngx_http_cache.h +++ b/src/http/ngx_http_cache.h @@ -79,6 +79,14 @@ struct ngx_http_cache_s { ngx_http_file_cache_t *file_cache; ngx_http_file_cache_node_t *node; + ngx_msec_t lock_timeout; + ngx_msec_t wait_time; + + ngx_event_t wait_event; + + unsigned lock:1; + unsigned waiting:1; + unsigned updated:1; unsigned updating:1; unsigned exists:1; diff --git a/src/http/ngx_http_file_cache.c b/src/http/ngx_http_file_cache.c --- a/src/http/ngx_http_file_cache.c +++ b/src/http/ngx_http_file_cache.c @@ -10,6 +10,9 @@ #include +static ngx_int_t ngx_http_file_cache_lock(ngx_http_request_t *r, + ngx_http_cache_t *c); +static void ngx_http_file_cache_lock_wait_handler(ngx_event_t *ev); static ngx_int_t ngx_http_file_cache_read(ngx_http_request_t *r, ngx_http_cache_t *c); static ssize_t ngx_http_file_cache_aio_read(ngx_http_request_t *r, @@ -181,13 +184,13 @@ ngx_http_file_cache_create(ngx_http_requ return NGX_ERROR; } + cln->handler = ngx_http_file_cache_cleanup; + cln->data = c; + if (ngx_http_file_cache_exists(cache, c) == NGX_ERROR) { return NGX_ERROR; } - cln->handler = ngx_http_file_cache_cleanup; - cln->data = c; - if (ngx_http_file_cache_name(r, cache->path) != NGX_OK) { return NGX_ERROR; } @@ -244,15 +247,24 @@ ngx_http_file_cache_open(ngx_http_reques c = r->cache; + if (c->waiting) { + return NGX_AGAIN; + } + if (c->buf) { return ngx_http_file_cache_read(r, c); } cache = c->file_cache; - cln = ngx_pool_cleanup_add(r->pool, 0); - if (cln == NULL) { - return NGX_ERROR; + if (c->node == NULL) { + cln = ngx_pool_cleanup_add(r->pool, 0); + if (cln == NULL) { + return NGX_ERROR; + } + + cln->handler = ngx_http_file_cache_cleanup; + cln->data = c; } rc = ngx_http_file_cache_exists(cache, c); @@ -264,9 +276,6 @@ ngx_http_file_cache_open(ngx_http_reques return rc; } - cln->handler = ngx_http_file_cache_cleanup; - cln->data = c; - if (rc == NGX_AGAIN) { return NGX_HTTP_CACHE_SCARCE; } @@ -306,7 +315,7 @@ ngx_http_file_cache_open(ngx_http_reques } if (!test) { - return NGX_DECLINED; + goto done; } clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); @@ -330,7 +339,7 @@ ngx_http_file_cache_open(ngx_http_reques case NGX_ENOENT: case NGX_ENOTDIR: - return rv; + goto done; default: ngx_log_error(NGX_LOG_CRIT, r->connection->log, of.err, @@ -354,6 +363,114 @@ ngx_http_file_cache_open(ngx_http_reques } return ngx_http_file_cache_read(r, c); + +done: + + if (rv == NGX_DECLINED) { + return ngx_http_file_cache_lock(r, c); + } + + return rv; +} + + +static ngx_int_t +ngx_http_file_cache_lock(ngx_http_request_t *r, ngx_http_cache_t *c) +{ + ngx_msec_t now, timer; + ngx_http_file_cache_t *cache; + + if (!c->lock) { + return NGX_DECLINED; + } + + cache = c->file_cache; + + ngx_shmtx_lock(&cache->shpool->mutex); + + if (!c->node->updating) { + c->node->updating = 1; + c->updating = 1; + } + + ngx_shmtx_unlock(&cache->shpool->mutex); + + ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, + "http file cache lock u:%d wt:%M", + c->updating, c->wait_time); + + if (c->updating) { + return NGX_DECLINED; + } + + c->waiting = 1; + + now = ngx_current_msec; + + if (c->wait_time == 0) { + c->wait_time = now + c->lock_timeout; + + c->wait_event.handler = ngx_http_file_cache_lock_wait_handler; + c->wait_event.data = r; + c->wait_event.log = r->connection->log; + } + + timer = c->wait_time - now; + + ngx_add_timer(&c->wait_event, (timer > 500) ? 500 : timer); + + r->main->blocked++; + + return NGX_AGAIN; +} + + +static void +ngx_http_file_cache_lock_wait_handler(ngx_event_t *ev) +{ + ngx_uint_t wait; + ngx_msec_t timer; + ngx_http_cache_t *c; + ngx_http_request_t *r; + ngx_http_file_cache_t *cache; + + r = ev->data; + c = r->cache; + + ngx_log_debug0(NGX_LOG_DEBUG_HTTP, ev->log, 0, + "http file cache wait handler wt:%M cur:%M", + c->wait_time, ngx_current_msec); + + timer = c->wait_time - ngx_current_msec; + + if ((ngx_msec_int_t) timer <= 0) { + ngx_log_debug0(NGX_LOG_DEBUG_HTTP, ev->log, 0, + "http file cache lock timeout"); + c->lock = 0; + goto wakeup; + } + + cache = c->file_cache; + wait = 0; + + ngx_shmtx_lock(&cache->shpool->mutex); + + if (c->node->updating) { + wait = 1; + } + + ngx_shmtx_unlock(&cache->shpool->mutex); + + if (wait) { + ngx_add_timer(ev, (timer > 500) ? 500 : timer); + return; + } + +wakeup: + + c->waiting = 0; + r->main->blocked--; + r->connection->write->handler(r->connection->write); } @@ -518,13 +635,19 @@ ngx_http_file_cache_exists(ngx_http_file ngx_shmtx_lock(&cache->shpool->mutex); - fcn = ngx_http_file_cache_lookup(cache, c->key); + fcn = c->node; + + if (fcn == NULL) { + fcn = ngx_http_file_cache_lookup(cache, c->key); + } if (fcn) { ngx_queue_remove(&fcn->queue); - fcn->uses++; - fcn->count++; + if (c->node == NULL) { + fcn->uses++; + fcn->count++; + } if (fcn->error) { @@ -621,6 +744,10 @@ ngx_http_file_cache_name(ngx_http_reques c = r->cache; + if (c->file.name.len) { + return NGX_OK; + } + c->file.name.len = path->name.len + 1 + path->len + 2 * NGX_HTTP_CACHE_KEY_LEN; @@ -957,6 +1084,10 @@ ngx_http_file_cache_free(ngx_http_cache_ } } } + + if (c->wait_event.timer_set) { + ngx_del_timer(&c->wait_event); + } } diff --git a/src/http/ngx_http_upstream.c b/src/http/ngx_http_upstream.c --- a/src/http/ngx_http_upstream.c +++ b/src/http/ngx_http_upstream.c @@ -707,6 +707,9 @@ ngx_http_upstream_cache(ngx_http_request c->body_start = u->conf->buffer_size; c->file_cache = u->conf->cache->data; + c->lock = u->conf->cache_lock; + c->lock_timeout = u->conf->cache_lock_timeout; + u->cache_status = NGX_HTTP_CACHE_MISS; } diff --git a/src/http/ngx_http_upstream.h b/src/http/ngx_http_upstream.h --- a/src/http/ngx_http_upstream.h +++ b/src/http/ngx_http_upstream.h @@ -165,6 +165,9 @@ typedef struct { ngx_uint_t cache_use_stale; ngx_uint_t cache_methods; + ngx_flag_t cache_lock; + ngx_msec_t cache_lock_timeout; + ngx_array_t *cache_valid; ngx_array_t *cache_bypass; ngx_array_t *no_cache; From mdounin at mdounin.ru Sun Dec 11 16:01:27 2011 From: mdounin at mdounin.ru (Maxim Dounin) Date: Sun, 11 Dec 2011 19:01:27 +0300 Subject: [PATCH 5 of 5] Cache lock support for fastcgi, scgi, uwsgi In-Reply-To: References: Message-ID: # HG changeset patch # User Maxim Dounin # Date 1323615378 -10800 # Node ID c162e2269b4c85e4d52f779e5a154ef761f3e6ba # Parent 9412a31366125763912dff5d592d539eb6102139 Cache lock support for fastcgi, scgi, uwsgi. diff --git a/src/http/modules/ngx_http_fastcgi_module.c b/src/http/modules/ngx_http_fastcgi_module.c --- a/src/http/modules/ngx_http_fastcgi_module.c +++ b/src/http/modules/ngx_http_fastcgi_module.c @@ -380,6 +380,20 @@ static ngx_command_t ngx_http_fastcgi_c offsetof(ngx_http_fastcgi_loc_conf_t, upstream.cache_methods), &ngx_http_upstream_cache_method_mask }, + { ngx_string("fastcgi_cache_lock"), + 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_fastcgi_loc_conf_t, upstream.cache_lock), + NULL }, + + { ngx_string("fastcgi_cache_lock_timeout"), + NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, + ngx_conf_set_msec_slot, + NGX_HTTP_LOC_CONF_OFFSET, + offsetof(ngx_http_fastcgi_loc_conf_t, upstream.cache_lock_timeout), + NULL }, + #endif { ngx_string("fastcgi_temp_path"), @@ -2062,6 +2076,8 @@ ngx_http_fastcgi_create_loc_conf(ngx_con conf->upstream.cache_bypass = NGX_CONF_UNSET_PTR; conf->upstream.no_cache = NGX_CONF_UNSET_PTR; conf->upstream.cache_valid = NGX_CONF_UNSET_PTR; + conf->upstream.cache_lock = NGX_CONF_UNSET; + conf->upstream.cache_lock_timeout = NGX_CONF_UNSET_MSEC; #endif conf->upstream.hide_headers = NGX_CONF_UNSET_PTR; @@ -2299,6 +2315,12 @@ ngx_http_fastcgi_merge_loc_conf(ngx_conf conf->cache_key = prev->cache_key; } + ngx_conf_merge_value(conf->upstream.cache_lock, + prev->upstream.cache_lock, 0); + + ngx_conf_merge_msec_value(conf->upstream.cache_lock_timeout, + prev->upstream.cache_lock_timeout, 5000); + #endif ngx_conf_merge_value(conf->upstream.pass_request_headers, diff --git a/src/http/modules/ngx_http_scgi_module.c b/src/http/modules/ngx_http_scgi_module.c --- a/src/http/modules/ngx_http_scgi_module.c +++ b/src/http/modules/ngx_http_scgi_module.c @@ -247,6 +247,20 @@ static ngx_command_t ngx_http_scgi_comma offsetof(ngx_http_scgi_loc_conf_t, upstream.cache_methods), &ngx_http_upstream_cache_method_mask }, + { ngx_string("scgi_cache_lock"), + 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_scgi_loc_conf_t, upstream.cache_lock), + NULL }, + + { ngx_string("scgi_cache_lock_timeout"), + NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, + ngx_conf_set_msec_slot, + NGX_HTTP_LOC_CONF_OFFSET, + offsetof(ngx_http_scgi_loc_conf_t, upstream.cache_lock_timeout), + NULL }, + #endif { ngx_string("scgi_temp_path"), @@ -1039,6 +1053,8 @@ ngx_http_scgi_create_loc_conf(ngx_conf_t conf->upstream.cache_bypass = NGX_CONF_UNSET_PTR; conf->upstream.no_cache = NGX_CONF_UNSET_PTR; conf->upstream.cache_valid = NGX_CONF_UNSET_PTR; + conf->upstream.cache_lock = NGX_CONF_UNSET; + conf->upstream.cache_lock_timeout = NGX_CONF_UNSET_MSEC; #endif conf->upstream.hide_headers = NGX_CONF_UNSET_PTR; @@ -1266,6 +1282,12 @@ ngx_http_scgi_merge_loc_conf(ngx_conf_t conf->cache_key = prev->cache_key; } + ngx_conf_merge_value(conf->upstream.cache_lock, + prev->upstream.cache_lock, 0); + + ngx_conf_merge_msec_value(conf->upstream.cache_lock_timeout, + prev->upstream.cache_lock_timeout, 5000); + #endif ngx_conf_merge_value(conf->upstream.pass_request_headers, diff --git a/src/http/modules/ngx_http_uwsgi_module.c b/src/http/modules/ngx_http_uwsgi_module.c --- a/src/http/modules/ngx_http_uwsgi_module.c +++ b/src/http/modules/ngx_http_uwsgi_module.c @@ -274,6 +274,20 @@ static ngx_command_t ngx_http_uwsgi_comm offsetof(ngx_http_uwsgi_loc_conf_t, upstream.cache_methods), &ngx_http_upstream_cache_method_mask }, + { ngx_string("uwsgi_cache_lock"), + 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_uwsgi_loc_conf_t, upstream.cache_lock), + NULL }, + + { ngx_string("uwsgi_cache_lock_timeout"), + NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, + ngx_conf_set_msec_slot, + NGX_HTTP_LOC_CONF_OFFSET, + offsetof(ngx_http_uwsgi_loc_conf_t, upstream.cache_lock_timeout), + NULL }, + #endif { ngx_string("uwsgi_temp_path"), @@ -1090,6 +1104,8 @@ ngx_http_uwsgi_create_loc_conf(ngx_conf_ conf->upstream.cache_bypass = NGX_CONF_UNSET_PTR; conf->upstream.no_cache = NGX_CONF_UNSET_PTR; conf->upstream.cache_valid = NGX_CONF_UNSET_PTR; + conf->upstream.cache_lock = NGX_CONF_UNSET; + conf->upstream.cache_lock_timeout = NGX_CONF_UNSET_MSEC; #endif conf->upstream.hide_headers = NGX_CONF_UNSET_PTR; @@ -1317,6 +1333,12 @@ ngx_http_uwsgi_merge_loc_conf(ngx_conf_t conf->cache_key = prev->cache_key; } + ngx_conf_merge_value(conf->upstream.cache_lock, + prev->upstream.cache_lock, 0); + + ngx_conf_merge_msec_value(conf->upstream.cache_lock_timeout, + prev->upstream.cache_lock_timeout, 5000); + #endif ngx_conf_merge_value(conf->upstream.pass_request_headers, From mdounin at mdounin.ru Sun Dec 11 16:30:43 2011 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Sun, 11 Dec 2011 16:30:43 +0000 Subject: [nginx] svn commit: r4336 - trunk/src/os/unix Message-ID: <20111211163043.EF56B3F9C1E@mail.nginx.com> Author: mdounin Date: 2011-12-11 16:30:42 +0000 (Sun, 11 Dec 2011) New Revision: 4336 Log: Microoptimization of sendfile(2) usage under FreeBSD. FreeBSD kernel checks headers/trailers pointer against NULL, not corresponding count. Passing NULL if there are no headers/trailers helps to avoid unneeded work in kernel, as well as unexpected 0 bytes GIO in traces. Modified: trunk/src/os/unix/ngx_freebsd_sendfile_chain.c Modified: trunk/src/os/unix/ngx_freebsd_sendfile_chain.c =================================================================== --- trunk/src/os/unix/ngx_freebsd_sendfile_chain.c 2011-12-09 16:17:12 UTC (rev 4335) +++ trunk/src/os/unix/ngx_freebsd_sendfile_chain.c 2011-12-11 16:30:42 UTC (rev 4336) @@ -246,9 +246,14 @@ } } - hdtr.headers = (struct iovec *) header.elts; + /* + * sendfile() does unneeded work if sf_hdtr's count is 0, + * but corresponding pointer is not NULL + */ + + hdtr.headers = header.nelts ? (struct iovec *) header.elts: NULL; hdtr.hdr_cnt = header.nelts; - hdtr.trailers = (struct iovec *) trailer.elts; + hdtr.trailers = trailer.nelts ? (struct iovec *) trailer.elts: NULL; hdtr.trl_cnt = trailer.nelts; /* From mp3geek at gmail.com Sun Dec 11 23:59:37 2011 From: mp3geek at gmail.com (Ryan Brown) Date: Mon, 12 Dec 2011 12:59:37 +1300 Subject: [PATCH 0 of 5] cache patches In-Reply-To: References: Message-ID: If I'm serving static (non-proxied,non-dynamic) gzip'd files, does these cache patches help with performance? cpu load? On Mon, Dec 12, 2011 at 5:01 AM, Maxim Dounin wrote: > Hello! > > Here are patch series which addresses several issues in cache > (first 3 patches), and adds cache lock support (last 2). > > I'm planning to commit first 3 patches shortly, cache lock patches will > remain experimental for a while. ?Review and testing appreciated. > > Maxim Dounin > > _______________________________________________ > nginx-devel mailing list > nginx-devel at nginx.org > http://mailman.nginx.org/mailman/listinfo/nginx-devel From appa at perusio.net Mon Dec 12 00:07:25 2011 From: appa at perusio.net (=?UTF-8?B?QW50w7NuaW8=?= P. P. Almeida) Date: Mon, 12 Dec 2011 00:07:25 +0000 Subject: [PATCH 0 of 5] cache patches In-Reply-To: References: Message-ID: <87d3buejpe.wl%appa@perusio.net> On 11 Dez 2011 16h01 WET, mdounin at mdounin.ru wrote: Hello Maxim, > Hello! > > Here are patch series which addresses several issues in cache > (first 3 patches), and adds cache lock support (last 2). > > I'm planning to commit first 3 patches shortly, cache lock patches > will remain experimental for a while. Review and testing > appreciated. I will. If I understood correctly the later two patches implement a locking mechanism so that if /foobar is not cached and there are 5 requests for foobar in time interval below the cache lock timeout then only the first request goes upstream the other requests are queued and are served up when the upstream returns a response. Example: location /foobar { # usual proxy cache stuff... proxy_cache_lock on; proxy_cache_lock_timeout 500; # the default, can be tweaked proxy_pass http://my_upstream; } 1. Request for /foobar comes in at t=0 2. Additional request for /foobar comes in at t=200ms 3. Additional request for /foobar comes in at t=220ms Requests 2 and 3 are queued by the cache manager. Request 1 is forwarded upstream. When a response arrives, requests 2 and 3 are served. For the moment the cache entries that are updating will use the current 'proxy_cache_use_stale updating' setting. Thanks, --- appa From vbart at nginx.com Mon Dec 12 09:02:30 2011 From: vbart at nginx.com (vbart at nginx.com) Date: Mon, 12 Dec 2011 09:02:30 +0000 Subject: [nginx] svn commit: r4337 - trunk/src/http/modules Message-ID: Author: vbart Date: 2011-12-12 09:02:29 +0000 (Mon, 12 Dec 2011) New Revision: 4337 Modified: trunk/src/http/modules/ngx_http_proxy_module.c Log: Proxy: added variables and regexp support to the first parameter of the "proxy_redirect" directive. Modified: trunk/src/http/modules/ngx_http_proxy_module.c =================================================================== --- trunk/src/http/modules/ngx_http_proxy_module.c 2011-12-11 16:30:42 UTC (rev 4336) +++ trunk/src/http/modules/ngx_http_proxy_module.c 2011-12-12 09:02:29 UTC (rev 4337) @@ -16,18 +16,15 @@ struct ngx_http_proxy_redirect_s { ngx_http_proxy_redirect_pt handler; - ngx_str_t redirect; union { - ngx_str_t text; + ngx_http_complex_value_t complex; +#if (NGX_PCRE) + ngx_http_regex_t *regex; +#endif + } redirect; - struct { - void *lengths; - void *values; - } vars; - - void *regex; - } replacement; + ngx_http_complex_value_t replacement; }; @@ -2289,21 +2286,30 @@ static ngx_int_t -ngx_http_proxy_rewrite_redirect_text(ngx_http_request_t *r, ngx_table_elt_t *h, - size_t prefix, ngx_http_proxy_redirect_t *pr) +ngx_http_proxy_rewrite_redirect_complex(ngx_http_request_t *r, + ngx_table_elt_t *h, size_t prefix, ngx_http_proxy_redirect_t *pr) { - size_t len; - u_char *data, *p; + size_t len; + u_char *data, *p; + ngx_str_t redirect, replacement; - if (pr->redirect.len > h->value.len - prefix - || ngx_rstrncmp(h->value.data + prefix, pr->redirect.data, - pr->redirect.len) != 0) + if (ngx_http_complex_value(r, &pr->redirect.complex, &redirect) != NGX_OK) { + return NGX_ERROR; + } + + if (redirect.len > h->value.len - prefix + || ngx_rstrncmp(h->value.data + prefix, redirect.data, + redirect.len) != 0) { return NGX_DECLINED; } - len = pr->replacement.text.len + h->value.len - pr->redirect.len; + if (ngx_http_complex_value(r, &pr->replacement, &replacement) != NGX_OK) { + return NGX_ERROR; + } + len = replacement.len + h->value.len - redirect.len; + data = ngx_pnalloc(r->pool, len); if (data == NULL) { return NGX_ERROR; @@ -2311,12 +2317,12 @@ p = ngx_copy(data, h->value.data, prefix); - if (pr->replacement.text.len) { - p = ngx_copy(p, pr->replacement.text.data, pr->replacement.text.len); + if (replacement.len) { + p = ngx_copy(p, replacement.data, replacement.len); } - ngx_memcpy(p, h->value.data + prefix + pr->redirect.len, - h->value.len - pr->redirect.len - prefix); + ngx_memcpy(p, h->value.data + prefix + redirect.len, + h->value.len - redirect.len - prefix); h->value.len = len; h->value.data = data; @@ -2325,60 +2331,33 @@ } +#if (NGX_PCRE) + static ngx_int_t -ngx_http_proxy_rewrite_redirect_vars(ngx_http_request_t *r, ngx_table_elt_t *h, +ngx_http_proxy_rewrite_redirect_regex(ngx_http_request_t *r, ngx_table_elt_t *h, size_t prefix, ngx_http_proxy_redirect_t *pr) { - size_t len; - u_char *data, *p; - ngx_http_script_code_pt code; - ngx_http_script_engine_t e; - ngx_http_script_len_code_pt lcode; + ngx_str_t redirect, replacement; - if (pr->redirect.len > h->value.len - prefix - || ngx_rstrncmp(h->value.data + prefix, pr->redirect.data, - pr->redirect.len) != 0) - { + redirect.len = h->value.len - prefix; + redirect.data = h->value.data + prefix; + + if (ngx_http_regex_exec(r, pr->redirect.regex, &redirect) != NGX_OK) { return NGX_DECLINED; } - ngx_memzero(&e, sizeof(ngx_http_script_engine_t)); - - e.ip = pr->replacement.vars.lengths; - e.request = r; - - len = h->value.len - pr->redirect.len; - - while (*(uintptr_t *) e.ip) { - lcode = *(ngx_http_script_len_code_pt *) e.ip; - len += lcode(&e); - } - - data = ngx_pnalloc(r->pool, len); - if (data == NULL) { + if (ngx_http_complex_value(r, &pr->replacement, &replacement) != NGX_OK) { return NGX_ERROR; } - p = ngx_copy(data, h->value.data, prefix); + h->value = replacement; - e.ip = pr->replacement.vars.values; - e.pos = p; - - while (*(uintptr_t *) e.ip) { - code = *(ngx_http_script_code_pt *) e.ip; - code(&e); - } - - ngx_memcpy(e.pos, h->value.data + prefix + pr->redirect.len, - h->value.len - pr->redirect.len - prefix); - - h->value.len = len; - h->value.data = data; - return NGX_OK; } +#endif + static ngx_int_t ngx_http_proxy_add_variables(ngx_conf_t *cf) { @@ -2749,26 +2728,32 @@ return NGX_CONF_ERROR; } - pr->handler = ngx_http_proxy_rewrite_redirect_text; + ngx_memzero(&pr->redirect.complex, + sizeof(ngx_http_complex_value_t)); + ngx_memzero(&pr->replacement, sizeof(ngx_http_complex_value_t)); + + pr->handler = ngx_http_proxy_rewrite_redirect_complex; + if (conf->vars.uri.len) { - pr->redirect = conf->url; - pr->replacement.text = conf->location; + pr->redirect.complex.value = conf->url; + pr->replacement.value = conf->location; } else { - pr->redirect.len = conf->url.len + sizeof("/") - 1; + pr->redirect.complex.value.len = conf->url.len + + sizeof("/") - 1; - p = ngx_pnalloc(cf->pool, pr->redirect.len); + p = ngx_pnalloc(cf->pool, pr->redirect.complex.value.len); if (p == NULL) { return NGX_CONF_ERROR; } - pr->redirect.data = p; + pr->redirect.complex.value.data = p; p = ngx_cpymem(p, conf->url.data, conf->url.len); *p = '/'; - ngx_str_set(&pr->replacement.text, "/"); + ngx_str_set(&pr->replacement.value, "/"); } } } @@ -3256,11 +3241,10 @@ { ngx_http_proxy_loc_conf_t *plcf = conf; - u_char *p; - ngx_str_t *value; - ngx_array_t *vars_lengths, *vars_values; - ngx_http_script_compile_t sc; - ngx_http_proxy_redirect_t *pr; + u_char *p; + ngx_str_t *value; + ngx_http_proxy_redirect_t *pr; + ngx_http_compile_complex_value_t ccv; if (plcf->redirect == 0) { return NGX_CONF_OK; @@ -3318,60 +3302,96 @@ return NGX_CONF_ERROR; } - pr->handler = ngx_http_proxy_rewrite_redirect_text; + pr->handler = ngx_http_proxy_rewrite_redirect_complex; + ngx_memzero(&pr->redirect.complex, sizeof(ngx_http_complex_value_t)); + + ngx_memzero(&pr->replacement, sizeof(ngx_http_complex_value_t)); + if (plcf->vars.uri.len) { - pr->redirect = plcf->url; - pr->replacement.text = plcf->location; + pr->redirect.complex.value = plcf->url; + pr->replacement.value = plcf->location; } else { - pr->redirect.len = plcf->url.len + sizeof("/") - 1; + pr->redirect.complex.value.len = plcf->url.len + sizeof("/") - 1; - p = ngx_pnalloc(cf->pool, pr->redirect.len); + p = ngx_pnalloc(cf->pool, pr->redirect.complex.value.len); if (p == NULL) { return NGX_CONF_ERROR; } - pr->redirect.data = p; + pr->redirect.complex.value.data = p; p = ngx_cpymem(p, plcf->url.data, plcf->url.len); *p = '/'; - ngx_str_set(&pr->replacement.text, "/"); + ngx_str_set(&pr->replacement.value, "/"); } return NGX_CONF_OK; } - if (ngx_http_script_variables_count(&value[2]) == 0) { - pr->handler = ngx_http_proxy_rewrite_redirect_text; - pr->redirect = value[1]; - pr->replacement.text = value[2]; - return NGX_CONF_OK; + if (value[1].data[0] == '~') { +#if (NGX_PCRE) + u_char errstr[NGX_MAX_CONF_ERRSTR]; + ngx_regex_compile_t rc; + + value[1].len--; + value[1].data++; + + ngx_memzero(&rc, sizeof(ngx_regex_compile_t)); + + if (value[1].data[0] == '*') { + value[1].len--; + value[1].data++; + rc.options = NGX_REGEX_CASELESS; + } + + rc.pattern = value[1]; + rc.err.len = NGX_MAX_CONF_ERRSTR; + rc.err.data = errstr; + + pr->redirect.regex = ngx_http_regex_compile(cf, &rc); + if (pr->redirect.regex == NULL) { + return NGX_CONF_ERROR; + } + + pr->handler = ngx_http_proxy_rewrite_redirect_regex; + +#else + ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, + "using regex \"%V\" requires PCRE library", + &value[1]); + + return NGX_CONF_ERROR; +#endif + } else { + + ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t)); + + ccv.cf = cf; + ccv.value = &value[1]; + ccv.complex_value = &pr->redirect.complex; + + if (ngx_http_compile_complex_value(&ccv) != NGX_OK) { + return NGX_CONF_ERROR; + } + + pr->handler = ngx_http_proxy_rewrite_redirect_complex; } - ngx_memzero(&sc, sizeof(ngx_http_script_compile_t)); - vars_lengths = NULL; - vars_values = NULL; + ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t)); - sc.cf = cf; - sc.source = &value[2]; - sc.lengths = &vars_lengths; - sc.values = &vars_values; - sc.complete_lengths = 1; - sc.complete_values = 1; + ccv.cf = cf; + ccv.value = &value[2]; + ccv.complex_value = &pr->replacement; - if (ngx_http_script_compile(&sc) != NGX_OK) { + if (ngx_http_compile_complex_value(&ccv) != NGX_OK) { return NGX_CONF_ERROR; } - pr->handler = ngx_http_proxy_rewrite_redirect_vars; - pr->redirect = value[1]; - pr->replacement.vars.lengths = vars_lengths->elts; - pr->replacement.vars.values = vars_values->elts; - return NGX_CONF_OK; } From abioy.sun at gmail.com Mon Dec 12 09:10:35 2011 From: abioy.sun at gmail.com (Abioy Sun) Date: Mon, 12 Dec 2011 17:10:35 +0800 Subject: The meaning of the COUNT field in ngx_http_request Message-ID: Hi All, I was dev some modules for nginx but confusing in the meaning of the 'count' field of ngx_http_request structure, anybody who can help? thx! Yours, Abioy -------------- next part -------------- An HTML attachment was scrubbed... URL: From mdounin at mdounin.ru Mon Dec 12 09:52:30 2011 From: mdounin at mdounin.ru (Maxim Dounin) Date: Mon, 12 Dec 2011 13:52:30 +0400 Subject: [PATCH 0 of 5] cache patches In-Reply-To: References: Message-ID: <20111212095229.GN67687@mdounin.ru> Hello! On Mon, Dec 12, 2011 at 12:59:37PM +1300, Ryan Brown wrote: > If I'm serving static (non-proxied,non-dynamic) gzip'd files, does > these cache patches help with performance? cpu load? Workloads not using cache (proxy_cache, fastcgi_cache, scgi_cache, uwsgi_cache) aren't affected by these patches. Maxim Dounin > > On Mon, Dec 12, 2011 at 5:01 AM, Maxim Dounin wrote: > > Hello! > > > > Here are patch series which addresses several issues in cache > > (first 3 patches), and adds cache lock support (last 2). > > > > I'm planning to commit first 3 patches shortly, cache lock patches will > > remain experimental for a while. ?Review and testing appreciated. > > > > Maxim Dounin > > > > _______________________________________________ > > 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 From mdounin at mdounin.ru Mon Dec 12 10:00:02 2011 From: mdounin at mdounin.ru (Maxim Dounin) Date: Mon, 12 Dec 2011 14:00:02 +0400 Subject: [PATCH 0 of 5] cache patches In-Reply-To: <87d3buejpe.wl%appa@perusio.net> References: <87d3buejpe.wl%appa@perusio.net> Message-ID: <20111212100002.GO67687@mdounin.ru> Hello! On Mon, Dec 12, 2011 at 12:07:25AM +0000, Ant?nio P. P. Almeida wrote: > On 11 Dez 2011 16h01 WET, mdounin at mdounin.ru wrote: > > Hello Maxim, > > > Hello! > > > > Here are patch series which addresses several issues in cache > > (first 3 patches), and adds cache lock support (last 2). > > > > I'm planning to commit first 3 patches shortly, cache lock patches > > will remain experimental for a while. Review and testing > > appreciated. > > I will. If I understood correctly the later two patches implement a > locking mechanism so that if /foobar is not cached and there are 5 > requests for foobar in time interval below the cache lock timeout then > only the first request goes upstream the other requests are queued and > are served up when the upstream returns a response. Yes. > > Example: > > location /foobar { > > # usual proxy cache stuff... > > proxy_cache_lock on; > proxy_cache_lock_timeout 500; # the default, can be tweaked The default for proxy_cache_lock_timeout is "5s". > proxy_pass http://my_upstream; > } > > 1. Request for /foobar comes in at t=0 > > 2. Additional request for /foobar comes in at t=200ms > > 3. Additional request for /foobar comes in at t=220ms > > Requests 2 and 3 are queued by the cache manager. Request 1 is > forwarded upstream. When a response arrives, requests 2 and 3 are > served. In the above scenario, request (2) will be served at t=700ms (500ms after request) and request (3) will be served at t=720ms. This is because right now requests use periodic timer (each 500ms) to see if response arrived. If a response doesn't arrive at all, at 5s200ms (after proxy_cache_lock_timeout) request (2) will be allowed to go to upstream, and at 5s220ms request (3) will be allowed to go to upstream. That is, proxy_cache_lock_timeout is a per-request safeguard timeout. > For the moment the cache entries that are updating will use the > current 'proxy_cache_use_stale updating' setting. Yes. Maxim Dounin From appa at perusio.net Mon Dec 12 10:25:34 2011 From: appa at perusio.net (=?UTF-8?B?QW50w7NuaW8=?= P. P. Almeida) Date: Mon, 12 Dec 2011 10:25:34 +0000 Subject: [PATCH 0 of 5] cache patches In-Reply-To: <20111212100002.GO67687@mdounin.ru> References: <87d3buejpe.wl%appa@perusio.net> <20111212100002.GO67687@mdounin.ru> Message-ID: <87aa6ydr35.wl%appa@perusio.net> On 12 Dez 2011 10h00 WET, mdounin at mdounin.ru wrote: Hello again, > The default for proxy_cache_lock_timeout is "5s". Yes indeed. There's a 5000 there. My fault. >> proxy_pass http://my_upstream; >> } >> >> 1. Request for /foobar comes in at t=0 >> >> 2. Additional request for /foobar comes in at t=200ms >> >> 3. Additional request for /foobar comes in at t=220ms >> >> Requests 2 and 3 are queued by the cache manager. Request 1 is >> forwarded upstream. When a response arrives, requests 2 and 3 are >> served. > > In the above scenario, request (2) will be served at t=700ms > (500ms after request) and request (3) will be served at t=720ms. > This is because right now requests use periodic timer (each 500ms) > to see if response arrived. Ok. This is harcoded right now, here I think: + if (wait) { + ngx_add_timer(ev, (timer > 500) ? 500 : timer); + return; + } Can we not make this a user defined setting? E.g.: proxy_cache_lock_request_period ; # defaults to 500 I don't know if making this period user defined will have consequences down the line in other cache manager code. Just an idea. Thanks, --- appa > If a response doesn't arrive at all, at 5s200ms (after > proxy_cache_lock_timeout) request (2) will be allowed to go to > upstream, and at 5s220ms request (3) will be allowed to go to > upstream. That is, proxy_cache_lock_timeout is a per-request > safeguard timeout. > >> For the moment the cache entries that are updating will use the >> current 'proxy_cache_use_stale updating' setting. > > Yes. > > Maxim Dounin > > _______________________________________________ > nginx-devel mailing list > nginx-devel at nginx.org > http://mailman.nginx.org/mailman/listinfo/nginx-devel From mdounin at mdounin.ru Mon Dec 12 10:34:37 2011 From: mdounin at mdounin.ru (Maxim Dounin) Date: Mon, 12 Dec 2011 14:34:37 +0400 Subject: [PATCH 0 of 5] cache patches In-Reply-To: <87aa6ydr35.wl%appa@perusio.net> References: <87d3buejpe.wl%appa@perusio.net> <20111212100002.GO67687@mdounin.ru> <87aa6ydr35.wl%appa@perusio.net> Message-ID: <20111212103437.GR67687@mdounin.ru> Hello! On Mon, Dec 12, 2011 at 10:25:34AM +0000, Ant?nio P. P. Almeida wrote: [...] > > In the above scenario, request (2) will be served at t=700ms > > (500ms after request) and request (3) will be served at t=720ms. > > This is because right now requests use periodic timer (each 500ms) > > to see if response arrived. > > Ok. This is harcoded right now, here I think: > > + if (wait) { > + ngx_add_timer(ev, (timer > 500) ? 500 : timer); > + return; > + } > > Can we not make this a user defined setting? E.g.: > > proxy_cache_lock_request_period ; # defaults to 500 > > I don't know if making this period user defined will have consequences > down the line in other cache manager code. This may be changed to user setting, but I don't want to as this is expected to move away from timer to event-based notification some day. Maxim Dounin From ru at nginx.com Mon Dec 12 10:45:05 2011 From: ru at nginx.com (ru at nginx.com) Date: Mon, 12 Dec 2011 10:45:05 +0000 Subject: [nginx] svn commit: r4338 - trunk/src/http Message-ID: <20111212104506.0BC6C3F9C1A@mail.nginx.com> Author: ru Date: 2011-12-12 10:45:05 +0000 (Mon, 12 Dec 2011) New Revision: 4338 Log: Renamed some constants to improve readability, no functional changes. Modified: trunk/src/http/ngx_http_header_filter_module.c Modified: trunk/src/http/ngx_http_header_filter_module.c =================================================================== --- trunk/src/http/ngx_http_header_filter_module.c 2011-12-12 09:02:29 UTC (rev 4337) +++ trunk/src/http/ngx_http_header_filter_module.c 2011-12-12 10:45:05 UTC (rev 4338) @@ -61,8 +61,8 @@ /* ngx_null_string, */ /* "207 Multi-Status" */ -#define NGX_HTTP_LAST_LEVEL_200 207 -#define NGX_HTTP_LEVEL_200 (NGX_HTTP_LAST_LEVEL_200 - 200) +#define NGX_HTTP_LAST_2XX 207 +#define NGX_HTTP_OFF_3XX (NGX_HTTP_LAST_2XX - 200) /* ngx_null_string, */ /* "300 Multiple Choices" */ @@ -75,8 +75,8 @@ /* ngx_null_string, */ /* "306 unused" */ /* ngx_null_string, */ /* "307 Temporary Redirect" */ -#define NGX_HTTP_LAST_LEVEL_300 305 -#define NGX_HTTP_LEVEL_300 (NGX_HTTP_LAST_LEVEL_300 - 301) +#define NGX_HTTP_LAST_3XX 305 +#define NGX_HTTP_OFF_4XX (NGX_HTTP_LAST_3XX - 301 + NGX_HTTP_OFF_3XX) ngx_string("400 Bad Request"), ngx_string("401 Unauthorized"), @@ -108,8 +108,8 @@ /* ngx_null_string, */ /* "423 Locked" */ /* ngx_null_string, */ /* "424 Failed Dependency" */ -#define NGX_HTTP_LAST_LEVEL_400 417 -#define NGX_HTTP_LEVEL_400 (NGX_HTTP_LAST_LEVEL_400 - 400) +#define NGX_HTTP_LAST_4XX 417 +#define NGX_HTTP_OFF_5XX (NGX_HTTP_LAST_4XX - 400 + NGX_HTTP_OFF_4XX) ngx_string("500 Internal Server Error"), ngx_string("501 Method Not Implemented"), @@ -124,7 +124,7 @@ /* ngx_null_string, */ /* "509 unused" */ /* ngx_null_string, */ /* "510 Not Extended" */ -#define NGX_HTTP_LAST_LEVEL_500 508 +#define NGX_HTTP_LAST_5XX 508 }; @@ -216,7 +216,7 @@ status = r->headers_out.status; if (status >= NGX_HTTP_OK - && status < NGX_HTTP_LAST_LEVEL_200) + && status < NGX_HTTP_LAST_2XX) { /* 2XX */ @@ -234,7 +234,7 @@ len += ngx_http_status_lines[status].len; } else if (status >= NGX_HTTP_MOVED_PERMANENTLY - && status < NGX_HTTP_LAST_LEVEL_300) + && status < NGX_HTTP_LAST_3XX) { /* 3XX */ @@ -242,29 +242,26 @@ r->header_only = 1; } - status = status - NGX_HTTP_MOVED_PERMANENTLY + NGX_HTTP_LEVEL_200; + status = status - NGX_HTTP_MOVED_PERMANENTLY + NGX_HTTP_OFF_3XX; status_line = &ngx_http_status_lines[status]; len += ngx_http_status_lines[status].len; } else if (status >= NGX_HTTP_BAD_REQUEST - && status < NGX_HTTP_LAST_LEVEL_400) + && status < NGX_HTTP_LAST_4XX) { /* 4XX */ status = status - NGX_HTTP_BAD_REQUEST - + NGX_HTTP_LEVEL_200 - + NGX_HTTP_LEVEL_300; + + NGX_HTTP_OFF_4XX; status_line = &ngx_http_status_lines[status]; len += ngx_http_status_lines[status].len; } else if (status >= NGX_HTTP_INTERNAL_SERVER_ERROR - && status < NGX_HTTP_LAST_LEVEL_500) + && status < NGX_HTTP_LAST_5XX) { /* 5XX */ status = status - NGX_HTTP_INTERNAL_SERVER_ERROR - + NGX_HTTP_LEVEL_200 - + NGX_HTTP_LEVEL_300 - + NGX_HTTP_LEVEL_400; + + NGX_HTTP_OFF_5XX; status_line = &ngx_http_status_lines[status]; len += ngx_http_status_lines[status].len; From mdounin at mdounin.ru Mon Dec 12 10:46:43 2011 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Mon, 12 Dec 2011 10:46:43 +0000 Subject: [nginx] svn commit: r4339 - trunk/src/http Message-ID: <20111212104643.BF4433F9C1B@mail.nginx.com> Author: mdounin Date: 2011-12-12 10:46:43 +0000 (Mon, 12 Dec 2011) New Revision: 4339 Log: Cache: obsolete code removed. The ngx_http_cache() and ngx_http_no_cache_set_slot() functions were replaced by ngx_http_test_predicates() and ngx_http_set_predicate_slot() in 0.8.46 and no longer used since then. Modified: trunk/src/http/ngx_http_file_cache.c Modified: trunk/src/http/ngx_http_file_cache.c =================================================================== --- trunk/src/http/ngx_http_file_cache.c 2011-12-12 10:45:05 UTC (rev 4338) +++ trunk/src/http/ngx_http_file_cache.c 2011-12-12 10:46:43 UTC (rev 4339) @@ -1752,69 +1752,3 @@ return NGX_CONF_OK; } - - -ngx_int_t -ngx_http_cache(ngx_http_request_t *r, ngx_array_t *no_cache) -{ - ngx_str_t val; - ngx_uint_t i; - ngx_http_complex_value_t *cv; - - cv = no_cache->elts; - - for (i = 0; i < no_cache->nelts; i++) { - if (ngx_http_complex_value(r, &cv[i], &val) != NGX_OK) { - return NGX_ERROR; - } - - if (val.len && val.data[0] != '0') { - return NGX_DECLINED; - } - } - - return NGX_OK; -} - - -char * -ngx_http_no_cache_set_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) -{ - char *p = conf; - - ngx_str_t *value; - ngx_uint_t i; - ngx_array_t **a; - ngx_http_complex_value_t *cv; - ngx_http_compile_complex_value_t ccv; - - a = (ngx_array_t **) (p + cmd->offset); - - if (*a == NGX_CONF_UNSET_PTR) { - *a = ngx_array_create(cf->pool, 1, sizeof(ngx_http_complex_value_t)); - if (*a == NULL) { - return NGX_CONF_ERROR; - } - } - - value = cf->args->elts; - - for (i = 1; i < cf->args->nelts; i++) { - cv = ngx_array_push(*a); - if (cv == NULL) { - return NGX_CONF_ERROR; - } - - ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t)); - - ccv.cf = cf; - ccv.value = &value[i]; - ccv.complex_value = cv; - - if (ngx_http_compile_complex_value(&ccv) != NGX_OK) { - return NGX_CONF_ERROR; - } - } - - return NGX_CONF_OK; -} From mdounin at mdounin.ru Mon Dec 12 10:47:48 2011 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Mon, 12 Dec 2011 10:47:48 +0000 Subject: [nginx] svn commit: r4340 - trunk/src/http Message-ID: <20111212104748.CB4B93F9C20@mail.nginx.com> Author: mdounin Date: 2011-12-12 10:47:48 +0000 (Mon, 12 Dec 2011) New Revision: 4340 Log: Cache: handling of cache files with long headers. There are two possible situations which can lead to this: response was cached with bigger proxy_buffer_size value (and nginx was restared since then, i.e. shared memory zone content was lost), or due to the race in the cache update code (see [1]) we've end up with fcn->body_start from a different response stored in shared memory zone. [1] http://mailman.nginx.org/pipermail/nginx-devel/2011-September/001287.html Modified: trunk/src/http/ngx_http_file_cache.c Modified: trunk/src/http/ngx_http_file_cache.c =================================================================== --- trunk/src/http/ngx_http_file_cache.c 2011-12-12 10:46:43 UTC (rev 4339) +++ trunk/src/http/ngx_http_file_cache.c 2011-12-12 10:47:48 UTC (rev 4340) @@ -386,6 +386,13 @@ return NGX_DECLINED; } + if (h->body_start > c->body_start) { + ngx_log_error(NGX_LOG_CRIT, r->connection->log, 0, + "cache file \"%s\" has too long header", + c->file.name.data); + return NGX_DECLINED; + } + c->buf->last += n; c->valid_sec = h->valid_sec; From mdounin at mdounin.ru Mon Dec 12 10:49:15 2011 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Mon, 12 Dec 2011 10:49:15 +0000 Subject: [nginx] svn commit: r4341 - trunk/src/http Message-ID: <20111212104915.1C6733F9C20@mail.nginx.com> Author: mdounin Date: 2011-12-12 10:49:14 +0000 (Mon, 12 Dec 2011) New Revision: 4341 Log: Cache: only complain on long locked entries. There have been multiple reports of cases where a real locked entry was removed, resulting in a segmentation fault later in a worker which locked the entry. It looks like default inactive timeout isn't enough in real life. For now just ignore such locked entries, and move them to the top of the inactive queue to allow processing of other entries. Modified: trunk/src/http/ngx_http_file_cache.c Modified: trunk/src/http/ngx_http_file_cache.c =================================================================== --- trunk/src/http/ngx_http_file_cache.c 2011-12-12 10:47:48 UTC (rev 4340) +++ trunk/src/http/ngx_http_file_cache.c 2011-12-12 10:49:14 UTC (rev 4341) @@ -1113,12 +1113,12 @@ /* * abnormally exited workers may leave locked cache entries, * and although it may be safe to remove them completely, - * we prefer to remove them from inactive queue and rbtree - * only, and to allow other leaks + * we prefer to just move them to the top of the inactive queue */ ngx_queue_remove(q); - ngx_rbtree_delete(&cache->sh->rbtree, &fcn->node); + fcn->expire = ngx_time() + cache->inactive; + ngx_queue_insert_head(&cache->sh->queue, &fcn->queue); ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, 0, "ignore long locked inactive cache entry %*s, count:%d", From mdounin at mdounin.ru Mon Dec 12 11:00:17 2011 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Mon, 12 Dec 2011 11:00:17 +0000 Subject: [nginx] svn commit: r4342 - trunk/misc Message-ID: <20111212110018.9C85E3F9C2E@mail.nginx.com> Author: mdounin Date: 2011-12-12 11:00:17 +0000 (Mon, 12 Dec 2011) New Revision: 4342 Log: Fixed RELEASE target to correctly call "release" one. Modified: trunk/misc/GNUmakefile Modified: trunk/misc/GNUmakefile =================================================================== --- trunk/misc/GNUmakefile 2011-12-12 10:49:14 UTC (rev 4341) +++ trunk/misc/GNUmakefile 2011-12-12 11:00:17 UTC (rev 4342) @@ -51,7 +51,7 @@ svn up - $(MAKE) release + $(MAKE) -f docs/GNUmakefile release snapshot: From mdounin at mdounin.ru Mon Dec 12 12:39:20 2011 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Mon, 12 Dec 2011 12:39:20 +0000 Subject: [nginx] svn commit: r4343 - trunk/misc Message-ID: <20111212123920.6648F3F9C27@mail.nginx.com> Author: mdounin Date: 2011-12-12 12:39:19 +0000 (Mon, 12 Dec 2011) New Revision: 4343 Log: Fixed RELEASE target again. Modified: trunk/misc/GNUmakefile Modified: trunk/misc/GNUmakefile =================================================================== --- trunk/misc/GNUmakefile 2011-12-12 11:00:17 UTC (rev 4342) +++ trunk/misc/GNUmakefile 2011-12-12 12:39:19 UTC (rev 4343) @@ -51,7 +51,7 @@ svn up - $(MAKE) -f docs/GNUmakefile release + $(MAKE) -f misc/GNUmakefile release snapshot: From mdounin at mdounin.ru Mon Dec 12 14:17:50 2011 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Mon, 12 Dec 2011 14:17:50 +0000 Subject: [nginx] svn commit: r4344 - trunk/docs/xml/nginx Message-ID: <20111212141750.505473F9C20@mail.nginx.com> Author: mdounin Date: 2011-12-12 14:17:49 +0000 (Mon, 12 Dec 2011) New Revision: 4344 Log: nginx-1.1.11-RELEASE Modified: trunk/docs/xml/nginx/changes.xml Modified: trunk/docs/xml/nginx/changes.xml =================================================================== --- trunk/docs/xml/nginx/changes.xml 2011-12-12 12:39:19 UTC (rev 4343) +++ trunk/docs/xml/nginx/changes.xml 2011-12-12 14:17:49 UTC (rev 4344) @@ -9,6 +9,104 @@ nginx changelog + + + + +???????? so_keepalive ? ????????? listen.
+??????? ????????? ???????. +
+ +the "so_keepalive" parameter of the "listen" directive.
+Thanks to Vsevolod Stakhov. +
+
+ + + +???????? if_not_empty ? ?????????? fastcgi/scgi/uwsgi_param. + + +the "if_not_empty" parameter of the "fastcgi/scgi/uwsgi_param" directives. + + + + + +?????????? $https. + + +the $https variable. + + + + + +????????? proxy_redirect ???????????? ?????????? ? ?????? ?????????. + + +the "proxy_redirect" directive supports variables in the first parameter. + + + + + +????????? proxy_redirect ???????????? ?????????? ?????????. + + +the "proxy_redirect" directive supports regular expressions. + + + + + +?????????? $sent_http_cache_control ????? ????????? ???????? ???????? ??? +????????????? ????????? expires.
+??????? Yichun Zhang. +
+ +the $sent_http_cache_control variable might contain a wrong value if the +"expires" directive was used.
+Thanks to Yichun Zhang. +
+
+ + + +????????? read_ahead ????? ?? ???????? ??? ????????????? ????????? ? +try_files ? open_file_cache. + + +the "read_ahead" directive might not work combined with "try_files" +and "open_file_cache". + + + + + +???? ? ????????? inactive ????????? proxy_cache_path +???? ??????? ????? ?????, +? ??????? ???????? ??? ????????? segmentation fault. + + +a segmentation fault might occur in a worker process +if small time was used in the "inactive" parameter of +the "proxy_cache_path" directive. + + + + + +?????? ?? ???? ????? ????????. + + +responses from cache might hang. + + + +
+ + From mdounin at mdounin.ru Mon Dec 12 14:18:15 2011 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Mon, 12 Dec 2011 14:18:15 +0000 Subject: [nginx] svn commit: r4345 - tags Message-ID: <20111212141815.A44143F9C21@mail.nginx.com> Author: mdounin Date: 2011-12-12 14:18:15 +0000 (Mon, 12 Dec 2011) New Revision: 4345 Log: release-1.1.11 tag Added: tags/release-1.1.11/ From mdounin at mdounin.ru Mon Dec 12 18:00:13 2011 From: mdounin at mdounin.ru (Maxim Dounin) Date: Mon, 12 Dec 2011 21:00:13 +0300 Subject: [PATCH] Fixed incorrect use of r->http_version in scgi module Message-ID: <156d489a0d1319ae2df6.1323709213@vm-bsd.mdounin.ru> # HG changeset patch # User Maxim Dounin # Date 1323708541 -10800 # Node ID 156d489a0d1319ae2df625521a76a3e527c5a5c2 # Parent 189afff6503fdb14e2ba72336a68d6673637f7d7 Fixed incorrect use of r->http_version in scgi module. The r->http_version is a version of client's request, and modules must not set it unless they are really willing to downgrade protocol version used for a response (i.e. to HTTP/0.9 if no response headers are available). In neither case r->http_version may be upgraded. The former code downgraded response from HTTP/1.1 to HTTP/1.0 for no reason, causing various problems (see ticket #66). It was also possible that HTTP/0.9 requests were upgraded to HTTP/1.0. diff --git a/src/http/modules/ngx_http_scgi_module.c b/src/http/modules/ngx_http_scgi_module.c --- a/src/http/modules/ngx_http_scgi_module.c +++ b/src/http/modules/ngx_http_scgi_module.c @@ -857,11 +857,7 @@ ngx_http_scgi_process_status_line(ngx_ht } if (rc == NGX_ERROR) { - - r->http_version = NGX_HTTP_VERSION_9; - u->process_header = ngx_http_scgi_process_header; - return ngx_http_scgi_process_header(r); } @@ -961,10 +957,6 @@ ngx_http_scgi_process_header(ngx_http_re ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "http scgi header done"); - if (r->http_version > NGX_HTTP_VERSION_9) { - return NGX_OK; - } - u = r->upstream; if (u->headers_in.status) { @@ -978,17 +970,15 @@ ngx_http_scgi_process_header(ngx_http_re return NGX_HTTP_UPSTREAM_INVALID_HEADER; } - r->http_version = NGX_HTTP_VERSION_10; u->headers_in.status_n = status; u->headers_in.status_line = *status_line; } else if (u->headers_in.location) { - r->http_version = NGX_HTTP_VERSION_10; u->headers_in.status_n = 302; ngx_str_set(&u->headers_in.status_line, "302 Moved Temporarily"); - } else { + } else if (u->headers_in.status_n == 0) { ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "upstream sent neither valid HTTP/1.0 header " "nor \"Status\" header line"); From mdounin at mdounin.ru Mon Dec 12 19:18:58 2011 From: mdounin at mdounin.ru (Maxim Dounin) Date: Mon, 12 Dec 2011 22:18:58 +0300 Subject: [PATCH 0 of 3] scgi patches Message-ID: Hello! Updated patch (or, rather, series). Discussed with Manlio Perillo and Valentin V. Bartenev. Maxim Dounin From mdounin at mdounin.ru Mon Dec 12 19:18:59 2011 From: mdounin at mdounin.ru (Maxim Dounin) Date: Mon, 12 Dec 2011 22:18:59 +0300 Subject: [PATCH 1 of 3] Fixed incorrect use of r->http_version in scgi module In-Reply-To: References: Message-ID: <8539c06e005df149af9a.1323713939@vm-bsd.mdounin.ru> # HG changeset patch # User Maxim Dounin # Date 1323713242 -10800 # Node ID 8539c06e005df149af9aeafbf5eedfb565796ecf # Parent 189afff6503fdb14e2ba72336a68d6673637f7d7 Fixed incorrect use of r->http_version in scgi module. The r->http_version is a version of client's request, and modules must not set it unless they are really willing to downgrade protocol version used for a response (i.e. to HTTP/0.9 if no response headers are available). In neither case r->http_version may be upgraded. The former code downgraded response from HTTP/1.1 to HTTP/1.0 for no reason, causing various problems (see ticket #66). It was also possible that HTTP/0.9 requests were upgraded to HTTP/1.0. diff --git a/src/http/modules/ngx_http_scgi_module.c b/src/http/modules/ngx_http_scgi_module.c --- a/src/http/modules/ngx_http_scgi_module.c +++ b/src/http/modules/ngx_http_scgi_module.c @@ -857,11 +857,7 @@ ngx_http_scgi_process_status_line(ngx_ht } if (rc == NGX_ERROR) { - - r->http_version = NGX_HTTP_VERSION_9; - u->process_header = ngx_http_scgi_process_header; - return ngx_http_scgi_process_header(r); } @@ -961,12 +957,12 @@ ngx_http_scgi_process_header(ngx_http_re ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "http scgi header done"); - if (r->http_version > NGX_HTTP_VERSION_9) { + u = r->upstream; + + if (u->headers_in.status_n) { return NGX_OK; } - u = r->upstream; - if (u->headers_in.status) { status_line = &u->headers_in.status->value; @@ -978,12 +974,10 @@ ngx_http_scgi_process_header(ngx_http_re return NGX_HTTP_UPSTREAM_INVALID_HEADER; } - r->http_version = NGX_HTTP_VERSION_10; u->headers_in.status_n = status; u->headers_in.status_line = *status_line; } else if (u->headers_in.location) { - r->http_version = NGX_HTTP_VERSION_10; u->headers_in.status_n = 302; ngx_str_set(&u->headers_in.status_line, "302 Moved Temporarily"); From mdounin at mdounin.ru Mon Dec 12 19:19:00 2011 From: mdounin at mdounin.ru (Maxim Dounin) Date: Mon, 12 Dec 2011 22:19:00 +0300 Subject: [PATCH 2 of 3] Scgi: removed duplicate function declaration In-Reply-To: References: Message-ID: <055c3b0ac991ebc19306.1323713940@vm-bsd.mdounin.ru> # HG changeset patch # User Maxim Dounin # Date 1323713243 -10800 # Node ID 055c3b0ac991ebc1930681c665a5c1e5d0b78f8c # Parent 8539c06e005df149af9aeafbf5eedfb565796ecf Scgi: removed duplicate function declaration. diff --git a/src/http/modules/ngx_http_scgi_module.c b/src/http/modules/ngx_http_scgi_module.c --- a/src/http/modules/ngx_http_scgi_module.c +++ b/src/http/modules/ngx_http_scgi_module.c @@ -36,7 +36,6 @@ static ngx_int_t ngx_http_scgi_create_re static ngx_int_t ngx_http_scgi_reinit_request(ngx_http_request_t *r); static ngx_int_t ngx_http_scgi_process_status_line(ngx_http_request_t *r); static ngx_int_t ngx_http_scgi_process_header(ngx_http_request_t *r); -static ngx_int_t ngx_http_scgi_process_header(ngx_http_request_t *r); static void ngx_http_scgi_abort_request(ngx_http_request_t *r); static void ngx_http_scgi_finalize_request(ngx_http_request_t *r, ngx_int_t rc); From mdounin at mdounin.ru Mon Dec 12 19:19:01 2011 From: mdounin at mdounin.ru (Maxim Dounin) Date: Mon, 12 Dec 2011 22:19:01 +0300 Subject: [PATCH 3 of 3] Scgi: removed error if there is no Status header In-Reply-To: References: Message-ID: # HG changeset patch # User Maxim Dounin # Date 1323713244 -10800 # Node ID b412333cff4fd53de8dbf4a3bedbc86c201fdece # Parent 055c3b0ac991ebc1930681c665a5c1e5d0b78f8c Scgi: removed error if there is no Status header. The SCGI specification doesn't specify format of the response, and assuming CGI specs should be used there is no reason to complain. RFC 3875 explicitly states that "A Status header field is optional, and status 200 'OK' is assumed if it is omitted". diff --git a/src/http/modules/ngx_http_scgi_module.c b/src/http/modules/ngx_http_scgi_module.c --- a/src/http/modules/ngx_http_scgi_module.c +++ b/src/http/modules/ngx_http_scgi_module.c @@ -982,9 +982,6 @@ ngx_http_scgi_process_header(ngx_http_re "302 Moved Temporarily"); } else { - ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, - "upstream sent neither valid HTTP/1.0 header " - "nor \"Status\" header line"); u->headers_in.status_n = 200; ngx_str_set(&u->headers_in.status_line, "200 OK"); } From mdounin at mdounin.ru Tue Dec 13 16:59:42 2011 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Tue, 13 Dec 2011 16:59:42 +0000 Subject: [nginx] svn commit: r4346 - in branches/stable-1.0/src: core http/modules/perl Message-ID: <20111213165942.8CB173F9C21@mail.nginx.com> Author: mdounin Date: 2011-12-13 16:59:41 +0000 (Tue, 13 Dec 2011) New Revision: 4346 Log: Version bump. Modified: branches/stable-1.0/src/core/nginx.h branches/stable-1.0/src/http/modules/perl/nginx.pm Modified: branches/stable-1.0/src/core/nginx.h =================================================================== --- branches/stable-1.0/src/core/nginx.h 2011-12-12 14:18:15 UTC (rev 4345) +++ branches/stable-1.0/src/core/nginx.h 2011-12-13 16:59:41 UTC (rev 4346) @@ -8,8 +8,8 @@ #define _NGINX_H_INCLUDED_ -#define nginx_version 1000010 -#define NGINX_VERSION "1.0.10" +#define nginx_version 1000011 +#define NGINX_VERSION "1.0.11" #define NGINX_VER "nginx/" NGINX_VERSION #define NGINX_VAR "NGINX" Modified: branches/stable-1.0/src/http/modules/perl/nginx.pm =================================================================== --- branches/stable-1.0/src/http/modules/perl/nginx.pm 2011-12-12 14:18:15 UTC (rev 4345) +++ branches/stable-1.0/src/http/modules/perl/nginx.pm 2011-12-13 16:59:41 UTC (rev 4346) @@ -48,7 +48,7 @@ HTTP_INSUFFICIENT_STORAGE ); -our $VERSION = '1.0.10'; +our $VERSION = '1.0.11'; require XSLoader; XSLoader::load('nginx', $VERSION); From mdounin at mdounin.ru Tue Dec 13 17:58:18 2011 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Tue, 13 Dec 2011 17:58:18 +0000 Subject: [nginx] svn commit: r4347 - in branches/stable-1.0: . docs misc src/http/modules Message-ID: <20111213175818.B300C3F9C24@mail.nginx.com> Author: mdounin Date: 2011-12-13 17:58:18 +0000 (Tue, 13 Dec 2011) New Revision: 4347 Log: Merge of r4000, r4014, r4265, r4321, r4342, r4343: Infrastructure changes: *) Don't ignore xmllint errors. *) Added missing dependencies for the CHANGES{,ru} targets. Pass string params to xsltproc. *) Ancient incomplete ngx_http_status_module removal. *) Compute the repository root from the checkout. *) Fixed RELEASE target to correctly call "release" one. Removed: branches/stable-1.0/src/http/modules/ngx_http_status_module.c Modified: branches/stable-1.0/ branches/stable-1.0/docs/GNUmakefile branches/stable-1.0/misc/GNUmakefile Property changes on: branches/stable-1.0 ___________________________________________________________________ Modified: svn:mergeinfo - /trunk:3960-3974,3977-3987,3991-3996,3998,4003-4007,4009-4013,4015-4018,4020,4023,4025-4027,4034-4065,4073,4077,4086-4090,4094-4102,4106-4108,4113-4114,4129-4137,4143,4147-4152,4154-4158,4177,4179,4182-4184,4186-4187,4189-4205,4207,4209-4210,4212,4219-4220,4229-4230,4232,4235-4237,4268,4280,4283 + /trunk:3960-3974,3977-3987,3991-3996,3998,4000,4003-4007,4009-4018,4020,4023,4025-4027,4034-4065,4073,4077,4086-4090,4094-4102,4106-4108,4113-4114,4129-4137,4143,4147-4152,4154-4158,4177,4179,4182-4184,4186-4187,4189-4205,4207,4209-4210,4212,4219-4220,4229-4230,4232,4235-4237,4265,4268,4280,4283,4321,4342-4343 Modified: branches/stable-1.0/docs/GNUmakefile =================================================================== --- branches/stable-1.0/docs/GNUmakefile 2011-12-13 16:59:41 UTC (rev 4346) +++ branches/stable-1.0/docs/GNUmakefile 2011-12-13 17:58:18 UTC (rev 4347) @@ -16,7 +16,7 @@ endef define XSLT - xmllint --noout --valid $2; \ + xmllint --noout --valid $2 xsltproc -o $3 \ $(shell echo $4 \\ | sed -e "s/\([^= ]*\)=\([^= ]*\)/--param \1 \"'\2'\"/g") \ @@ -29,21 +29,23 @@ $(TEMP)/$(NGINX)/CHANGES.ru: docs/xml/nginx/changes.xml \ + docs/xml/change_log_conf.xml \ docs/xslt/changes.xslt test -d $(TEMP)/$(NGINX) || mkdir -p $(TEMP)/$(NGINX) - xsltproc --param lang "'ru'" \ + xsltproc --stringparam lang ru \ -o $(TEMP)/$(NGINX)/CHANGES.ru \ 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) - xsltproc --param lang "'en'" \ + xsltproc --stringparam lang en \ -o $(TEMP)/$(NGINX)/CHANGES \ docs/xslt/changes.xslt docs/xml/nginx/changes.xml Modified: branches/stable-1.0/misc/GNUmakefile =================================================================== --- branches/stable-1.0/misc/GNUmakefile 2011-12-13 16:59:41 UTC (rev 4346) +++ branches/stable-1.0/misc/GNUmakefile 2011-12-13 17:58:18 UTC (rev 4347) @@ -3,7 +3,7 @@ | sed -e 's/^.*\"\(.*\)\"/\1/') NGINX = nginx-$(VER) TEMP = tmp -REPO = svn://svn.nginx.com +REPO = $(shell svn info | sed -n 's/^Repository Root: //p') OBJS = objs.msvc8 OPENSSL = openssl-0.9.8r @@ -26,8 +26,6 @@ rm -r $(TEMP)/$(NGINX)/src/mysql - rm $(TEMP)/$(NGINX)/src/http/modules/ngx_http_status_module.c - mv $(TEMP)/$(NGINX)/docs/text/LICENSE $(TEMP)/$(NGINX) mv $(TEMP)/$(NGINX)/docs/text/README $(TEMP)/$(NGINX) mv $(TEMP)/$(NGINX)/docs/html $(TEMP)/$(NGINX) @@ -48,13 +46,13 @@ svn ci -F $(TEMP)/message echo "release-$(VER) tag" > $(TEMP)/message - svn copy $(REPO)/nginx/branches/stable-1.0 \ - $(REPO)/nginx/tags/release-$(VER) \ + svn copy $(REPO)/branches/stable-1.0 \ + $(REPO)/tags/release-$(VER) \ -F $(TEMP)/message svn up - $(MAKE) release + $(MAKE) -f misc/GNUmakefile release snapshot: @@ -73,8 +71,6 @@ rm -r $(TEMP)/$(NGINX)/src/mysql - rm $(TEMP)/$(NGINX)/src/http/modules/ngx_http_status_module.c - mv $(TEMP)/$(NGINX)/docs/text/LICENSE $(TEMP)/$(NGINX) mv $(TEMP)/$(NGINX)/docs/text/README $(TEMP)/$(NGINX) mv $(TEMP)/$(NGINX)/docs/html $(TEMP)/$(NGINX) Deleted: branches/stable-1.0/src/http/modules/ngx_http_status_module.c =================================================================== --- branches/stable-1.0/src/http/modules/ngx_http_status_module.c 2011-12-13 16:59:41 UTC (rev 4346) +++ branches/stable-1.0/src/http/modules/ngx_http_status_module.c 2011-12-13 17:58:18 UTC (rev 4347) @@ -1,309 +0,0 @@ - -/* - * Copyright (C) Igor Sysoev - */ - - -#include -#include -#include - - -typedef struct { - ngx_http_request_t *request; - ngx_pool_t *pool; - ngx_chain_t *head; - ngx_buf_t *last; - size_t size; -} ngx_http_status_ctx_t; - - -static ngx_int_t ngx_http_status(ngx_http_status_ctx_t *ctx); -static char *ngx_http_set_status(ngx_conf_t *cf, ngx_command_t *cmd, - void *conf); - -static ngx_command_t ngx_http_status_commands[] = { - - { ngx_string("status"), - NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, - ngx_http_set_status, - 0, - 0, - NULL }, - - ngx_null_command -}; - - - -static ngx_http_module_t ngx_http_status_module_ctx = { - NULL, /* pre conf */ - - NULL, /* create main configuration */ - NULL, /* init main configuration */ - - NULL, /* create server configuration */ - NULL, /* merge server configuration */ - - NULL, /* create location configuration */ - NULL /* merge location configuration */ -}; - - -ngx_module_t ngx_http_status_module = { - NGX_MODULE, - &ngx_http_status_module_ctx, /* module context */ - ngx_http_status_commands, /* module directives */ - NGX_HTTP_MODULE, /* module type */ - NULL, /* init module */ - NULL /* init process */ -}; - - -static ngx_int_t ngx_http_status_handler(ngx_http_request_t *r) -{ - ngx_int_t rc; - ngx_http_status_ctx_t ctx; - - if (r->method != NGX_HTTP_GET && r->method != NGX_HTTP_HEAD) { - return NGX_HTTP_NOT_ALLOWED; - } - - rc = ngx_http_discard_body(r); - - if (rc != NGX_OK && rc != NGX_AGAIN) { - return rc; - } - - r->headers_out.content_type = ngx_list_push(&r->headers_out.headers); - if (r->headers_out.content_type == NULL) { - return NGX_HTTP_INTERNAL_SERVER_ERROR; - } - - r->headers_out.content_type->key.len = 0; - r->headers_out.content_type->key.data = NULL; - r->headers_out.content_type->value.len = sizeof("text/plain") - 1; - r->headers_out.content_type->value.data = (u_char *) "text/plain"; - - if (r->method == NGX_HTTP_HEAD) { - r->headers_out.status = NGX_HTTP_OK; - - rc = ngx_http_send_header(r); - - if (rc == NGX_ERROR || rc > NGX_OK || r->header_only) { - return rc; - } - } - - ctx.request = r; - ctx.pool = r->pool; - ctx.head = NULL; - ctx.size = 0; - - if (ngx_http_status(&ctx) != NGX_OK) { - return NGX_HTTP_INTERNAL_SERVER_ERROR; - } - - r->headers_out.status = NGX_HTTP_OK; - r->headers_out.content_length_n = ctx.size; - - rc = ngx_http_send_header(r); - - if (rc == NGX_ERROR || rc > NGX_OK || r->header_only) { - return rc; - } - - if (!r->main) { - ctx.last->last_buf = 1; - } - - return ngx_http_output_filter(r, ctx.head); -} - - -static ngx_int_t ngx_http_status(ngx_http_status_ctx_t *ctx) -{ - u_char ch; - size_t len, n; - ngx_uint_t i, dash; - ngx_buf_t *b; - ngx_chain_t *cl, **ll; - ngx_connection_t *c; - ngx_http_request_t *r; - ngx_http_core_main_conf_t *cmcf; - - cmcf = ngx_http_get_module_main_conf(ctx->request, ngx_http_core_module); - -#if (NGX_SUPPRESS_WARN) - b = NULL; - ll = NULL; -#endif - - dash = 0; - - /* TODO: old connections */ - - c = ngx_cycle->connections; - for (i = 0; i < ngx_cycle->connection_n; i++) { - - /* TODO: trylock connection mutex */ - - r = c[i].data; - if (r && r->signature == NGX_HTTP_MODULE) { - - /* STUB: should be NGX_PID_T_LEN */ - len = NGX_INT64_LEN /* pid */ - + 1 + NGX_INT32_LEN /* connection */ - + 1 + 1 /* state */ - + 1 + NGX_INET_ADDRSTRLEN - + 1 + (r->server_name ? cmcf->max_server_name_len : 1) - + 2; /* "\r\n" */ - - /* BUG: cmcf->max_server_name_len and "*.domain.tld" */ - - - if (r->request_line.len) { - len += 1 + 1 + r->request_line.len + 1; - } - - if (!(b = ngx_create_temp_buf(ctx->pool, len))) { - /* TODO: unlock mutex */ - return NGX_ERROR; - } - - b->last = ngx_sprintf(b->last, "%P %5ui", ngx_pid, i); - - switch (r->http_state) { - case NGX_HTTP_INITING_REQUEST_STATE: - ch = 'I'; - break; - - case NGX_HTTP_READING_REQUEST_STATE: - ch = 'R'; - break; - - case NGX_HTTP_PROCESS_REQUEST_STATE: - ch = 'P'; - break; - - case NGX_HTTP_WRITING_REQUEST_STATE: - ch = 'W'; - break; - - case NGX_HTTP_KEEPALIVE_STATE: - ch = 'K'; - break; - - default: - ch = '?'; - } - - *(b->last++) = ' '; - *(b->last++) = ch; - - *(b->last++) = ' '; - b->last = ngx_cpymem(b->last, c[i].addr_text.data, - c[i].addr_text.len); - for (n = c[i].addr_text.len; n < NGX_INET_ADDRSTRLEN; n++) { - *(b->last++) = ' '; - } - - *(b->last++) = ' '; - if (r->server_name) { - b->last = ngx_cpymem(b->last, r->server_name->data, - r->server_name->len); - for (n = r->server_name->len; - n < cmcf->max_server_name_len; - n++) - { - *(b->last++) = ' '; - } - - } else { - *(b->last++) = '?'; - } - - if (r->request_line.len) { - *(b->last++) = ' '; - *(b->last++) = '"'; - b->last = ngx_cpymem(b->last, r->request_line.data, - r->request_line.len); - *(b->last++) = '"'; - - } - - *(b->last++) = CR; *(b->last++) = LF; - - dash = 0; - - } else if (c[i].fd != -1) { - len = NGX_INT64_LEN /* pid */ - + 1 + NGX_INT32_LEN /* connection */ - + 1 + 1 /* state */ - + 2; /* "\r\n" */ - - if (!(b = ngx_create_temp_buf(ctx->pool, len))) { - /* TODO: unlock mutex */ - return NGX_ERROR; - } - - b->last = ngx_sprintf(b->last, "%P %5ui", ngx_pid, i); - - *(b->last++) = ' '; - *(b->last++) = 's'; - - *(b->last++) = CR; *(b->last++) = LF; - - dash = 0; - - } else if (!dash) { - len = 3; - - if (!(b = ngx_create_temp_buf(ctx->pool, len))) { - /* TODO: unlock mutex */ - return NGX_ERROR; - } - - *(b->last++) = '-'; *(b->last++) = CR; *(b->last++) = LF; - - dash = 1; - - } else { - continue; - } - - /* TODO: unlock mutex */ - - if (!(cl = ngx_alloc_chain_link(ctx->pool))) { - return NGX_ERROR; - } - - if (ctx->head) { - *ll = cl; - - } else { - ctx->head = cl; - } - - cl->buf = b; - cl->next = NULL; - ll = &cl->next; - - ctx->size += b->last - b->pos; - } - - ctx->last = b; - - return NGX_OK; -} - - -static char *ngx_http_set_status(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) -{ - ngx_http_core_loc_conf_t *clcf; - - clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module); - clcf->handler = ngx_http_status_handler; - - return NGX_CONF_OK; -} From mdounin at mdounin.ru Tue Dec 13 18:07:52 2011 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Tue, 13 Dec 2011 18:07:52 +0000 Subject: [nginx] svn commit: r4348 - in branches/stable-1.0: . auto docs/man Message-ID: <20111213180752.B84293F9C36@mail.nginx.com> Author: mdounin Date: 2011-12-13 18:07:52 +0000 (Tue, 13 Dec 2011) New Revision: 4348 Log: Manpage changes: *) Support link. *) Commented out reference to non-existing nginx.conf(5). *) Rebuild manpage only if needed. Modified: branches/stable-1.0/ branches/stable-1.0/auto/install branches/stable-1.0/docs/man/nginx.8 Property changes on: branches/stable-1.0 ___________________________________________________________________ Modified: svn:mergeinfo - /trunk:3960-3974,3977-3987,3991-3996,3998,4000,4003-4007,4009-4018,4020,4023,4025-4027,4034-4065,4073,4077,4086-4090,4094-4102,4106-4108,4113-4114,4129-4137,4143,4147-4152,4154-4158,4177,4179,4182-4184,4186-4187,4189-4205,4207,4209-4210,4212,4219-4220,4229-4230,4232,4235-4237,4265,4268,4280,4283,4321,4342-4343 + /trunk:3960-3974,3977-3987,3991-3996,3998,4000-4018,4020,4023,4025-4027,4034-4065,4073,4077,4086-4090,4094-4102,4106-4108,4113-4114,4129-4137,4143,4147-4152,4154-4158,4177,4179,4182-4184,4186-4187,4189-4205,4207,4209-4210,4212,4219-4220,4229-4230,4232,4235-4237,4265,4268,4280,4283,4321,4342-4343 Modified: branches/stable-1.0/auto/install =================================================================== --- branches/stable-1.0/auto/install 2011-12-13 17:58:18 UTC (rev 4347) +++ branches/stable-1.0/auto/install 2011-12-13 18:07:52 UTC (rev 4348) @@ -74,7 +74,9 @@ cat << END >> $NGX_MAKEFILE -manpage: +manpage: $NGX_OBJS/nginx.8 + +$NGX_OBJS/nginx.8: man/nginx.8 $NGX_AUTO_CONFIG_H sed -e "s|%%PREFIX%%|$NGX_PREFIX|" \\ -e "s|%%PID_PATH%%|$NGX_PID_PATH|" \\ -e "s|%%CONF_PATH%%|$NGX_CONF_PATH|" \\ Modified: branches/stable-1.0/docs/man/nginx.8 =================================================================== --- branches/stable-1.0/docs/man/nginx.8 2011-12-13 17:58:18 UTC (rev 4347) +++ branches/stable-1.0/docs/man/nginx.8 2011-12-13 18:07:52 UTC (rev 4348) @@ -24,7 +24,7 @@ .\" SUCH DAMAGE. .\" .\" -.Dd November 14, 2010 +.Dd August 10, 2011 .Dt NGINX 8 .Os .Sh NAME @@ -177,25 +177,25 @@ .Pa ~/mynginx.conf with global directives for PID and quantity of worker processes. .Sh SEE ALSO -.Xr nginx.conf 5 +.\"Xr nginx.conf 5 +.\"Pp +Documentation at +.Pa http://nginx.org/ +and +.Pa http://sysoev.ru/nginx/ . +.Pp +For questions and technical support, please refer to +.Pa http://nginx.org/en/support.html . .Sh HISTORY Development of .Nm started in 2002, with the first public release on October 4, 2004. .Sh AUTHORS +.An -nosplit .An Igor Sysoev Aq igor at sysoev.ru .Pp -Documentation available on -.Pa http://nginx.org/ -and -.Pa http://sysoev.ru/nginx/ . -.Pp This manual page was written by .An Sergey A. Osokin Aq osa at FreeBSD.org.ru as a result of compilation of many .Nm documents all over the world. -.Sh BUGS -Report to mailing list -.Aq Li nginx at nginx.org -if you found one. From mdounin at mdounin.ru Tue Dec 13 18:15:28 2011 From: mdounin at mdounin.ru (Maxim Dounin) Date: Tue, 13 Dec 2011 22:15:28 +0400 Subject: [nginx] svn commit: r4348 - in branches/stable-1.0: . auto docs/man In-Reply-To: <20111213180752.B84293F9C36@mail.nginx.com> References: <20111213180752.B84293F9C36@mail.nginx.com> Message-ID: <20111213181528.GJ67687@mdounin.ru> Hello! On Tue, Dec 13, 2011 at 06:07:52PM +0000, mdounin at mdounin.ru wrote: > Author: mdounin > Date: 2011-12-13 18:07:52 +0000 (Tue, 13 Dec 2011) > New Revision: 4348 > > Log: > Manpage changes: Oops, "Merge of r4001, r4002, r4008:" should be here. Updated. > > *) Support link. > > *) Commented out reference to non-existing nginx.conf(5). > > *) Rebuild manpage only if needed. [...] Maxim Dounin From mdounin at mdounin.ru Tue Dec 13 18:30:15 2011 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Tue, 13 Dec 2011 18:30:15 +0000 Subject: [nginx] svn commit: r4349 - in branches/stable-1.0: . src/http Message-ID: <20111213183015.F26EE3F9C23@mail.nginx.com> Author: mdounin Date: 2011-12-13 18:30:15 +0000 (Tue, 13 Dec 2011) New Revision: 4349 Log: Merge of r4144: Upstream: clearing of u->peer.connection on close. This fixes crashes observed with some 3rd party balancer modules. Standard balancer modules (round-robin and ip hash) explicitly set pc->connection (aka u->peer.connection) to NULL and aren't affected. Modified: branches/stable-1.0/ branches/stable-1.0/src/http/ngx_http_upstream.c Property changes on: branches/stable-1.0 ___________________________________________________________________ Modified: svn:mergeinfo - /trunk:3960-3974,3977-3987,3991-3996,3998,4000-4018,4020,4023,4025-4027,4034-4065,4073,4077,4086-4090,4094-4102,4106-4108,4113-4114,4129-4137,4143,4147-4152,4154-4158,4177,4179,4182-4184,4186-4187,4189-4205,4207,4209-4210,4212,4219-4220,4229-4230,4232,4235-4237,4265,4268,4280,4283,4321,4342-4343 + /trunk:3960-3974,3977-3987,3991-3996,3998,4000-4018,4020,4023,4025-4027,4034-4065,4073,4077,4086-4090,4094-4102,4106-4108,4113-4114,4129-4137,4143-4144,4147-4152,4154-4158,4177,4179,4182-4184,4186-4187,4189-4205,4207,4209-4210,4212,4219-4220,4229-4230,4232,4235-4237,4265,4268,4280,4283,4321,4342-4343 Modified: branches/stable-1.0/src/http/ngx_http_upstream.c =================================================================== --- branches/stable-1.0/src/http/ngx_http_upstream.c 2011-12-13 18:07:52 UTC (rev 4348) +++ branches/stable-1.0/src/http/ngx_http_upstream.c 2011-12-13 18:30:15 UTC (rev 4349) @@ -2888,6 +2888,7 @@ #endif ngx_close_connection(u->peer.connection); + u->peer.connection = NULL; } #if 0 From mdounin at mdounin.ru Tue Dec 13 18:34:35 2011 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Tue, 13 Dec 2011 18:34:35 +0000 Subject: [nginx] svn commit: r4350 - in branches/stable-1.0: . src/http Message-ID: <20111213183435.4E69B3F9C39@mail.nginx.com> Author: mdounin Date: 2011-12-13 18:34:34 +0000 (Tue, 13 Dec 2011) New Revision: 4350 Log: Merge of r4153: Better handling of late upstream creation. Configuration with duplicate upstream blocks defined after first use, i.e. like server { ... location / { proxy_pass http://backend; } } upstream backend { ... } upstream backend { ... } now correctly results in "duplicate upstream" error. Additionally, upstream blocks defined after first use now handle various server directive parameters ("weight", "max_fails", etc.). Previously configuration like server { ... location / { proxy_pass http://backend; } } upstream backend { server 127.0.0.1 max_fails=5; } incorrectly resulted in "invalid parameter "max_fails=5"" error. Modified: branches/stable-1.0/ branches/stable-1.0/src/http/ngx_http_upstream.c Property changes on: branches/stable-1.0 ___________________________________________________________________ Modified: svn:mergeinfo - /trunk:3960-3974,3977-3987,3991-3996,3998,4000-4018,4020,4023,4025-4027,4034-4065,4073,4077,4086-4090,4094-4102,4106-4108,4113-4114,4129-4137,4143-4144,4147-4152,4154-4158,4177,4179,4182-4184,4186-4187,4189-4205,4207,4209-4210,4212,4219-4220,4229-4230,4232,4235-4237,4265,4268,4280,4283,4321,4342-4343 + /trunk:3960-3974,3977-3987,3991-3996,3998,4000-4018,4020,4023,4025-4027,4034-4065,4073,4077,4086-4090,4094-4102,4106-4108,4113-4114,4129-4137,4143-4144,4147-4158,4177,4179,4182-4184,4186-4187,4189-4205,4207,4209-4210,4212,4219-4220,4229-4230,4232,4235-4237,4265,4268,4280,4283,4321,4342-4343 Modified: branches/stable-1.0/src/http/ngx_http_upstream.c =================================================================== --- branches/stable-1.0/src/http/ngx_http_upstream.c 2011-12-13 18:30:15 UTC (rev 4349) +++ branches/stable-1.0/src/http/ngx_http_upstream.c 2011-12-13 18:34:34 UTC (rev 4350) @@ -4280,6 +4280,10 @@ continue; } + if (flags & NGX_HTTP_UPSTREAM_CREATE) { + uscfp[i]->flags = flags; + } + return uscfp[i]; } From mdounin at mdounin.ru Tue Dec 13 18:46:07 2011 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Tue, 13 Dec 2011 18:46:07 +0000 Subject: [nginx] svn commit: r4351 - in branches/stable-1.0: . src/http/modules Message-ID: <20111213184607.F14483F9C36@mail.nginx.com> Author: mdounin Date: 2011-12-13 18:46:07 +0000 (Tue, 13 Dec 2011) New Revision: 4351 Log: Merge of r4217, r4218: Fixed "expires @00h". Fixed "expires @time" with unknown last modified time (ticket #32). Modified: branches/stable-1.0/ branches/stable-1.0/src/http/modules/ngx_http_headers_filter_module.c Property changes on: branches/stable-1.0 ___________________________________________________________________ Modified: svn:mergeinfo - /trunk:3960-3974,3977-3987,3991-3996,3998,4000-4018,4020,4023,4025-4027,4034-4065,4073,4077,4086-4090,4094-4102,4106-4108,4113-4114,4129-4137,4143-4144,4147-4158,4177,4179,4182-4184,4186-4187,4189-4205,4207,4209-4210,4212,4219-4220,4229-4230,4232,4235-4237,4265,4268,4280,4283,4321,4342-4343 + /trunk:3960-3974,3977-3987,3991-3996,3998,4000-4018,4020,4023,4025-4027,4034-4065,4073,4077,4086-4090,4094-4102,4106-4108,4113-4114,4129-4137,4143-4144,4147-4158,4177,4179,4182-4184,4186-4187,4189-4205,4207,4209-4210,4212,4217-4220,4229-4230,4232,4235-4237,4265,4268,4280,4283,4321,4342-4343 Modified: branches/stable-1.0/src/http/modules/ngx_http_headers_filter_module.c =================================================================== --- branches/stable-1.0/src/http/modules/ngx_http_headers_filter_module.c 2011-12-13 18:34:34 UTC (rev 4350) +++ branches/stable-1.0/src/http/modules/ngx_http_headers_filter_module.c 2011-12-13 18:46:07 UTC (rev 4351) @@ -253,7 +253,7 @@ return NGX_ERROR; } - if (conf->expires_time == 0) { + if (conf->expires_time == 0 && conf->expires != NGX_HTTP_EXPIRES_DAILY) { ngx_memcpy(expires->value.data, ngx_cached_http_time.data, ngx_cached_http_time.len + 1); ngx_str_set(&cc->value, "max-age=0"); @@ -262,16 +262,16 @@ now = ngx_time(); - if (conf->expires == NGX_HTTP_EXPIRES_ACCESS - || r->headers_out.last_modified_time == -1) + if (conf->expires == NGX_HTTP_EXPIRES_DAILY) { + expires_time = ngx_next_time(conf->expires_time); + max_age = expires_time - now; + + } else if (conf->expires == NGX_HTTP_EXPIRES_ACCESS + || r->headers_out.last_modified_time == -1) { expires_time = now + conf->expires_time; max_age = conf->expires_time; - } else if (conf->expires == NGX_HTTP_EXPIRES_DAILY) { - expires_time = ngx_next_time(conf->expires_time); - max_age = expires_time - now; - } else { expires_time = r->headers_out.last_modified_time + conf->expires_time; max_age = expires_time - now; From mdounin at mdounin.ru Tue Dec 13 18:59:18 2011 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Tue, 13 Dec 2011 18:59:18 +0000 Subject: [nginx] svn commit: r4352 - in branches/stable-1.0: . src/os/unix Message-ID: <20111213185918.F0AA13F9C1D@mail.nginx.com> Author: mdounin Date: 2011-12-13 18:59:18 +0000 (Tue, 13 Dec 2011) New Revision: 4352 Log: Merge of r4221, r4222: Fixed unix ngx_write_chain_to_file() to return total bytes written. Previously result of last iteration's writev() was returned. This was unnoticed as return value was only used if chain contained only one or two buffers. Modified: branches/stable-1.0/ branches/stable-1.0/src/os/unix/ngx_files.c Property changes on: branches/stable-1.0 ___________________________________________________________________ Modified: svn:mergeinfo - /trunk:3960-3974,3977-3987,3991-3996,3998,4000-4018,4020,4023,4025-4027,4034-4065,4073,4077,4086-4090,4094-4102,4106-4108,4113-4114,4129-4137,4143-4144,4147-4158,4177,4179,4182-4184,4186-4187,4189-4205,4207,4209-4210,4212,4217-4220,4229-4230,4232,4235-4237,4265,4268,4280,4283,4321,4342-4343 + /trunk:3960-3974,3977-3987,3991-3996,3998,4000-4018,4020,4023,4025-4027,4034-4065,4073,4077,4086-4090,4094-4102,4106-4108,4113-4114,4129-4137,4143-4144,4147-4158,4177,4179,4182-4184,4186-4187,4189-4205,4207,4209-4210,4212,4217-4222,4229-4230,4232,4235-4237,4265,4268,4280,4283,4321,4342-4343 Modified: branches/stable-1.0/src/os/unix/ngx_files.c =================================================================== --- branches/stable-1.0/src/os/unix/ngx_files.c 2011-12-13 18:46:07 UTC (rev 4351) +++ branches/stable-1.0/src/os/unix/ngx_files.c 2011-12-13 18:59:18 UTC (rev 4352) @@ -153,7 +153,7 @@ { u_char *prev; size_t size; - ssize_t n; + ssize_t total, n; ngx_array_t vec; struct iovec *iov, iovs[NGX_IOVS]; @@ -165,6 +165,8 @@ offset); } + total = 0; + vec.elts = iovs; vec.size = sizeof(struct iovec); vec.nalloc = NGX_IOVS; @@ -202,8 +204,15 @@ if (vec.nelts == 1) { iov = vec.elts; - return ngx_write_file(file, (u_char *) iov[0].iov_base, - iov[0].iov_len, offset); + + n = ngx_write_file(file, (u_char *) iov[0].iov_base, + iov[0].iov_len, offset); + + if (n == NGX_ERROR) { + return n; + } + + return total + n; } if (file->sys_offset != offset) { @@ -233,10 +242,11 @@ file->sys_offset += n; file->offset += n; + total += n; } while (cl); - return n; + return total; } From mdounin at mdounin.ru Tue Dec 13 19:01:10 2011 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Tue, 13 Dec 2011 19:01:10 +0000 Subject: [nginx] svn commit: r4353 - in branches/stable-1.0: . src/core Message-ID: <20111213190110.81E7A3F9C1D@mail.nginx.com> Author: mdounin Date: 2011-12-13 19:01:10 +0000 (Tue, 13 Dec 2011) New Revision: 4353 Log: Merge of r4223: FreeBSD's MALLOC_OPTIONS must be set before any malloc() call. The bug has been introduced in r3799. Modified: branches/stable-1.0/ branches/stable-1.0/src/core/nginx.c Property changes on: branches/stable-1.0 ___________________________________________________________________ Modified: svn:mergeinfo - /trunk:3960-3974,3977-3987,3991-3996,3998,4000-4018,4020,4023,4025-4027,4034-4065,4073,4077,4086-4090,4094-4102,4106-4108,4113-4114,4129-4137,4143-4144,4147-4158,4177,4179,4182-4184,4186-4187,4189-4205,4207,4209-4210,4212,4217-4222,4229-4230,4232,4235-4237,4265,4268,4280,4283,4321,4342-4343 + /trunk:3960-3974,3977-3987,3991-3996,3998,4000-4018,4020,4023,4025-4027,4034-4065,4073,4077,4086-4090,4094-4102,4106-4108,4113-4114,4129-4137,4143-4144,4147-4158,4177,4179,4182-4184,4186-4187,4189-4205,4207,4209-4210,4212,4217-4223,4229-4230,4232,4235-4237,4265,4268,4280,4283,4321,4342-4343 Modified: branches/stable-1.0/src/core/nginx.c =================================================================== --- branches/stable-1.0/src/core/nginx.c 2011-12-13 18:59:18 UTC (rev 4352) +++ branches/stable-1.0/src/core/nginx.c 2011-12-13 19:01:10 UTC (rev 4353) @@ -203,6 +203,10 @@ ngx_cycle_t *cycle, init_cycle; ngx_core_conf_t *ccf; +#if (NGX_FREEBSD) + ngx_debug_init(); +#endif + if (ngx_strerror_init() != NGX_OK) { return 1; } @@ -260,10 +264,6 @@ } } -#if (NGX_FREEBSD) - ngx_debug_init(); -#endif - /* TODO */ ngx_max_sockets = -1; ngx_time_init(); From appa at perusio.net Tue Dec 13 19:38:33 2011 From: appa at perusio.net (=?UTF-8?B?QW50w7NuaW8=?= P. P. Almeida) Date: Tue, 13 Dec 2011 19:38:33 +0000 Subject: [PATCH 0 of 5] cache patches In-Reply-To: <20111212103437.GR67687@mdounin.ru> References: <87d3buejpe.wl%appa@perusio.net> <20111212100002.GO67687@mdounin.ru> <87aa6ydr35.wl%appa@perusio.net> <20111212103437.GR67687@mdounin.ru> Message-ID: <87liqgcldy.wl%appa@perusio.net> > This may be changed to user setting, but I don't want to as this > is expected to move away from timer to event-based notification > some day. Going off in a tangent here. I gather this patches are the first steps towards implementing busy locks in full. If so then may I suggest, just in case you haven't had yet the opportunity to look into, that the tengine distribution already has implemented this, i.e., busy locks. There are several core modules patched, namely event. Perhaps this would speed up the process. Just an idea. --- appa From mdounin at mdounin.ru Wed Dec 14 13:06:45 2011 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Wed, 14 Dec 2011 13:06:45 +0000 Subject: [nginx] svn commit: r4354 - in branches/stable-1.0: . src/core src/mail src/os/unix Message-ID: <20111214130645.874F93F9C34@mail.nginx.com> Author: mdounin Date: 2011-12-14 13:06:45 +0000 (Wed, 14 Dec 2011) New Revision: 4354 Log: Merge of r4227, r4228: Fixed range checking for the "somaxconn" sysctl. Fixed port range checking. Modified: branches/stable-1.0/ branches/stable-1.0/src/core/ngx_inet.c branches/stable-1.0/src/mail/ngx_mail_auth_http_module.c branches/stable-1.0/src/os/unix/ngx_darwin_init.c branches/stable-1.0/src/os/unix/ngx_freebsd_init.c Property changes on: branches/stable-1.0 ___________________________________________________________________ Modified: svn:mergeinfo - /trunk:3960-3974,3977-3987,3991-3996,3998,4000-4018,4020,4023,4025-4027,4034-4065,4073,4077,4086-4090,4094-4102,4106-4108,4113-4114,4129-4137,4143-4144,4147-4158,4177,4179,4182-4184,4186-4187,4189-4205,4207,4209-4210,4212,4217-4223,4229-4230,4232,4235-4237,4265,4268,4280,4283,4321,4342-4343 + /trunk:3960-3974,3977-3987,3991-3996,3998,4000-4018,4020,4023,4025-4027,4034-4065,4073,4077,4086-4090,4094-4102,4106-4108,4113-4114,4129-4137,4143-4144,4147-4158,4177,4179,4182-4184,4186-4187,4189-4205,4207,4209-4210,4212,4217-4223,4227-4230,4232,4235-4237,4265,4268,4280,4283,4321,4342-4343 Modified: branches/stable-1.0/src/core/ngx_inet.c =================================================================== --- branches/stable-1.0/src/core/ngx_inet.c 2011-12-13 19:01:10 UTC (rev 4353) +++ branches/stable-1.0/src/core/ngx_inet.c 2011-12-14 13:06:45 UTC (rev 4354) @@ -671,7 +671,7 @@ n = ngx_atoi(port, len); - if (n < 1 || n > 65536) { + if (n < 1 || n > 65535) { u->err = "invalid port"; return NGX_ERROR; } @@ -695,7 +695,7 @@ if (n != NGX_ERROR) { - if (n < 1 || n > 65536) { + if (n < 1 || n > 65535) { u->err = "invalid port"; return NGX_ERROR; } @@ -835,7 +835,7 @@ n = ngx_atoi(port, len); - if (n < 1 || n > 65536) { + if (n < 1 || n > 65535) { u->err = "invalid port"; return NGX_ERROR; } Modified: branches/stable-1.0/src/mail/ngx_mail_auth_http_module.c =================================================================== --- branches/stable-1.0/src/mail/ngx_mail_auth_http_module.c 2011-12-13 19:01:10 UTC (rev 4353) +++ branches/stable-1.0/src/mail/ngx_mail_auth_http_module.c 2011-12-14 13:06:45 UTC (rev 4354) @@ -783,7 +783,7 @@ sin->sin_family = AF_INET; port = ngx_atoi(ctx->port.data, ctx->port.len); - if (port == NGX_ERROR || port < 1 || port > 65536) { + if (port == NGX_ERROR || port < 1 || port > 65535) { ngx_log_error(NGX_LOG_ERR, s->connection->log, 0, "auth http server %V sent invalid server " "port:\"%V\"", Modified: branches/stable-1.0/src/os/unix/ngx_darwin_init.c =================================================================== --- branches/stable-1.0/src/os/unix/ngx_darwin_init.c 2011-12-13 19:01:10 UTC (rev 4353) +++ branches/stable-1.0/src/os/unix/ngx_darwin_init.c 2011-12-14 13:06:45 UTC (rev 4354) @@ -58,7 +58,6 @@ ngx_int_t ngx_os_specific_init(ngx_log_t *log) { - int somaxconn; size_t size; ngx_err_t err; ngx_uint_t i; @@ -125,12 +124,9 @@ ngx_ncpu = ngx_darwin_hw_ncpu; - somaxconn = 32676; - - if (ngx_darwin_kern_ipc_somaxconn > somaxconn) { + if (ngx_darwin_kern_ipc_somaxconn > 32767) { ngx_log_error(NGX_LOG_ALERT, log, 0, - "sysctl kern.ipc.somaxconn must be no more than %d", - somaxconn); + "sysctl kern.ipc.somaxconn must be less than 32768"); return NGX_ERROR; } Modified: branches/stable-1.0/src/os/unix/ngx_freebsd_init.c =================================================================== --- branches/stable-1.0/src/os/unix/ngx_freebsd_init.c 2011-12-13 19:01:10 UTC (rev 4353) +++ branches/stable-1.0/src/os/unix/ngx_freebsd_init.c 2011-12-14 13:06:45 UTC (rev 4354) @@ -97,7 +97,7 @@ ngx_int_t ngx_os_specific_init(ngx_log_t *log) { - int version, somaxconn; + int version; size_t size; ngx_err_t err; ngx_uint_t i; @@ -209,12 +209,9 @@ ngx_ncpu = ngx_freebsd_hw_ncpu; } - somaxconn = version < 600008 ? 32676 : 65535; - - if (ngx_freebsd_kern_ipc_somaxconn > somaxconn) { + if (version < 600008 && ngx_freebsd_kern_ipc_somaxconn > 32767) { ngx_log_error(NGX_LOG_ALERT, log, 0, - "sysctl kern.ipc.somaxconn must be no more than %d", - somaxconn); + "sysctl kern.ipc.somaxconn must be less than 32768"); return NGX_ERROR; } From mdounin at mdounin.ru Wed Dec 14 13:34:16 2011 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Wed, 14 Dec 2011 13:34:16 +0000 Subject: [nginx] svn commit: r4355 - in branches/stable-1.0: . auto src/os/unix Message-ID: <20111214133416.EC7F13F9C1D@mail.nginx.com> Author: mdounin Date: 2011-12-14 13:34:16 +0000 (Wed, 14 Dec 2011) New Revision: 4355 Log: Merge of r4231, r4300, r4303, r4304: Configure/build changes and fixes: *) Revamped "configure --help" text. *) FreeBSD 10-current has recently gotten POSIX_FADV_* macros. A fix for the broken build applied. *) AIX 7 defines sys_nerr in errno.h, therefore included in the sys_nerr test. When sys_nerr and _sys_nerr are missed on a particular platform and our euristic for a maximum errno detection applied always print the maximum errno number we reached instead of printing void. This makes possible to build nginx on AIX 7.1. *) Made it possible to build/install from the SVN checkout. Modified: branches/stable-1.0/ branches/stable-1.0/auto/install branches/stable-1.0/auto/options branches/stable-1.0/auto/unix branches/stable-1.0/src/os/unix/ngx_files.c Property changes on: branches/stable-1.0 ___________________________________________________________________ Modified: svn:mergeinfo - /trunk:3960-3974,3977-3987,3991-3996,3998,4000-4018,4020,4023,4025-4027,4034-4065,4073,4077,4086-4090,4094-4102,4106-4108,4113-4114,4129-4137,4143-4144,4147-4158,4177,4179,4182-4184,4186-4187,4189-4205,4207,4209-4210,4212,4217-4223,4227-4230,4232,4235-4237,4265,4268,4280,4283,4321,4342-4343 + /trunk:3960-3974,3977-3987,3991-3996,3998,4000-4018,4020,4023,4025-4027,4034-4065,4073,4077,4086-4090,4094-4102,4106-4108,4113-4114,4129-4137,4143-4144,4147-4158,4177,4179,4182-4184,4186-4187,4189-4205,4207,4209-4210,4212,4217-4223,4227-4232,4235-4237,4265,4268,4280,4283,4300,4303-4304,4321,4342-4343 Modified: branches/stable-1.0/auto/install =================================================================== --- branches/stable-1.0/auto/install 2011-12-14 13:06:45 UTC (rev 4354) +++ branches/stable-1.0/auto/install 2011-12-14 13:34:16 UTC (rev 4355) @@ -72,16 +72,28 @@ esac +if test -e man/nginx.8 ; then + NGX_MAN=man/nginx.8 +else + NGX_MAN=docs/man/nginx.8 +fi + +if test -d html ; then + NGX_HTML=html +else + NGX_HTML=docs/html +fi + cat << END >> $NGX_MAKEFILE manpage: $NGX_OBJS/nginx.8 -$NGX_OBJS/nginx.8: man/nginx.8 $NGX_AUTO_CONFIG_H +$NGX_OBJS/nginx.8: $NGX_MAN $NGX_AUTO_CONFIG_H sed -e "s|%%PREFIX%%|$NGX_PREFIX|" \\ -e "s|%%PID_PATH%%|$NGX_PID_PATH|" \\ -e "s|%%CONF_PATH%%|$NGX_CONF_PATH|" \\ -e "s|%%ERROR_LOG_PATH%%|${NGX_ERROR_LOG_PATH:-stderr}|" \\ - < man/nginx.8 > $NGX_OBJS/nginx.8 + < $NGX_MAN > \$@ install: $NGX_OBJS${ngx_dirsep}nginx${ngx_binext} \ $NGX_INSTALL_PERL_MODULES @@ -135,7 +147,7 @@ mkdir -p '\$(DESTDIR)`dirname "$NGX_HTTP_LOG_PATH"`' test -d '\$(DESTDIR)$NGX_PREFIX/html' \ - || cp -r html '\$(DESTDIR)$NGX_PREFIX' + || cp -R $NGX_HTML '\$(DESTDIR)$NGX_PREFIX' END Modified: branches/stable-1.0/auto/options =================================================================== --- branches/stable-1.0/auto/options 2011-12-14 13:06:45 UTC (rev 4354) +++ branches/stable-1.0/auto/options 2011-12-14 13:34:16 UTC (rev 4355) @@ -304,21 +304,21 @@ cat << END - --help this message + --help print this message - --prefix=PATH set the installation prefix - --sbin-path=PATH set path to the nginx binary file - --conf-path=PATH set path to the nginx.conf file - --error-log-path=PATH set path to the error log - --pid-path=PATH set path to nginx.pid file - --lock-path=PATH set path to nginx.lock file + --prefix=PATH set installation prefix + --sbin-path=PATH set nginx binary pathname + --conf-path=PATH set nginx.conf pathname + --error-log-path=PATH set error log pathname + --pid-path=PATH set nginx.pid pathname + --lock-path=PATH set nginx.lock pathname - --user=USER set non-privilege user - for the worker processes - --group=GROUP set non-privilege group - for the worker processes + --user=USER set non-privileged user for + worker processes + --group=GROUP set non-privileged group for + worker processes - --builddir=DIR set the build directory + --builddir=DIR set build directory --with-rtsig_module enable rtsig module --with-select_module enable select module @@ -326,8 +326,8 @@ --with-poll_module enable poll module --without-poll_module disable poll module - --with-file-aio enable file aio support - --with-ipv6 enable ipv6 support + --with-file-aio enable file AIO support + --with-ipv6 enable IPv6 support --with-http_ssl_module enable ngx_http_ssl_module --with-http_realip_module enable ngx_http_realip_module @@ -370,17 +370,20 @@ disable ngx_http_upstream_ip_hash_module --with-http_perl_module enable ngx_http_perl_module - --with-perl_modules_path=PATH set path to the perl modules - --with-perl=PATH set path to the perl binary + --with-perl_modules_path=PATH set Perl modules path + --with-perl=PATH set perl binary pathname - --http-log-path=PATH set path to the http access log - --http-client-body-temp-path=PATH set path to the http client request body - temporary files - --http-proxy-temp-path=PATH set path to the http proxy temporary files - --http-fastcgi-temp-path=PATH set path to the http fastcgi temporary - files - --http-uwsgi-temp-path=PATH set path to the http uwsgi temporary files - --http-scgi-temp-path=PATH set path to the http scgi temporary files + --http-log-path=PATH set http access log pathname + --http-client-body-temp-path=PATH set path to store + http client request body temporary files + --http-proxy-temp-path=PATH set path to store + http proxy temporary files + --http-fastcgi-temp-path=PATH set path to store + http fastcgi temporary files + --http-uwsgi-temp-path=PATH set path to store + http uwsgi temporary files + --http-scgi-temp-path=PATH set path to store + http scgi temporary files --without-http disable HTTP server --without-http-cache disable HTTP cache @@ -396,40 +399,40 @@ --add-module=PATH enable an external module - --with-cc=PATH set path to C compiler - --with-cpp=PATH set path to C preprocessor - --with-cc-opt=OPTIONS set additional options for C compiler - --with-ld-opt=OPTIONS set additional options for linker - --with-cpu-opt=CPU build for specified CPU, the valid values: + --with-cc=PATH set C compiler pathname + --with-cpp=PATH set C preprocessor pathname + --with-cc-opt=OPTIONS set additional C compiler options + --with-ld-opt=OPTIONS set additional linker options + --with-cpu-opt=CPU build for the specified CPU, valid values: pentium, pentiumpro, pentium3, pentium4, athlon, opteron, sparc32, sparc64, ppc64 --without-pcre disable PCRE library usage --with-pcre force PCRE library usage --with-pcre=DIR set path to PCRE library sources - --with-pcre-opt=OPTIONS set additional options for PCRE building + --with-pcre-opt=OPTIONS set additional build options for PCRE --with-md5=DIR set path to md5 library sources - --with-md5-opt=OPTIONS set additional options for md5 building + --with-md5-opt=OPTIONS set additional build options for md5 --with-md5-asm use md5 assembler sources --with-sha1=DIR set path to sha1 library sources - --with-sha1-opt=OPTIONS set additional options for sha1 building + --with-sha1-opt=OPTIONS set additional build options for sha1 --with-sha1-asm use sha1 assembler sources --with-zlib=DIR set path to zlib library sources - --with-zlib-opt=OPTIONS set additional options for zlib building + --with-zlib-opt=OPTIONS set additional build options for zlib --with-zlib-asm=CPU use zlib assembler sources optimized - for specified CPU, the valid values: + for the specified CPU, valid values: pentium, pentiumpro --with-libatomic force libatomic_ops library usage --with-libatomic=DIR set path to libatomic_ops library sources --with-openssl=DIR set path to OpenSSL library sources - --with-openssl-opt=OPTIONS set additional options for OpenSSL building + --with-openssl-opt=OPTIONS set additional build options for OpenSSL - --with-debug enable the debugging logging + --with-debug enable debug logging END Modified: branches/stable-1.0/auto/unix =================================================================== --- branches/stable-1.0/auto/unix 2011-12-14 13:06:45 UTC (rev 4354) +++ branches/stable-1.0/auto/unix 2011-12-14 13:34:16 UTC (rev 4355) @@ -496,7 +496,8 @@ ngx_feature="sys_nerr" ngx_feature_name="NGX_SYS_NERR" ngx_feature_run=value -ngx_feature_incs='#include ' +ngx_feature_incs='#include + #include ' ngx_feature_path= ngx_feature_libs= ngx_feature_test='printf("%d", sys_nerr);' @@ -538,10 +539,10 @@ || p == NULL || strncmp(p, "Unknown error", 13) == 0) { - printf("%d", n); - return 0; + break; } - }' + } + printf("%d", n);' . auto/feature fi Modified: branches/stable-1.0/src/os/unix/ngx_files.c =================================================================== --- branches/stable-1.0/src/os/unix/ngx_files.c 2011-12-14 13:06:45 UTC (rev 4354) +++ branches/stable-1.0/src/os/unix/ngx_files.c 2011-12-14 13:34:16 UTC (rev 4355) @@ -464,7 +464,7 @@ } -#if (NGX_HAVE_POSIX_FADVISE) +#if (NGX_HAVE_POSIX_FADVISE) && !(NGX_HAVE_F_READAHEAD) ngx_int_t ngx_read_ahead(ngx_fd_t fd, size_t n) From mdounin at mdounin.ru Wed Dec 14 13:37:53 2011 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Wed, 14 Dec 2011 13:37:53 +0000 Subject: [nginx] svn commit: r4356 - in branches/stable-1.0: . src/http/modules Message-ID: <20111214133753.C037D3F9C22@mail.nginx.com> Author: mdounin Date: 2011-12-14 13:37:53 +0000 (Wed, 14 Dec 2011) New Revision: 4356 Log: Merge of r4266, r4308, r4309: Image filter changes: *) The "image_filter_sharpen" directive. *) Cosmetics. *) Fixed "rotate" to always work when combined with "resize/crop". Modified: branches/stable-1.0/ branches/stable-1.0/src/http/modules/ngx_http_image_filter_module.c Property changes on: branches/stable-1.0 ___________________________________________________________________ Modified: svn:mergeinfo - /trunk:3960-3974,3977-3987,3991-3996,3998,4000-4018,4020,4023,4025-4027,4034-4065,4073,4077,4086-4090,4094-4102,4106-4108,4113-4114,4129-4137,4143-4144,4147-4158,4177,4179,4182-4184,4186-4187,4189-4205,4207,4209-4210,4212,4217-4223,4227-4232,4235-4237,4265,4268,4280,4283,4300,4303-4304,4321,4342-4343 + /trunk:3960-3974,3977-3987,3991-3996,3998,4000-4018,4020,4023,4025-4027,4034-4065,4073,4077,4086-4090,4094-4102,4106-4108,4113-4114,4129-4137,4143-4144,4147-4158,4177,4179,4182-4184,4186-4187,4189-4205,4207,4209-4210,4212,4217-4223,4227-4232,4235-4237,4265-4266,4268,4280,4283,4300,4303-4304,4308-4309,4321,4342-4343 Modified: branches/stable-1.0/src/http/modules/ngx_http_image_filter_module.c =================================================================== --- branches/stable-1.0/src/http/modules/ngx_http_image_filter_module.c 2011-12-14 13:34:16 UTC (rev 4355) +++ branches/stable-1.0/src/http/modules/ngx_http_image_filter_module.c 2011-12-14 13:37:53 UTC (rev 4356) @@ -41,6 +41,7 @@ ngx_uint_t height; ngx_uint_t angle; ngx_uint_t jpeg_quality; + ngx_uint_t sharpen; ngx_flag_t transparency; @@ -48,6 +49,7 @@ ngx_http_complex_value_t *hcv; ngx_http_complex_value_t *acv; ngx_http_complex_value_t *jqcv; + ngx_http_complex_value_t *shcv; size_t buffer_size; } ngx_http_image_filter_conf_t; @@ -105,13 +107,15 @@ void *conf); static char *ngx_http_image_filter_jpeg_quality(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); +static char *ngx_http_image_filter_sharpen(ngx_conf_t *cf, ngx_command_t *cmd, + void *conf); static ngx_int_t ngx_http_image_filter_init(ngx_conf_t *cf); static ngx_command_t ngx_http_image_filter_commands[] = { { ngx_string("image_filter"), - NGX_HTTP_LOC_CONF|NGX_CONF_TAKE13|NGX_CONF_TAKE2, + NGX_HTTP_LOC_CONF|NGX_CONF_TAKE123, ngx_http_image_filter, NGX_HTTP_LOC_CONF_OFFSET, 0, @@ -124,6 +128,13 @@ 0, NULL }, + { ngx_string("image_filter_sharpen"), + NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, + ngx_http_image_filter_sharpen, + NGX_HTTP_LOC_CONF_OFFSET, + 0, + NULL }, + { ngx_string("image_filter_transparency"), NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, ngx_conf_set_flag_slot, @@ -724,7 +735,7 @@ ngx_http_image_resize(ngx_http_request_t *r, ngx_http_image_filter_ctx_t *ctx) { int sx, sy, dx, dy, ox, oy, ax, ay, size, - colors, palette, transparent, + colors, palette, transparent, sharpen, red, green, blue, t; u_char *out; ngx_buf_t *b; @@ -948,6 +959,11 @@ gdImageColorTransparent(dst, gdImageColorExact(dst, red, green, blue)); } + sharpen = ngx_http_image_filter_get_value(r, conf->shcv, conf->sharpen); + if (sharpen > 0) { + gdImageSharpen(dst, sharpen); + } + out = ngx_http_image_out(r, ctx->type, dst, &size); ngx_log_debug3(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, @@ -1156,6 +1172,7 @@ conf->filter = NGX_CONF_UNSET_UINT; conf->jpeg_quality = NGX_CONF_UNSET_UINT; + conf->sharpen = NGX_CONF_UNSET_UINT; conf->angle = NGX_CONF_UNSET_UINT; conf->transparency = NGX_CONF_UNSET; conf->buffer_size = NGX_CONF_UNSET_SIZE; @@ -1191,6 +1208,12 @@ conf->jqcv = prev->jqcv; } + ngx_conf_merge_uint_value(conf->sharpen, prev->sharpen, 0); + + if (conf->shcv == NULL) { + conf->shcv = prev->shcv; + } + ngx_conf_merge_uint_value(conf->angle, prev->angle, 0); if (conf->acv == NULL) { conf->acv = prev->acv; @@ -1239,7 +1262,11 @@ } else if (cf->args->nelts == 3) { if (ngx_strcmp(value[i].data, "rotate") == 0) { - imcf->filter = NGX_HTTP_IMAGE_ROTATE; + if (imcf->filter != NGX_HTTP_IMAGE_RESIZE + && imcf->filter != NGX_HTTP_IMAGE_CROP) + { + imcf->filter = NGX_HTTP_IMAGE_ROTATE; + } ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t)); @@ -1382,7 +1409,7 @@ if (n <= 0) { ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, - "invalid parameter \"%V\"", &value[1]); + "invalid value \"%V\"", &value[1]); return NGX_CONF_ERROR; } @@ -1401,6 +1428,53 @@ } +static char * +ngx_http_image_filter_sharpen(ngx_conf_t *cf, ngx_command_t *cmd, + void *conf) +{ + ngx_http_image_filter_conf_t *imcf = conf; + + ngx_str_t *value; + ngx_int_t n; + ngx_http_complex_value_t cv; + ngx_http_compile_complex_value_t ccv; + + value = cf->args->elts; + + ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t)); + + ccv.cf = cf; + ccv.value = &value[1]; + ccv.complex_value = &cv; + + if (ngx_http_compile_complex_value(&ccv) != NGX_OK) { + return NGX_CONF_ERROR; + } + + if (cv.lengths == NULL) { + n = ngx_http_image_filter_value(&value[1]); + + if (n < 0) { + ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, + "invalid value \"%V\"", &value[1]); + return NGX_CONF_ERROR; + } + + imcf->sharpen = (ngx_uint_t) n; + + } else { + imcf->shcv = ngx_palloc(cf->pool, sizeof(ngx_http_complex_value_t)); + if (imcf->shcv == NULL) { + return NGX_CONF_ERROR; + } + + *imcf->shcv = cv; + } + + return NGX_CONF_OK; +} + + static ngx_int_t ngx_http_image_filter_init(ngx_conf_t *cf) { From mdounin at mdounin.ru Wed Dec 14 13:40:25 2011 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Wed, 14 Dec 2011 13:40:25 +0000 Subject: [nginx] svn commit: r4357 - in branches/stable-1.0: . src/http Message-ID: <20111214134025.A7AE53F9C1F@mail.nginx.com> Author: mdounin Date: 2011-12-14 13:40:25 +0000 (Wed, 14 Dec 2011) New Revision: 4357 Log: Merge of r4267, r4301: Fix of the "keepalive_disable" directive. Modified: branches/stable-1.0/ branches/stable-1.0/src/http/ngx_http_core_module.c Property changes on: branches/stable-1.0 ___________________________________________________________________ Modified: svn:mergeinfo - /trunk:3960-3974,3977-3987,3991-3996,3998,4000-4018,4020,4023,4025-4027,4034-4065,4073,4077,4086-4090,4094-4102,4106-4108,4113-4114,4129-4137,4143-4144,4147-4158,4177,4179,4182-4184,4186-4187,4189-4205,4207,4209-4210,4212,4217-4223,4227-4232,4235-4237,4265-4266,4268,4280,4283,4300,4303-4304,4308-4309,4321,4342-4343 + /trunk:3960-3974,3977-3987,3991-3996,3998,4000-4018,4020,4023,4025-4027,4034-4065,4073,4077,4086-4090,4094-4102,4106-4108,4113-4114,4129-4137,4143-4144,4147-4158,4177,4179,4182-4184,4186-4187,4189-4205,4207,4209-4210,4212,4217-4223,4227-4232,4235-4237,4265-4268,4280,4283,4300-4301,4303-4304,4308-4309,4321,4342-4343 Modified: branches/stable-1.0/src/http/ngx_http_core_module.c =================================================================== --- branches/stable-1.0/src/http/ngx_http_core_module.c 2011-12-14 13:37:53 UTC (rev 4356) +++ branches/stable-1.0/src/http/ngx_http_core_module.c 2011-12-14 13:40:25 UTC (rev 4357) @@ -143,7 +143,7 @@ }; -static ngx_conf_enum_t ngx_http_core_keepalive_disable[] = { +static ngx_conf_bitmask_t ngx_http_core_keepalive_disable[] = { { ngx_string("none"), NGX_HTTP_KEEPALIVE_DISABLE_NONE }, { ngx_string("msie6"), NGX_HTTP_KEEPALIVE_DISABLE_MSIE6 }, { ngx_string("safari"), NGX_HTTP_KEEPALIVE_DISABLE_SAFARI }, @@ -513,8 +513,8 @@ NULL }, { ngx_string("keepalive_disable"), - NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, - ngx_conf_set_enum_slot, + NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE12, + ngx_conf_set_bitmask_slot, NGX_HTTP_LOC_CONF_OFFSET, offsetof(ngx_http_core_loc_conf_t, keepalive_disable), &ngx_http_core_keepalive_disable }, @@ -3264,12 +3264,12 @@ * clcf->auto_redirect = 0; * clcf->alias = 0; * clcf->gzip_proxied = 0; + * clcf->keepalive_disable = 0; */ clcf->client_max_body_size = NGX_CONF_UNSET; clcf->client_body_buffer_size = NGX_CONF_UNSET_SIZE; clcf->client_body_timeout = NGX_CONF_UNSET_MSEC; - clcf->keepalive_disable = NGX_CONF_UNSET_UINT; clcf->satisfy = NGX_CONF_UNSET_UINT; clcf->if_modified_since = NGX_CONF_UNSET_UINT; clcf->max_ranges = NGX_CONF_UNSET_UINT; @@ -3472,9 +3472,11 @@ ngx_conf_merge_msec_value(conf->client_body_timeout, prev->client_body_timeout, 60000); - ngx_conf_merge_uint_value(conf->keepalive_disable, prev->keepalive_disable, - NGX_HTTP_KEEPALIVE_DISABLE_MSIE6 - |NGX_HTTP_KEEPALIVE_DISABLE_SAFARI); + ngx_conf_merge_bitmask_value(conf->keepalive_disable, + prev->keepalive_disable, + (NGX_CONF_BITMASK_SET + |NGX_HTTP_KEEPALIVE_DISABLE_MSIE6 + |NGX_HTTP_KEEPALIVE_DISABLE_SAFARI)); ngx_conf_merge_uint_value(conf->satisfy, prev->satisfy, NGX_HTTP_SATISFY_ALL); ngx_conf_merge_uint_value(conf->if_modified_since, prev->if_modified_since, From mdounin at mdounin.ru Wed Dec 14 14:31:56 2011 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Wed, 14 Dec 2011 14:31:56 +0000 Subject: [nginx] svn commit: r4358 - in branches/stable-1.0: . src/http src/http/modules src/mail Message-ID: <20111214143156.D390E3F9C24@mail.nginx.com> Author: mdounin Date: 2011-12-14 14:31:55 +0000 (Wed, 14 Dec 2011) New Revision: 4358 Log: Merge of r4270, r4274: Minor cleanup: *) Changed error message to be more appropriate in the imaginary "open_file_cache max=0" case. *) Fixed NGX_CONF_TAKE1/NGX_CONF_FLAG misuse. Modified: branches/stable-1.0/ branches/stable-1.0/src/http/modules/ngx_http_fastcgi_module.c branches/stable-1.0/src/http/modules/ngx_http_ssi_filter_module.c branches/stable-1.0/src/http/modules/ngx_http_ssl_module.c branches/stable-1.0/src/http/ngx_http_core_module.c branches/stable-1.0/src/mail/ngx_mail_proxy_module.c Property changes on: branches/stable-1.0 ___________________________________________________________________ Modified: svn:mergeinfo - /trunk:3960-3974,3977-3987,3991-3996,3998,4000-4018,4020,4023,4025-4027,4034-4065,4073,4077,4086-4090,4094-4102,4106-4108,4113-4114,4129-4137,4143-4144,4147-4158,4177,4179,4182-4184,4186-4187,4189-4205,4207,4209-4210,4212,4217-4223,4227-4232,4235-4237,4265-4268,4280,4283,4300-4301,4303-4304,4308-4309,4321,4342-4343 + /trunk:3960-3974,3977-3987,3991-3996,3998,4000-4018,4020,4023,4025-4027,4034-4065,4073,4077,4086-4090,4094-4102,4106-4108,4113-4114,4129-4137,4143-4144,4147-4158,4177,4179,4182-4184,4186-4187,4189-4205,4207,4209-4210,4212,4217-4223,4227-4232,4235-4237,4265-4268,4270,4274,4280,4283,4300-4301,4303-4304,4308-4309,4321,4342-4343 Modified: branches/stable-1.0/src/http/modules/ngx_http_fastcgi_module.c =================================================================== --- branches/stable-1.0/src/http/modules/ngx_http_fastcgi_module.c 2011-12-14 13:40:25 UTC (rev 4357) +++ branches/stable-1.0/src/http/modules/ngx_http_fastcgi_module.c 2011-12-14 14:31:55 UTC (rev 4358) @@ -431,7 +431,7 @@ &ngx_http_upstream_ignore_headers_masks }, { ngx_string("fastcgi_catch_stderr"), - NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, + NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, ngx_conf_set_str_array_slot, NGX_HTTP_LOC_CONF_OFFSET, offsetof(ngx_http_fastcgi_loc_conf_t, catch_stderr), Modified: branches/stable-1.0/src/http/modules/ngx_http_ssi_filter_module.c =================================================================== --- branches/stable-1.0/src/http/modules/ngx_http_ssi_filter_module.c 2011-12-14 13:40:25 UTC (rev 4357) +++ branches/stable-1.0/src/http/modules/ngx_http_ssi_filter_module.c 2011-12-14 14:31:55 UTC (rev 4358) @@ -139,14 +139,14 @@ NULL }, { ngx_string("ssi_min_file_chunk"), - NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, + NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, ngx_conf_set_size_slot, NGX_HTTP_LOC_CONF_OFFSET, offsetof(ngx_http_ssi_loc_conf_t, min_file_chunk), NULL }, { ngx_string("ssi_value_length"), - NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, + NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, ngx_conf_set_size_slot, NGX_HTTP_LOC_CONF_OFFSET, offsetof(ngx_http_ssi_loc_conf_t, value_len), Modified: branches/stable-1.0/src/http/modules/ngx_http_ssl_module.c =================================================================== --- branches/stable-1.0/src/http/modules/ngx_http_ssl_module.c 2011-12-14 13:40:25 UTC (rev 4357) +++ branches/stable-1.0/src/http/modules/ngx_http_ssl_module.c 2011-12-14 14:31:55 UTC (rev 4358) @@ -101,7 +101,7 @@ NULL }, { ngx_string("ssl_verify_client"), - NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_FLAG, + NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1, ngx_conf_set_enum_slot, NGX_HTTP_SRV_CONF_OFFSET, offsetof(ngx_http_ssl_srv_conf_t, verify), Modified: branches/stable-1.0/src/http/ngx_http_core_module.c =================================================================== --- branches/stable-1.0/src/http/ngx_http_core_module.c 2011-12-14 13:40:25 UTC (rev 4357) +++ branches/stable-1.0/src/http/ngx_http_core_module.c 2011-12-14 14:31:55 UTC (rev 4358) @@ -4397,7 +4397,7 @@ if (ngx_strncmp(value[i].data, "max=", 4) == 0) { max = ngx_atoi(value[i].data + 4, value[i].len - 4); - if (max == NGX_ERROR) { + if (max <= 0) { goto failed; } Modified: branches/stable-1.0/src/mail/ngx_mail_proxy_module.c =================================================================== --- branches/stable-1.0/src/mail/ngx_mail_proxy_module.c 2011-12-14 13:40:25 UTC (rev 4357) +++ branches/stable-1.0/src/mail/ngx_mail_proxy_module.c 2011-12-14 14:31:55 UTC (rev 4358) @@ -60,7 +60,7 @@ NULL }, { ngx_string("proxy_pass_error_message"), - NGX_MAIL_MAIN_CONF|NGX_MAIL_SRV_CONF|NGX_CONF_TAKE1, + NGX_MAIL_MAIN_CONF|NGX_MAIL_SRV_CONF|NGX_CONF_FLAG, ngx_conf_set_flag_slot, NGX_MAIL_SRV_CONF_OFFSET, offsetof(ngx_mail_proxy_conf_t, pass_error_message), From mdounin at mdounin.ru Wed Dec 14 15:13:25 2011 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Wed, 14 Dec 2011 15:13:25 +0000 Subject: [nginx] svn commit: r4359 - in branches/stable-1.0: . src/http/modules Message-ID: <20111214151325.AA9A73F9C28@mail.nginx.com> Author: mdounin Date: 2011-12-14 15:13:25 +0000 (Wed, 14 Dec 2011) New Revision: 4359 Log: Merge of r4275, r4276, r4278, r4279: Fixes for proxy_set_header, fastcgi/scgi/uwsgi_param inheritance: *) Fixed proxy_set_header inheritance with proxy_cache (ticket #45). Headers cleared with cache enabled (If-Modified-Since etc.) might be cleared in unrelated servers/locations without proxy_cache enabled if proxy_cache was used in some server/location. Example config which triggered the problem: proxy_set_header X-Test "test"; server { location /1 { proxy_cache name; proxy_pass ... } } server { location /2 { proxy_pass ... } } Another one: server { proxy_cache name; location /1 { proxy_pass ... } location /2 { proxy_cache off; proxy_pass ... } } In both cases If-Modified-Since header wasn't sent to backend in location /2. Fix is to not modify conf->headers_source, but instead merge user-supplied headers from conf->headers_source and default headers (either cache or not) into separate headers_merged array. *) Fixed proxy_set_header inheritance with proxy_set_body. *) Separate functions to merge fastcgi/scgi/uwsgi params. No functional changes. *) Fixed fastcgi/scgi/uwsgi_param inheritance. The following problems were fixed: 1. Directive fastcgi_cache affected headers sent to backends in unrelated servers / locations (see ticket #45). 2. If-Unmodified-Since, If-Match and If-Range headers were sent to backends if fastcgi_cache was used. 3. Cache-related headers were sent to backends if there were no fastcgi_param directives and fastcgi_cache was used at server level. Modified: branches/stable-1.0/ branches/stable-1.0/src/http/modules/ngx_http_fastcgi_module.c branches/stable-1.0/src/http/modules/ngx_http_proxy_module.c branches/stable-1.0/src/http/modules/ngx_http_scgi_module.c branches/stable-1.0/src/http/modules/ngx_http_uwsgi_module.c Property changes on: branches/stable-1.0 ___________________________________________________________________ Modified: svn:mergeinfo - /trunk:3960-3974,3977-3987,3991-3996,3998,4000-4018,4020,4023,4025-4027,4034-4065,4073,4077,4086-4090,4094-4102,4106-4108,4113-4114,4129-4137,4143-4144,4147-4158,4177,4179,4182-4184,4186-4187,4189-4205,4207,4209-4210,4212,4217-4223,4227-4232,4235-4237,4265-4268,4270,4274,4280,4283,4300-4301,4303-4304,4308-4309,4321,4342-4343 + /trunk:3960-3974,3977-3987,3991-3996,3998,4000-4018,4020,4023,4025-4027,4034-4065,4073,4077,4086-4090,4094-4102,4106-4108,4113-4114,4129-4137,4143-4144,4147-4158,4177,4179,4182-4184,4186-4187,4189-4205,4207,4209-4210,4212,4217-4223,4227-4232,4235-4237,4265-4268,4270,4274-4276,4278-4280,4283,4300-4301,4303-4304,4308-4309,4321,4342-4343 Modified: branches/stable-1.0/src/http/modules/ngx_http_fastcgi_module.c =================================================================== --- branches/stable-1.0/src/http/modules/ngx_http_fastcgi_module.c 2011-12-14 14:31:55 UTC (rev 4358) +++ branches/stable-1.0/src/http/modules/ngx_http_fastcgi_module.c 2011-12-14 15:13:25 UTC (rev 4359) @@ -142,6 +142,9 @@ static void *ngx_http_fastcgi_create_loc_conf(ngx_conf_t *cf); static char *ngx_http_fastcgi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child); +static ngx_int_t ngx_http_fastcgi_merge_params(ngx_conf_t *cf, + ngx_http_fastcgi_loc_conf_t *conf, ngx_http_fastcgi_loc_conf_t *prev); + static ngx_int_t ngx_http_fastcgi_script_name_variable(ngx_http_request_t *r, ngx_http_variable_value_t *v, uintptr_t data); static ngx_int_t ngx_http_fastcgi_path_info_variable(ngx_http_request_t *r, @@ -2025,17 +2028,9 @@ ngx_http_fastcgi_loc_conf_t *prev = parent; ngx_http_fastcgi_loc_conf_t *conf = child; - u_char *p; size_t size; - uintptr_t *code; - ngx_uint_t i; - ngx_array_t headers_names; - ngx_keyval_t *src; - ngx_hash_key_t *hk; ngx_hash_init_t hash; ngx_http_core_loc_conf_t *clcf; - ngx_http_script_compile_t sc; - ngx_http_script_copy_code_t *copy; if (conf->upstream.store != 0) { ngx_conf_merge_value(conf->upstream.store, @@ -2293,95 +2288,146 @@ } #endif + if (ngx_http_fastcgi_merge_params(cf, conf, prev) != NGX_OK) { + return NGX_CONF_ERROR; + } + + return NGX_CONF_OK; +} + + +static ngx_int_t +ngx_http_fastcgi_merge_params(ngx_conf_t *cf, + ngx_http_fastcgi_loc_conf_t *conf, ngx_http_fastcgi_loc_conf_t *prev) +{ + u_char *p; + size_t size; + uintptr_t *code; + ngx_uint_t i, nsrc; + ngx_array_t headers_names; +#if (NGX_HTTP_CACHE) + ngx_array_t params_merged; +#endif + ngx_keyval_t *src; + ngx_hash_key_t *hk; + ngx_hash_init_t hash; + ngx_http_script_compile_t sc; + ngx_http_script_copy_code_t *copy; + if (conf->params_source == NULL) { - conf->flushes = prev->flushes; - conf->params_len = prev->params_len; - conf->params = prev->params; conf->params_source = prev->params_source; - conf->headers_hash = prev->headers_hash; + if (prev->headers_hash.buckets #if (NGX_HTTP_CACHE) + && ((conf->upstream.cache == NULL) == (prev->upstream.cache == NULL)) +#endif + ) + { + conf->flushes = prev->flushes; + conf->params_len = prev->params_len; + conf->params = prev->params; + conf->headers_hash = prev->headers_hash; + conf->header_params = prev->header_params; - if (conf->params_source == NULL) { - - if ((conf->upstream.cache == NULL) - == (prev->upstream.cache == NULL)) - { - return NGX_CONF_OK; - } - - /* 6 is a number of ngx_http_fastcgi_cache_headers entries */ - conf->params_source = ngx_array_create(cf->pool, 6, - sizeof(ngx_keyval_t)); - if (conf->params_source == NULL) { - return NGX_CONF_ERROR; - } + return NGX_OK; } -#else + } - if (conf->params_source == NULL) { - return NGX_CONF_OK; - } - + if (conf->params_source == NULL +#if (NGX_HTTP_CACHE) + && (conf->upstream.cache == NULL) #endif + ) + { + conf->headers_hash.buckets = (void *) 1; + return NGX_OK; } conf->params_len = ngx_array_create(cf->pool, 64, 1); if (conf->params_len == NULL) { - return NGX_CONF_ERROR; + return NGX_ERROR; } conf->params = ngx_array_create(cf->pool, 512, 1); if (conf->params == NULL) { - return NGX_CONF_ERROR; + return NGX_ERROR; } if (ngx_array_init(&headers_names, cf->temp_pool, 4, sizeof(ngx_hash_key_t)) != NGX_OK) { - return NGX_CONF_ERROR; + return NGX_ERROR; } - src = conf->params_source->elts; + if (conf->params_source) { + src = conf->params_source->elts; + nsrc = conf->params_source->nelts; + } else { + src = NULL; + nsrc = 0; + } + #if (NGX_HTTP_CACHE) if (conf->upstream.cache) { ngx_keyval_t *h, *s; - for (h = ngx_http_fastcgi_cache_headers; h->key.len; h++) { + if (ngx_array_init(¶ms_merged, cf->temp_pool, 4, sizeof(ngx_keyval_t)) + != NGX_OK) + { + return NGX_ERROR; + } - for (i = 0; i < conf->params_source->nelts; i++) { + for (i = 0; i < nsrc; i++) { + + s = ngx_array_push(¶ms_merged); + if (s == NULL) { + return NGX_ERROR; + } + + *s = src[i]; + } + + h = ngx_http_fastcgi_cache_headers; + + while (h->key.len) { + + src = params_merged.elts; + nsrc = params_merged.nelts; + + for (i = 0; i < nsrc; i++) { if (ngx_strcasecmp(h->key.data, src[i].key.data) == 0) { goto next; } } - s = ngx_array_push(conf->params_source); + s = ngx_array_push(¶ms_merged); if (s == NULL) { - return NGX_CONF_ERROR; + return NGX_ERROR; } *s = *h; - src = conf->params_source->elts; - next: h++; } + + src = params_merged.elts; + nsrc = params_merged.nelts; } #endif - for (i = 0; i < conf->params_source->nelts; i++) { + for (i = 0; i < nsrc; i++) { if (src[i].key.len > sizeof("HTTP_") - 1 && ngx_strncmp(src[i].key.data, "HTTP_", sizeof("HTTP_") - 1) == 0) { hk = ngx_array_push(&headers_names); if (hk == NULL) { - return NGX_CONF_ERROR; + return NGX_ERROR; } hk->key.len = src[i].key.len - 5; @@ -2397,7 +2443,7 @@ copy = ngx_array_push_n(conf->params_len, sizeof(ngx_http_script_copy_code_t)); if (copy == NULL) { - return NGX_CONF_ERROR; + return NGX_ERROR; } copy->code = (ngx_http_script_code_pt) ngx_http_script_copy_len_code; @@ -2406,11 +2452,11 @@ size = (sizeof(ngx_http_script_copy_code_t) + src[i].key.len + sizeof(uintptr_t) - 1) - & ~(sizeof(uintptr_t) - 1); + & ~(sizeof(uintptr_t) - 1); copy = ngx_array_push_n(conf->params, size); if (copy == NULL) { - return NGX_CONF_ERROR; + return NGX_ERROR; } copy->code = ngx_http_script_copy_code; @@ -2429,12 +2475,12 @@ sc.values = &conf->params; if (ngx_http_script_compile(&sc) != NGX_OK) { - return NGX_CONF_ERROR; + return NGX_ERROR; } code = ngx_array_push_n(conf->params_len, sizeof(uintptr_t)); if (code == NULL) { - return NGX_CONF_ERROR; + return NGX_ERROR; } *code = (uintptr_t) NULL; @@ -2442,7 +2488,7 @@ code = ngx_array_push_n(conf->params, sizeof(uintptr_t)); if (code == NULL) { - return NGX_CONF_ERROR; + return NGX_ERROR; } *code = (uintptr_t) NULL; @@ -2450,12 +2496,11 @@ code = ngx_array_push_n(conf->params_len, sizeof(uintptr_t)); if (code == NULL) { - return NGX_CONF_ERROR; + return NGX_ERROR; } *code = (uintptr_t) NULL; - conf->header_params = headers_names.nelts; hash.hash = &conf->headers_hash; @@ -2466,12 +2511,7 @@ hash.pool = cf->pool; hash.temp_pool = NULL; - if (ngx_hash_init(&hash, headers_names.elts, headers_names.nelts) != NGX_OK) - { - return NGX_CONF_ERROR; - } - - return NGX_CONF_OK; + return ngx_hash_init(&hash, headers_names.elts, headers_names.nelts); } Modified: branches/stable-1.0/src/http/modules/ngx_http_proxy_module.c =================================================================== --- branches/stable-1.0/src/http/modules/ngx_http_proxy_module.c 2011-12-14 14:31:55 UTC (rev 4358) +++ branches/stable-1.0/src/http/modules/ngx_http_proxy_module.c 2011-12-14 15:13:25 UTC (rev 4359) @@ -1722,7 +1722,6 @@ u_char *p; size_t size; - ngx_keyval_t *s; ngx_hash_init_t hash; ngx_http_core_loc_conf_t *clcf; ngx_http_proxy_redirect_t *pr; @@ -2067,22 +2066,6 @@ if (ngx_http_script_compile(&sc) != NGX_OK) { return NGX_CONF_ERROR; } - - if (conf->headers_source == NULL) { - conf->headers_source = ngx_array_create(cf->pool, 4, - sizeof(ngx_keyval_t)); - if (conf->headers_source == NULL) { - return NGX_CONF_ERROR; - } - } - - s = ngx_array_push(conf->headers_source); - if (s == NULL) { - return NGX_CONF_ERROR; - } - - ngx_str_set(&s->key, "Content-Length"); - ngx_str_set(&s->value, "$proxy_internal_body_length"); } if (ngx_http_proxy_merge_headers(cf, conf, prev) != NGX_OK) { @@ -2101,7 +2084,7 @@ size_t size; uintptr_t *code; ngx_uint_t i; - ngx_array_t headers_names; + ngx_array_t headers_names, headers_merged; ngx_keyval_t *src, *s, *h; ngx_hash_key_t *hk; ngx_hash_init_t hash; @@ -2117,6 +2100,8 @@ } if (conf->headers_set_hash.buckets + && ((conf->body_source.data == NULL) + == (prev->body_source.data == NULL)) #if (NGX_HTTP_CACHE) && ((conf->upstream.cache == NULL) == (prev->upstream.cache == NULL)) #endif @@ -2132,6 +2117,12 @@ return NGX_ERROR; } + if (ngx_array_init(&headers_merged, cf->temp_pool, 4, sizeof(ngx_keyval_t)) + != NGX_OK) + { + return NGX_ERROR; + } + if (conf->headers_source == NULL) { conf->headers_source = ngx_array_create(cf->pool, 4, sizeof(ngx_keyval_t)); @@ -2151,8 +2142,6 @@ } - src = conf->headers_source->elts; - #if (NGX_HTTP_CACHE) h = conf->upstream.cache ? ngx_http_proxy_cache_headers: @@ -2163,32 +2152,52 @@ #endif + src = conf->headers_source->elts; + for (i = 0; i < conf->headers_source->nelts; i++) { + + s = ngx_array_push(&headers_merged); + if (s == NULL) { + return NGX_ERROR; + } + + *s = src[i]; + } + while (h->key.len) { - for (i = 0; i < conf->headers_source->nelts; i++) { + src = headers_merged.elts; + for (i = 0; i < headers_merged.nelts; i++) { if (ngx_strcasecmp(h->key.data, src[i].key.data) == 0) { goto next; } } - s = ngx_array_push(conf->headers_source); + s = ngx_array_push(&headers_merged); if (s == NULL) { return NGX_ERROR; } *s = *h; - src = conf->headers_source->elts; - next: h++; } + if (conf->body_source.data) { + s = ngx_array_push(&headers_merged); + if (s == NULL) { + return NGX_ERROR; + } - src = conf->headers_source->elts; - for (i = 0; i < conf->headers_source->nelts; i++) { + ngx_str_set(&s->key, "Content-Length"); + ngx_str_set(&s->value, "$proxy_internal_body_length"); + } + + src = headers_merged.elts; + for (i = 0; i < headers_merged.nelts; i++) { + hk = ngx_array_push(&headers_names); if (hk == NULL) { return NGX_ERROR; Modified: branches/stable-1.0/src/http/modules/ngx_http_scgi_module.c =================================================================== --- branches/stable-1.0/src/http/modules/ngx_http_scgi_module.c 2011-12-14 14:31:55 UTC (rev 4358) +++ branches/stable-1.0/src/http/modules/ngx_http_scgi_module.c 2011-12-14 15:13:25 UTC (rev 4359) @@ -43,6 +43,8 @@ static void *ngx_http_scgi_create_loc_conf(ngx_conf_t *cf); static char *ngx_http_scgi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child); +static ngx_int_t ngx_http_scgi_merge_params(ngx_conf_t *cf, + ngx_http_scgi_loc_conf_t *conf, ngx_http_scgi_loc_conf_t *prev); static char *ngx_http_scgi_pass(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); static char *ngx_http_scgi_store(ngx_conf_t *cf, ngx_command_t *cmd, @@ -1059,17 +1061,9 @@ ngx_http_scgi_loc_conf_t *prev = parent; ngx_http_scgi_loc_conf_t *conf = child; - u_char *p; size_t size; - uintptr_t *code; - ngx_uint_t i; - ngx_array_t headers_names; - ngx_keyval_t *src; - ngx_hash_key_t *hk; ngx_hash_init_t hash; ngx_http_core_loc_conf_t *clcf; - ngx_http_script_compile_t sc; - ngx_http_script_copy_code_t *copy; if (conf->upstream.store != 0) { ngx_conf_merge_value(conf->upstream.store, prev->upstream.store, 0); @@ -1307,95 +1301,146 @@ } } + if (ngx_http_scgi_merge_params(cf, conf, prev) != NGX_OK) { + return NGX_CONF_ERROR; + } + + return NGX_CONF_OK; +} + + +static ngx_int_t +ngx_http_scgi_merge_params(ngx_conf_t *cf, ngx_http_scgi_loc_conf_t *conf, + ngx_http_scgi_loc_conf_t *prev) +{ + u_char *p; + size_t size; + uintptr_t *code; + ngx_uint_t i, nsrc; + ngx_array_t headers_names; +#if (NGX_HTTP_CACHE) + ngx_array_t params_merged; +#endif + ngx_keyval_t *src; + ngx_hash_key_t *hk; + ngx_hash_init_t hash; + ngx_http_script_compile_t sc; + ngx_http_script_copy_code_t *copy; + if (conf->params_source == NULL) { - conf->flushes = prev->flushes; - conf->params_len = prev->params_len; - conf->params = prev->params; conf->params_source = prev->params_source; - conf->headers_hash = prev->headers_hash; + if (prev->headers_hash.buckets #if (NGX_HTTP_CACHE) + && ((conf->upstream.cache == NULL) == (prev->upstream.cache == NULL)) +#endif + ) + { + conf->flushes = prev->flushes; + conf->params_len = prev->params_len; + conf->params = prev->params; + conf->headers_hash = prev->headers_hash; + conf->header_params = prev->header_params; - if (conf->params_source == NULL) { - - if ((conf->upstream.cache == NULL) - == (prev->upstream.cache == NULL)) - { - return NGX_CONF_OK; - } - - /* 6 is a number of ngx_http_scgi_cache_headers entries */ - conf->params_source = ngx_array_create(cf->pool, 6, - sizeof(ngx_keyval_t)); - if (conf->params_source == NULL) { - return NGX_CONF_ERROR; - } + return NGX_OK; } -#else + } - if (conf->params_source == NULL) { - return NGX_CONF_OK; - } - + if (conf->params_source == NULL +#if (NGX_HTTP_CACHE) + && (conf->upstream.cache == NULL) #endif + ) + { + conf->headers_hash.buckets = (void *) 1; + return NGX_OK; } conf->params_len = ngx_array_create(cf->pool, 64, 1); if (conf->params_len == NULL) { - return NGX_CONF_ERROR; + return NGX_ERROR; } conf->params = ngx_array_create(cf->pool, 512, 1); if (conf->params == NULL) { - return NGX_CONF_ERROR; + return NGX_ERROR; } if (ngx_array_init(&headers_names, cf->temp_pool, 4, sizeof(ngx_hash_key_t)) != NGX_OK) { - return NGX_CONF_ERROR; + return NGX_ERROR; } - src = conf->params_source->elts; + if (conf->params_source) { + src = conf->params_source->elts; + nsrc = conf->params_source->nelts; + } else { + src = NULL; + nsrc = 0; + } + #if (NGX_HTTP_CACHE) if (conf->upstream.cache) { ngx_keyval_t *h, *s; - for (h = ngx_http_scgi_cache_headers; h->key.len; h++) { + if (ngx_array_init(¶ms_merged, cf->temp_pool, 4, sizeof(ngx_keyval_t)) + != NGX_OK) + { + return NGX_ERROR; + } - for (i = 0; i < conf->params_source->nelts; i++) { + for (i = 0; i < nsrc; i++) { + + s = ngx_array_push(¶ms_merged); + if (s == NULL) { + return NGX_ERROR; + } + + *s = src[i]; + } + + h = ngx_http_scgi_cache_headers; + + while (h->key.len) { + + src = params_merged.elts; + nsrc = params_merged.nelts; + + for (i = 0; i < nsrc; i++) { if (ngx_strcasecmp(h->key.data, src[i].key.data) == 0) { goto next; } } - s = ngx_array_push(conf->params_source); + s = ngx_array_push(¶ms_merged); if (s == NULL) { - return NGX_CONF_ERROR; + return NGX_ERROR; } *s = *h; - src = conf->params_source->elts; - next: h++; } + + src = params_merged.elts; + nsrc = params_merged.nelts; } #endif - for (i = 0; i < conf->params_source->nelts; i++) { + for (i = 0; i < nsrc; i++) { if (src[i].key.len > sizeof("HTTP_") - 1 && ngx_strncmp(src[i].key.data, "HTTP_", sizeof("HTTP_") - 1) == 0) { hk = ngx_array_push(&headers_names); if (hk == NULL) { - return NGX_CONF_ERROR; + return NGX_ERROR; } hk->key.len = src[i].key.len - 5; @@ -1411,7 +1456,7 @@ copy = ngx_array_push_n(conf->params_len, sizeof(ngx_http_script_copy_code_t)); if (copy == NULL) { - return NGX_CONF_ERROR; + return NGX_ERROR; } copy->code = (ngx_http_script_code_pt) ngx_http_script_copy_len_code; @@ -1424,7 +1469,7 @@ copy = ngx_array_push_n(conf->params, size); if (copy == NULL) { - return NGX_CONF_ERROR; + return NGX_ERROR; } copy->code = ngx_http_script_copy_code; @@ -1443,12 +1488,12 @@ sc.values = &conf->params; if (ngx_http_script_compile(&sc) != NGX_OK) { - return NGX_CONF_ERROR; + return NGX_ERROR; } code = ngx_array_push_n(conf->params_len, sizeof(uintptr_t)); if (code == NULL) { - return NGX_CONF_ERROR; + return NGX_ERROR; } *code = (uintptr_t) NULL; @@ -1456,7 +1501,7 @@ code = ngx_array_push_n(conf->params, sizeof(uintptr_t)); if (code == NULL) { - return NGX_CONF_ERROR; + return NGX_ERROR; } *code = (uintptr_t) NULL; @@ -1464,14 +1509,14 @@ code = ngx_array_push_n(conf->params_len, sizeof(uintptr_t)); if (code == NULL) { - return NGX_CONF_ERROR; + return NGX_ERROR; } *code = (uintptr_t) NULL; code = ngx_array_push_n(conf->params, sizeof(uintptr_t)); if (code == NULL) { - return NGX_CONF_ERROR; + return NGX_ERROR; } *code = (uintptr_t) NULL; @@ -1486,12 +1531,7 @@ hash.pool = cf->pool; hash.temp_pool = NULL; - if (ngx_hash_init(&hash, headers_names.elts, headers_names.nelts) != NGX_OK) - { - return NGX_CONF_ERROR; - } - - return NGX_CONF_OK; + return ngx_hash_init(&hash, headers_names.elts, headers_names.nelts); } Modified: branches/stable-1.0/src/http/modules/ngx_http_uwsgi_module.c =================================================================== --- branches/stable-1.0/src/http/modules/ngx_http_uwsgi_module.c 2011-12-14 14:31:55 UTC (rev 4358) +++ branches/stable-1.0/src/http/modules/ngx_http_uwsgi_module.c 2011-12-14 15:13:25 UTC (rev 4359) @@ -50,6 +50,8 @@ static void *ngx_http_uwsgi_create_loc_conf(ngx_conf_t *cf); static char *ngx_http_uwsgi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child); +static ngx_int_t ngx_http_uwsgi_merge_params(ngx_conf_t *cf, + ngx_http_uwsgi_loc_conf_t *conf, ngx_http_uwsgi_loc_conf_t *prev); static char *ngx_http_uwsgi_pass(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); @@ -1112,17 +1114,9 @@ ngx_http_uwsgi_loc_conf_t *prev = parent; ngx_http_uwsgi_loc_conf_t *conf = child; - u_char *p; size_t size; - uintptr_t *code; - ngx_uint_t i; - ngx_array_t headers_names; - ngx_keyval_t *src; - ngx_hash_key_t *hk; ngx_hash_init_t hash; ngx_http_core_loc_conf_t *clcf; - ngx_http_script_compile_t sc; - ngx_http_script_copy_code_t *copy; if (conf->upstream.store != 0) { ngx_conf_merge_value(conf->upstream.store, prev->upstream.store, 0); @@ -1365,95 +1359,146 @@ ngx_conf_merge_uint_value(conf->modifier1, prev->modifier1, 0); ngx_conf_merge_uint_value(conf->modifier2, prev->modifier2, 0); + if (ngx_http_uwsgi_merge_params(cf, conf, prev) != NGX_OK) { + return NGX_CONF_ERROR; + } + + return NGX_CONF_OK; +} + + +static ngx_int_t +ngx_http_uwsgi_merge_params(ngx_conf_t *cf, ngx_http_uwsgi_loc_conf_t *conf, + ngx_http_uwsgi_loc_conf_t *prev) +{ + u_char *p; + size_t size; + uintptr_t *code; + ngx_uint_t i, nsrc; + ngx_array_t headers_names; +#if (NGX_HTTP_CACHE) + ngx_array_t params_merged; +#endif + ngx_keyval_t *src; + ngx_hash_key_t *hk; + ngx_hash_init_t hash; + ngx_http_script_compile_t sc; + ngx_http_script_copy_code_t *copy; + if (conf->params_source == NULL) { - conf->flushes = prev->flushes; - conf->params_len = prev->params_len; - conf->params = prev->params; conf->params_source = prev->params_source; - conf->headers_hash = prev->headers_hash; + if (prev->headers_hash.buckets #if (NGX_HTTP_CACHE) + && ((conf->upstream.cache == NULL) == (prev->upstream.cache == NULL)) +#endif + ) + { + conf->flushes = prev->flushes; + conf->params_len = prev->params_len; + conf->params = prev->params; + conf->headers_hash = prev->headers_hash; + conf->header_params = prev->header_params; - if (conf->params_source == NULL) { - - if ((conf->upstream.cache == NULL) - == (prev->upstream.cache == NULL)) - { - return NGX_CONF_OK; - } - - /* 6 is a number of ngx_http_uwsgi_cache_headers entries */ - conf->params_source = ngx_array_create(cf->pool, 6, - sizeof(ngx_keyval_t)); - if (conf->params_source == NULL) { - return NGX_CONF_ERROR; - } + return NGX_OK; } -#else + } - if (conf->params_source == NULL) { - return NGX_CONF_OK; - } - + if (conf->params_source == NULL +#if (NGX_HTTP_CACHE) + && (conf->upstream.cache == NULL) #endif + ) + { + conf->headers_hash.buckets = (void *) 1; + return NGX_OK; } conf->params_len = ngx_array_create(cf->pool, 64, 1); if (conf->params_len == NULL) { - return NGX_CONF_ERROR; + return NGX_ERROR; } conf->params = ngx_array_create(cf->pool, 512, 1); if (conf->params == NULL) { - return NGX_CONF_ERROR; + return NGX_ERROR; } if (ngx_array_init(&headers_names, cf->temp_pool, 4, sizeof(ngx_hash_key_t)) != NGX_OK) { - return NGX_CONF_ERROR; + return NGX_ERROR; } - src = conf->params_source->elts; + if (conf->params_source) { + src = conf->params_source->elts; + nsrc = conf->params_source->nelts; + } else { + src = NULL; + nsrc = 0; + } + #if (NGX_HTTP_CACHE) if (conf->upstream.cache) { ngx_keyval_t *h, *s; - for (h = ngx_http_uwsgi_cache_headers; h->key.len; h++) { + if (ngx_array_init(¶ms_merged, cf->temp_pool, 4, sizeof(ngx_keyval_t)) + != NGX_OK) + { + return NGX_ERROR; + } - for (i = 0; i < conf->params_source->nelts; i++) { + for (i = 0; i < nsrc; i++) { + + s = ngx_array_push(¶ms_merged); + if (s == NULL) { + return NGX_ERROR; + } + + *s = src[i]; + } + + h = ngx_http_uwsgi_cache_headers; + + while (h->key.len) { + + src = params_merged.elts; + nsrc = params_merged.nelts; + + for (i = 0; i < nsrc; i++) { if (ngx_strcasecmp(h->key.data, src[i].key.data) == 0) { goto next; } } - s = ngx_array_push(conf->params_source); + s = ngx_array_push(¶ms_merged); if (s == NULL) { - return NGX_CONF_ERROR; + return NGX_ERROR; } *s = *h; - src = conf->params_source->elts; - next: h++; } + + src = params_merged.elts; + nsrc = params_merged.nelts; } #endif - for (i = 0; i < conf->params_source->nelts; i++) { + for (i = 0; i < nsrc; i++) { if (src[i].key.len > sizeof("HTTP_") - 1 && ngx_strncmp(src[i].key.data, "HTTP_", sizeof("HTTP_") - 1) == 0) { hk = ngx_array_push(&headers_names); if (hk == NULL) { - return NGX_CONF_ERROR; + return NGX_ERROR; } hk->key.len = src[i].key.len - 5; @@ -1469,7 +1514,7 @@ copy = ngx_array_push_n(conf->params_len, sizeof(ngx_http_script_copy_code_t)); if (copy == NULL) { - return NGX_CONF_ERROR; + return NGX_ERROR; } copy->code = (ngx_http_script_code_pt) ngx_http_script_copy_len_code; @@ -1482,7 +1527,7 @@ copy = ngx_array_push_n(conf->params, size); if (copy == NULL) { - return NGX_CONF_ERROR; + return NGX_ERROR; } copy->code = ngx_http_script_copy_code; @@ -1501,12 +1546,12 @@ sc.values = &conf->params; if (ngx_http_script_compile(&sc) != NGX_OK) { - return NGX_CONF_ERROR; + return NGX_ERROR; } code = ngx_array_push_n(conf->params_len, sizeof(uintptr_t)); if (code == NULL) { - return NGX_CONF_ERROR; + return NGX_ERROR; } *code = (uintptr_t) NULL; @@ -1514,7 +1559,7 @@ code = ngx_array_push_n(conf->params, sizeof(uintptr_t)); if (code == NULL) { - return NGX_CONF_ERROR; + return NGX_ERROR; } *code = (uintptr_t) NULL; @@ -1522,7 +1567,7 @@ code = ngx_array_push_n(conf->params_len, sizeof(uintptr_t)); if (code == NULL) { - return NGX_CONF_ERROR; + return NGX_ERROR; } *code = (uintptr_t) NULL; @@ -1537,12 +1582,7 @@ hash.pool = cf->pool; hash.temp_pool = NULL; - if (ngx_hash_init(&hash, headers_names.elts, headers_names.nelts) != NGX_OK) - { - return NGX_CONF_ERROR; - } - - return NGX_CONF_OK; + return ngx_hash_init(&hash, headers_names.elts, headers_names.nelts); } From mdounin at mdounin.ru Wed Dec 14 15:16:05 2011 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Wed, 14 Dec 2011 15:16:05 +0000 Subject: [nginx] svn commit: r4360 - in branches/stable-1.0: . conf Message-ID: <20111214151606.0A94A3F9C28@mail.nginx.com> Author: mdounin Date: 2011-12-14 15:16:05 +0000 (Wed, 14 Dec 2011) New Revision: 4360 Log: Merge of r4282, r4302: Added image/webp and video/webm MIME types. Added svgz extension for compressed SVG. Modified: branches/stable-1.0/ branches/stable-1.0/conf/mime.types Property changes on: branches/stable-1.0 ___________________________________________________________________ Modified: svn:mergeinfo - /trunk:3960-3974,3977-3987,3991-3996,3998,4000-4018,4020,4023,4025-4027,4034-4065,4073,4077,4086-4090,4094-4102,4106-4108,4113-4114,4129-4137,4143-4144,4147-4158,4177,4179,4182-4184,4186-4187,4189-4205,4207,4209-4210,4212,4217-4223,4227-4232,4235-4237,4265-4268,4270,4274-4276,4278-4280,4283,4300-4301,4303-4304,4308-4309,4321,4342-4343 + /trunk:3960-3974,3977-3987,3991-3996,3998,4000-4018,4020,4023,4025-4027,4034-4065,4073,4077,4086-4090,4094-4102,4106-4108,4113-4114,4129-4137,4143-4144,4147-4158,4177,4179,4182-4184,4186-4187,4189-4205,4207,4209-4210,4212,4217-4223,4227-4232,4235-4237,4265-4268,4270,4274-4276,4278-4280,4282-4283,4300-4304,4308-4309,4321,4342-4343 Modified: branches/stable-1.0/conf/mime.types =================================================================== --- branches/stable-1.0/conf/mime.types 2011-12-14 15:13:25 UTC (rev 4359) +++ branches/stable-1.0/conf/mime.types 2011-12-14 15:16:05 UTC (rev 4360) @@ -21,7 +21,8 @@ image/x-icon ico; image/x-jng jng; image/x-ms-bmp bmp; - image/svg+xml svg; + image/svg+xml svg svgz; + image/webp webp; application/java-archive jar war ear; application/mac-binhex40 hqx; @@ -69,6 +70,7 @@ video/mp4 mp4; video/mpeg mpeg mpg; video/quicktime mov; + video/webm webm; video/x-flv flv; video/x-m4v m4v; video/x-mng mng; From mdounin at mdounin.ru Wed Dec 14 15:23:23 2011 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Wed, 14 Dec 2011 15:23:23 +0000 Subject: [nginx] svn commit: r4361 - in branches/stable-1.0: . src/core src/os/unix src/os/win32 Message-ID: <20111214152325.1AFB83F9C22@mail.nginx.com> Author: mdounin Date: 2011-12-14 15:23:23 +0000 (Wed, 14 Dec 2011) New Revision: 4361 Log: Merge of r4284: Introduction of simple ngx_write_stderr() instead of ngx_log_stderr() for output of ./configure options, etc., since ngx_log_stderr() output length is limited by 2048 characters defined as NGX_MAX_ERROR_STR. Modified: branches/stable-1.0/ branches/stable-1.0/src/core/nginx.c branches/stable-1.0/src/core/ngx_log.h branches/stable-1.0/src/os/unix/ngx_files.h branches/stable-1.0/src/os/win32/ngx_files.h Property changes on: branches/stable-1.0 ___________________________________________________________________ Modified: svn:mergeinfo - /trunk:3960-3974,3977-3987,3991-3996,3998,4000-4018,4020,4023,4025-4027,4034-4065,4073,4077,4086-4090,4094-4102,4106-4108,4113-4114,4129-4137,4143-4144,4147-4158,4177,4179,4182-4184,4186-4187,4189-4205,4207,4209-4210,4212,4217-4223,4227-4232,4235-4237,4265-4268,4270,4274-4276,4278-4280,4282-4283,4300-4304,4308-4309,4321,4342-4343 + /trunk:3960-3974,3977-3987,3991-3996,3998,4000-4018,4020,4023,4025-4027,4034-4065,4073,4077,4086-4090,4094-4102,4106-4108,4113-4114,4129-4137,4143-4144,4147-4158,4177,4179,4182-4184,4186-4187,4189-4205,4207,4209-4210,4212,4217-4223,4227-4232,4235-4237,4265-4268,4270,4274-4276,4278-4280,4282-4284,4300-4304,4308-4309,4321,4342-4343 Modified: branches/stable-1.0/src/core/nginx.c =================================================================== --- branches/stable-1.0/src/core/nginx.c 2011-12-14 15:16:05 UTC (rev 4360) +++ branches/stable-1.0/src/core/nginx.c 2011-12-14 15:23:23 UTC (rev 4361) @@ -216,47 +216,49 @@ } if (ngx_show_version) { - ngx_log_stderr(0, "nginx version: " NGINX_VER); + ngx_write_stderr("nginx version: " NGINX_VER NGX_LINEFEED); if (ngx_show_help) { - ngx_log_stderr(0, + ngx_write_stderr( "Usage: nginx [-?hvVtq] [-s signal] [-c filename] " - "[-p prefix] [-g directives]" CRLF CRLF - "Options:" CRLF - " -?,-h : this help" CRLF - " -v : show version and exit" CRLF + "[-p prefix] [-g directives]" NGX_LINEFEED + NGX_LINEFEED + "Options:" NGX_LINEFEED + " -?,-h : this help" NGX_LINEFEED + " -v : show version and exit" NGX_LINEFEED " -V : show version and configure options then exit" - CRLF - " -t : test configuration and exit" CRLF + NGX_LINEFEED + " -t : test configuration and exit" NGX_LINEFEED " -q : suppress non-error messages " - "during configuration testing" CRLF + "during configuration testing" NGX_LINEFEED " -s signal : send signal to a master process: " - "stop, quit, reopen, reload" CRLF + "stop, quit, reopen, reload" NGX_LINEFEED #ifdef NGX_PREFIX " -p prefix : set prefix path (default: " - NGX_PREFIX ")" CRLF + NGX_PREFIX ")" NGX_LINEFEED #else - " -p prefix : set prefix path (default: NONE)" CRLF + " -p prefix : set prefix path (default: NONE)" NGX_LINEFEED #endif " -c filename : set configuration file (default: " - NGX_CONF_PATH ")" CRLF + NGX_CONF_PATH ")" NGX_LINEFEED " -g directives : set global directives out of configuration " - "file" CRLF + "file" NGX_LINEFEED NGX_LINEFEED ); } if (ngx_show_configure) { + ngx_write_stderr( #ifdef NGX_COMPILER - ngx_log_stderr(0, "built by " NGX_COMPILER); + "built by " NGX_COMPILER NGX_LINEFEED #endif #if (NGX_SSL) #ifdef SSL_CTRL_SET_TLSEXT_HOSTNAME - ngx_log_stderr(0, "TLS SNI support enabled"); + "TLS SNI support enabled" NGX_LINEFEED #else - ngx_log_stderr(0, "TLS SNI support disabled"); + "TLS SNI support disabled" NGX_LINEFEED #endif #endif - ngx_log_stderr(0, "configure arguments:" NGX_CONFIGURE); + "configure arguments:" NGX_CONFIGURE NGX_LINEFEED); } if (!ngx_test_config) { Modified: branches/stable-1.0/src/core/ngx_log.h =================================================================== --- branches/stable-1.0/src/core/ngx_log.h 2011-12-14 15:16:05 UTC (rev 4360) +++ branches/stable-1.0/src/core/ngx_log.h 2011-12-14 15:23:23 UTC (rev 4361) @@ -203,6 +203,22 @@ u_char *ngx_log_errno(u_char *buf, u_char *last, ngx_err_t err); +/* + * ngx_write_stderr() cannot be implemented as macro, since + * MSVC does not allow to use #ifdef inside macro parameters. + * + * ngx_write_fd() is used instead of ngx_write_console(), since + * CharToOemBuff() inside ngx_write_console() cannot be used with + * read only buffer as destination and CharToOemBuff() is not needed + * for ngx_write_stderr() anyway. + */ +static ngx_inline void +ngx_write_stderr(char *text) +{ + (void) ngx_write_fd(ngx_stderr, text, strlen(text)); +} + + extern ngx_module_t ngx_errlog_module; extern ngx_uint_t ngx_use_stderr; Modified: branches/stable-1.0/src/os/unix/ngx_files.h =================================================================== --- branches/stable-1.0/src/os/unix/ngx_files.h 2011-12-14 15:16:05 UTC (rev 4360) +++ branches/stable-1.0/src/os/unix/ngx_files.h 2011-12-14 15:23:23 UTC (rev 4361) @@ -128,6 +128,7 @@ #define ngx_linefeed(p) *p++ = LF; #define NGX_LINEFEED_SIZE 1 +#define NGX_LINEFEED "\x0a" #define ngx_rename_file(o, n) rename((const char *) o, (const char *) n) Modified: branches/stable-1.0/src/os/win32/ngx_files.h =================================================================== --- branches/stable-1.0/src/os/win32/ngx_files.h 2011-12-14 15:16:05 UTC (rev 4360) +++ branches/stable-1.0/src/os/win32/ngx_files.h 2011-12-14 15:23:23 UTC (rev 4361) @@ -115,6 +115,7 @@ #define ngx_linefeed(p) *p++ = CR; *p++ = LF; #define NGX_LINEFEED_SIZE 2 +#define NGX_LINEFEED CRLF #define ngx_delete_file(name) DeleteFile((const char *) name) From mdounin at mdounin.ru Wed Dec 14 15:25:33 2011 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Wed, 14 Dec 2011 15:25:33 +0000 Subject: [nginx] svn commit: r4362 - in branches/stable-1.0: . src/core Message-ID: <20111214152533.CBA203F9C22@mail.nginx.com> Author: mdounin Date: 2011-12-14 15:25:32 +0000 (Wed, 14 Dec 2011) New Revision: 4362 Log: Merge of r4294: Fixed handling of SIGWINCH/NOACCEPT signal. After first upgrade it was ignored since r4020 (1.1.1, 1.0.9) as ngx_daemonized wasn't set. Modified: branches/stable-1.0/ branches/stable-1.0/src/core/nginx.c Property changes on: branches/stable-1.0 ___________________________________________________________________ Modified: svn:mergeinfo - /trunk:3960-3974,3977-3987,3991-3996,3998,4000-4018,4020,4023,4025-4027,4034-4065,4073,4077,4086-4090,4094-4102,4106-4108,4113-4114,4129-4137,4143-4144,4147-4158,4177,4179,4182-4184,4186-4187,4189-4205,4207,4209-4210,4212,4217-4223,4227-4232,4235-4237,4265-4268,4270,4274-4276,4278-4280,4282-4284,4300-4304,4308-4309,4321,4342-4343 + /trunk:3960-3974,3977-3987,3991-3996,3998,4000-4018,4020,4023,4025-4027,4034-4065,4073,4077,4086-4090,4094-4102,4106-4108,4113-4114,4129-4137,4143-4144,4147-4158,4177,4179,4182-4184,4186-4187,4189-4205,4207,4209-4210,4212,4217-4223,4227-4232,4235-4237,4265-4268,4270,4274-4276,4278-4280,4282-4284,4294,4300-4304,4308-4309,4321,4342-4343 Modified: branches/stable-1.0/src/core/nginx.c =================================================================== --- branches/stable-1.0/src/core/nginx.c 2011-12-14 15:23:23 UTC (rev 4361) +++ branches/stable-1.0/src/core/nginx.c 2011-12-14 15:25:32 UTC (rev 4362) @@ -376,6 +376,10 @@ ngx_daemonized = 1; } + if (ngx_inherited) { + ngx_daemonized = 1; + } + #endif if (ngx_create_pidfile(&ccf->pid, cycle->log) != NGX_OK) { From mdounin at mdounin.ru Wed Dec 14 15:28:14 2011 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Wed, 14 Dec 2011 15:28:14 +0000 Subject: [nginx] svn commit: r4363 - in branches/stable-1.0: . src/http/modules Message-ID: <20111214152814.3C2843F9C22@mail.nginx.com> Author: mdounin Date: 2011-12-14 15:28:13 +0000 (Wed, 14 Dec 2011) New Revision: 4363 Log: Merge of r4295: Fixed incorrect counting the length of headers in a SCGI request. Modified: branches/stable-1.0/ branches/stable-1.0/src/http/modules/ngx_http_scgi_module.c Property changes on: branches/stable-1.0 ___________________________________________________________________ Modified: svn:mergeinfo - /trunk:3960-3974,3977-3987,3991-3996,3998,4000-4018,4020,4023,4025-4027,4034-4065,4073,4077,4086-4090,4094-4102,4106-4108,4113-4114,4129-4137,4143-4144,4147-4158,4177,4179,4182-4184,4186-4187,4189-4205,4207,4209-4210,4212,4217-4223,4227-4232,4235-4237,4265-4268,4270,4274-4276,4278-4280,4282-4284,4294,4300-4304,4308-4309,4321,4342-4343 + /trunk:3960-3974,3977-3987,3991-3996,3998,4000-4018,4020,4023,4025-4027,4034-4065,4073,4077,4086-4090,4094-4102,4106-4108,4113-4114,4129-4137,4143-4144,4147-4158,4177,4179,4182-4184,4186-4187,4189-4205,4207,4209-4210,4212,4217-4223,4227-4232,4235-4237,4265-4268,4270,4274-4276,4278-4280,4282-4284,4294-4295,4300-4304,4308-4309,4321,4342-4343 Modified: branches/stable-1.0/src/http/modules/ngx_http_scgi_module.c =================================================================== --- branches/stable-1.0/src/http/modules/ngx_http_scgi_module.c 2011-12-14 15:25:32 UTC (rev 4362) +++ branches/stable-1.0/src/http/modules/ngx_http_scgi_module.c 2011-12-14 15:28:13 UTC (rev 4363) @@ -558,8 +558,10 @@ while (*(uintptr_t *) le.ip) { lcode = *(ngx_http_script_len_code_pt *) le.ip; - len += lcode(&le) + 1; + len += lcode(&le); } + len++; + le.ip += sizeof(uintptr_t); } } From mdounin at mdounin.ru Wed Dec 14 15:30:03 2011 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Wed, 14 Dec 2011 15:30:03 +0000 Subject: [nginx] svn commit: r4364 - in branches/stable-1.0: . src/http/modules Message-ID: <20111214153003.D64A43F9C23@mail.nginx.com> Author: mdounin Date: 2011-12-14 15:30:02 +0000 (Wed, 14 Dec 2011) New Revision: 4364 Log: Merge of r4298: Fixed flv header to match specification. Used "\x5" in 5th byte to claim presence of both audio and video. Used previous tag size 0 in the beginning of the flv body (bytes 10 .. 13) as required by specification (see http://www.adobe.com/devnet/f4v.html). Patch by Piotr Sikora. Modified: branches/stable-1.0/ branches/stable-1.0/src/http/modules/ngx_http_flv_module.c Property changes on: branches/stable-1.0 ___________________________________________________________________ Modified: svn:mergeinfo - /trunk:3960-3974,3977-3987,3991-3996,3998,4000-4018,4020,4023,4025-4027,4034-4065,4073,4077,4086-4090,4094-4102,4106-4108,4113-4114,4129-4137,4143-4144,4147-4158,4177,4179,4182-4184,4186-4187,4189-4205,4207,4209-4210,4212,4217-4223,4227-4232,4235-4237,4265-4268,4270,4274-4276,4278-4280,4282-4284,4294-4295,4300-4304,4308-4309,4321,4342-4343 + /trunk:3960-3974,3977-3987,3991-3996,3998,4000-4018,4020,4023,4025-4027,4034-4065,4073,4077,4086-4090,4094-4102,4106-4108,4113-4114,4129-4137,4143-4144,4147-4158,4177,4179,4182-4184,4186-4187,4189-4205,4207,4209-4210,4212,4217-4223,4227-4232,4235-4237,4265-4268,4270,4274-4276,4278-4280,4282-4284,4294-4295,4298,4300-4304,4308-4309,4321,4342-4343 Modified: branches/stable-1.0/src/http/modules/ngx_http_flv_module.c =================================================================== --- branches/stable-1.0/src/http/modules/ngx_http_flv_module.c 2011-12-14 15:28:13 UTC (rev 4363) +++ branches/stable-1.0/src/http/modules/ngx_http_flv_module.c 2011-12-14 15:30:02 UTC (rev 4364) @@ -23,7 +23,7 @@ }; -static u_char ngx_flv_header[] = "FLV\x1\x1\0\0\0\x9\0\0\0\x9"; +static u_char ngx_flv_header[] = "FLV\x1\x5\0\0\0\x9\0\0\0\0"; static ngx_http_module_t ngx_http_flv_module_ctx = { From mdounin at mdounin.ru Wed Dec 14 18:00:50 2011 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Wed, 14 Dec 2011 18:00:50 +0000 Subject: [nginx] svn commit: r4365 - in branches/stable-1.0: . src/http Message-ID: <20111214180050.A0E5E3F9C27@mail.nginx.com> Author: mdounin Date: 2011-12-14 18:00:50 +0000 (Wed, 14 Dec 2011) New Revision: 4365 Log: Merge of r4305: Fixed segfault on ssl servers without cert with SNI (ticket #54). Non-default servers may not have ssl context created if there are no certificate defined. Make sure to check if ssl context present before using it. Modified: branches/stable-1.0/ branches/stable-1.0/src/http/ngx_http_request.c Property changes on: branches/stable-1.0 ___________________________________________________________________ Modified: svn:mergeinfo - /trunk:3960-3974,3977-3987,3991-3996,3998,4000-4018,4020,4023,4025-4027,4034-4065,4073,4077,4086-4090,4094-4102,4106-4108,4113-4114,4129-4137,4143-4144,4147-4158,4177,4179,4182-4184,4186-4187,4189-4205,4207,4209-4210,4212,4217-4223,4227-4232,4235-4237,4265-4268,4270,4274-4276,4278-4280,4282-4284,4294-4295,4298,4300-4304,4308-4309,4321,4342-4343 + /trunk:3960-3974,3977-3987,3991-3996,3998,4000-4018,4020,4023,4025-4027,4034-4065,4073,4077,4086-4090,4094-4102,4106-4108,4113-4114,4129-4137,4143-4144,4147-4158,4177,4179,4182-4184,4186-4187,4189-4205,4207,4209-4210,4212,4217-4223,4227-4232,4235-4237,4265-4268,4270,4274-4276,4278-4280,4282-4284,4294-4295,4298,4300-4305,4308-4309,4321,4342-4343 Modified: branches/stable-1.0/src/http/ngx_http_request.c =================================================================== --- branches/stable-1.0/src/http/ngx_http_request.c 2011-12-14 15:30:02 UTC (rev 4364) +++ branches/stable-1.0/src/http/ngx_http_request.c 2011-12-14 18:00:50 UTC (rev 4365) @@ -671,25 +671,27 @@ sscf = ngx_http_get_module_srv_conf(r, ngx_http_ssl_module); - SSL_set_SSL_CTX(ssl_conn, sscf->ssl.ctx); + if (sscf->ssl.ctx) { + SSL_set_SSL_CTX(ssl_conn, sscf->ssl.ctx); - /* - * SSL_set_SSL_CTX() only changes certs as of 1.0.0d - * adjust other things we care about - */ + /* + * SSL_set_SSL_CTX() only changes certs as of 1.0.0d + * adjust other things we care about + */ - SSL_set_verify(ssl_conn, SSL_CTX_get_verify_mode(sscf->ssl.ctx), - SSL_CTX_get_verify_callback(sscf->ssl.ctx)); + SSL_set_verify(ssl_conn, SSL_CTX_get_verify_mode(sscf->ssl.ctx), + SSL_CTX_get_verify_callback(sscf->ssl.ctx)); - SSL_set_verify_depth(ssl_conn, SSL_CTX_get_verify_depth(sscf->ssl.ctx)); + SSL_set_verify_depth(ssl_conn, SSL_CTX_get_verify_depth(sscf->ssl.ctx)); #ifdef SSL_CTRL_CLEAR_OPTIONS - /* only in 0.9.8m+ */ - SSL_clear_options(ssl_conn, SSL_get_options(ssl_conn) & - ~SSL_CTX_get_options(sscf->ssl.ctx)); + /* only in 0.9.8m+ */ + SSL_clear_options(ssl_conn, SSL_get_options(ssl_conn) & + ~SSL_CTX_get_options(sscf->ssl.ctx)); #endif - SSL_set_options(ssl_conn, SSL_CTX_get_options(sscf->ssl.ctx)); + SSL_set_options(ssl_conn, SSL_CTX_get_options(sscf->ssl.ctx)); + } return SSL_TLSEXT_ERR_OK; } From mdounin at mdounin.ru Wed Dec 14 18:02:37 2011 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Wed, 14 Dec 2011 18:02:37 +0000 Subject: [nginx] svn commit: r4366 - in branches/stable-1.0: . src/http/modules Message-ID: <20111214180237.4BB143F9C1A@mail.nginx.com> Author: mdounin Date: 2011-12-14 18:02:37 +0000 (Wed, 14 Dec 2011) New Revision: 4366 Log: Merge of r4307: Fix of mp4 module seeking. Modified: branches/stable-1.0/ branches/stable-1.0/src/http/modules/ngx_http_mp4_module.c Property changes on: branches/stable-1.0 ___________________________________________________________________ Modified: svn:mergeinfo - /trunk:3960-3974,3977-3987,3991-3996,3998,4000-4018,4020,4023,4025-4027,4034-4065,4073,4077,4086-4090,4094-4102,4106-4108,4113-4114,4129-4137,4143-4144,4147-4158,4177,4179,4182-4184,4186-4187,4189-4205,4207,4209-4210,4212,4217-4223,4227-4232,4235-4237,4265-4268,4270,4274-4276,4278-4280,4282-4284,4294-4295,4298,4300-4305,4308-4309,4321,4342-4343 + /trunk:3960-3974,3977-3987,3991-3996,3998,4000-4018,4020,4023,4025-4027,4034-4065,4073,4077,4086-4090,4094-4102,4106-4108,4113-4114,4129-4137,4143-4144,4147-4158,4177,4179,4182-4184,4186-4187,4189-4205,4207,4209-4210,4212,4217-4223,4227-4232,4235-4237,4265-4268,4270,4274-4276,4278-4280,4282-4284,4294-4295,4298,4300-4305,4307-4309,4321,4342-4343 Modified: branches/stable-1.0/src/http/modules/ngx_http_mp4_module.c =================================================================== --- branches/stable-1.0/src/http/modules/ngx_http_mp4_module.c 2011-12-14 18:00:50 UTC (rev 4365) +++ branches/stable-1.0/src/http/modules/ngx_http_mp4_module.c 2011-12-14 18:02:37 UTC (rev 4366) @@ -1899,7 +1899,7 @@ ngx_log_debug2(NGX_LOG_DEBUG_HTTP, mp4->file.log, 0, "count:%uD, duration:%uD", count, duration); - if (start_time < count * duration) { + if (start_time < (uint64_t) count * duration) { start_sample += (ngx_uint_t) (start_time / duration); count -= start_sample; ngx_mp4_set_32value(entry->count, count); From mdounin at mdounin.ru Wed Dec 14 18:04:06 2011 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Wed, 14 Dec 2011 18:04:06 +0000 Subject: [nginx] svn commit: r4367 - in branches/stable-1.0: . src/core Message-ID: <20111214180406.A804F3F9C1A@mail.nginx.com> Author: mdounin Date: 2011-12-14 18:04:06 +0000 (Wed, 14 Dec 2011) New Revision: 4367 Log: Merge of r4313: Added escaping of double quotes in ngx_escape_html(). Patch by Zaur Abasmirzoev. Modified: branches/stable-1.0/ branches/stable-1.0/src/core/ngx_string.c Property changes on: branches/stable-1.0 ___________________________________________________________________ Modified: svn:mergeinfo - /trunk:3960-3974,3977-3987,3991-3996,3998,4000-4018,4020,4023,4025-4027,4034-4065,4073,4077,4086-4090,4094-4102,4106-4108,4113-4114,4129-4137,4143-4144,4147-4158,4177,4179,4182-4184,4186-4187,4189-4205,4207,4209-4210,4212,4217-4223,4227-4232,4235-4237,4265-4268,4270,4274-4276,4278-4280,4282-4284,4294-4295,4298,4300-4305,4307-4309,4321,4342-4343 + /trunk:3960-3974,3977-3987,3991-3996,3998,4000-4018,4020,4023,4025-4027,4034-4065,4073,4077,4086-4090,4094-4102,4106-4108,4113-4114,4129-4137,4143-4144,4147-4158,4177,4179,4182-4184,4186-4187,4189-4205,4207,4209-4210,4212,4217-4223,4227-4232,4235-4237,4265-4268,4270,4274-4276,4278-4280,4282-4284,4294-4295,4298,4300-4305,4307-4309,4313,4321,4342-4343 Modified: branches/stable-1.0/src/core/ngx_string.c =================================================================== --- branches/stable-1.0/src/core/ngx_string.c 2011-12-14 18:02:37 UTC (rev 4366) +++ branches/stable-1.0/src/core/ngx_string.c 2011-12-14 18:04:06 UTC (rev 4367) @@ -1657,6 +1657,10 @@ len += sizeof("&") - 2; break; + case '"': + len += sizeof(""") - 2; + break; + default: break; } @@ -1684,6 +1688,11 @@ *dst++ = ';'; break; + case '"': + *dst++ = '&'; *dst++ = 'q'; *dst++ = 'u'; *dst++ = 'o'; + *dst++ = 't'; *dst++ = ';'; + break; + default: *dst++ = ch; break; From mdounin at mdounin.ru Wed Dec 14 18:06:21 2011 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Wed, 14 Dec 2011 18:06:21 +0000 Subject: [nginx] svn commit: r4368 - in branches/stable-1.0: . src/http/modules Message-ID: <20111214180621.CEC633F9C1A@mail.nginx.com> Author: mdounin Date: 2011-12-14 18:06:21 +0000 (Wed, 14 Dec 2011) New Revision: 4368 Log: Merge of r4315: Allowed add_header for proxied 206 replies. It was working for nginx's own 206 replies as they are seen as 200 in the headers filter module (range filter goes later in the headers filter chain), but not for proxied replies. Modified: branches/stable-1.0/ branches/stable-1.0/src/http/modules/ngx_http_headers_filter_module.c Property changes on: branches/stable-1.0 ___________________________________________________________________ Modified: svn:mergeinfo - /trunk:3960-3974,3977-3987,3991-3996,3998,4000-4018,4020,4023,4025-4027,4034-4065,4073,4077,4086-4090,4094-4102,4106-4108,4113-4114,4129-4137,4143-4144,4147-4158,4177,4179,4182-4184,4186-4187,4189-4205,4207,4209-4210,4212,4217-4223,4227-4232,4235-4237,4265-4268,4270,4274-4276,4278-4280,4282-4284,4294-4295,4298,4300-4305,4307-4309,4313,4321,4342-4343 + /trunk:3960-3974,3977-3987,3991-3996,3998,4000-4018,4020,4023,4025-4027,4034-4065,4073,4077,4086-4090,4094-4102,4106-4108,4113-4114,4129-4137,4143-4144,4147-4158,4177,4179,4182-4184,4186-4187,4189-4205,4207,4209-4210,4212,4217-4223,4227-4232,4235-4237,4265-4268,4270,4274-4276,4278-4280,4282-4284,4294-4295,4298,4300-4305,4307-4309,4313,4315,4321,4342-4343 Modified: branches/stable-1.0/src/http/modules/ngx_http_headers_filter_module.c =================================================================== --- branches/stable-1.0/src/http/modules/ngx_http_headers_filter_module.c 2011-12-14 18:04:06 UTC (rev 4367) +++ branches/stable-1.0/src/http/modules/ngx_http_headers_filter_module.c 2011-12-14 18:06:21 UTC (rev 4368) @@ -145,6 +145,7 @@ || r != r->main || (r->headers_out.status != NGX_HTTP_OK && r->headers_out.status != NGX_HTTP_NO_CONTENT + && r->headers_out.status != NGX_HTTP_PARTIAL_CONTENT && r->headers_out.status != NGX_HTTP_MOVED_PERMANENTLY && r->headers_out.status != NGX_HTTP_MOVED_TEMPORARILY && r->headers_out.status != NGX_HTTP_NOT_MODIFIED)) From mdounin at mdounin.ru Thu Dec 15 14:04:39 2011 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Thu, 15 Dec 2011 14:04:39 +0000 Subject: [nginx] svn commit: r4369 - branches/stable-1.0/docs/xml/nginx Message-ID: <20111215140439.F0CB83F9C28@mail.nginx.com> Author: mdounin Date: 2011-12-15 14:04:39 +0000 (Thu, 15 Dec 2011) New Revision: 4369 Log: nginx-1.0.11-RELEASE Modified: branches/stable-1.0/docs/xml/nginx/changes.xml Modified: branches/stable-1.0/docs/xml/nginx/changes.xml =================================================================== --- branches/stable-1.0/docs/xml/nginx/changes.xml 2011-12-14 18:06:21 UTC (rev 4368) +++ branches/stable-1.0/docs/xml/nginx/changes.xml 2011-12-15 14:04:39 UTC (rev 4369) @@ -9,6 +9,137 @@ nginx changelog + + + + +?????? ??????? ??????? ???????????? ??? ?????? SSI-???????? echo.
+??????? ????? ????????????. +
+ +now double quotes are encoded in an "echo" SSI-command output.
+Thanks to Zaur Abasmirzoev. +
+
+ + + +????????? image_filter_sharpen. + + +the "image_filter_sharpen" directive. + + + + + +? ??????? ???????? ??? ????????? segmentation fault, +???? ?????????????? SNI; +?????? ????????? ? 1.0.9. + + +a segmentation fault might occur in a worker process +if SNI was used; +the bug had appeared in 1.0.9. + + + + + +?????? SIGWINCH ?????????? ???????? ????? ??????? ?????????? ???????????? +?????; +?????? ????????? ? 1.0.9. + + +SIGWINCH signal did not work after first binary upgrade; +the bug had appeared in 1.0.9. + + + + + +?????? "If-Modified-Since", "If-Range" ? ?? ???????? ? ????????? ??????? +??????? ????? ???????????? ??????? ??? ???????????; ??? ?? ???????????? ??? +??????????? ???????????, ???? ??????????? ???? ???????? ? ?????? ????? +????????????. + + +the "If-Modified-Since", "If-Range", etc. client request header lines +might be passed to backend while caching; or not passed without caching +if caching was enabled in another part of the configuration. + + + + + +? ????????? scgi_param ??? ????????????? ????????? ??????????. + + +in the "scgi_param" directive, if complex parameters were used. + + + + + +????????? add_header ? expires ?? ???????? ??? ??????? ? ????? 206, +???? ?????? ?????????????. + + +"add_header" and "expires" directives did not work if a request was proxied +and response status code was 206. + + + + + +? ????????? "expires @time". + + +in the "expires @time" directive. + + + + + +? ?????? ngx_http_flv_module.
+??????? Piotr Sikora. +
+ +in the ngx_http_flv_module.
+Thanks to Piotr Sikora. +
+
+ + + +? ?????? ngx_http_mp4_module. + + +in the ngx_http_mp4_module. + + + + + +nginx ?? ????????? ?? FreeBSD 10. + + +nginx could not be built on FreeBSD 10. + + + + + +nginx ?? ????????? ?? AIX. + + +nginx could not be built on AIX. + + + +
+ + From mdounin at mdounin.ru Thu Dec 15 14:05:08 2011 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Thu, 15 Dec 2011 14:05:08 +0000 Subject: [nginx] svn commit: r4370 - in tags: . release-1.0.11 Message-ID: <20111215140508.D37853F9C28@mail.nginx.com> Author: mdounin Date: 2011-12-15 14:05:08 +0000 (Thu, 15 Dec 2011) New Revision: 4370 Log: release-1.0.11 tag Added: tags/release-1.0.11/ Property changes on: tags/release-1.0.11 ___________________________________________________________________ Added: svn:ignore + access.log client_body_temp fastcgi_temp proxy_temp GNUmakefile Makefile makefile nginx nginx.conf nginx-*.tar.gz objs* tmp Added: svn:mergeinfo + /trunk:3960-3974,3977-3987,3991-3996,3998,4000-4018,4020,4023,4025-4027,4034-4065,4073,4077,4086-4090,4094-4102,4106-4108,4113-4114,4129-4137,4143-4144,4147-4158,4177,4179,4182-4184,4186-4187,4189-4205,4207,4209-4210,4212,4217-4223,4227-4232,4235-4237,4265-4268,4270,4274-4276,4278-4280,4282-4284,4294-4295,4298,4300-4305,4307-4309,4313,4315,4321,4342-4343 From zls.sogou at gmail.com Fri Dec 16 16:34:15 2011 From: zls.sogou at gmail.com (lanshun zhou) Date: Sat, 17 Dec 2011 00:34:15 +0800 Subject: [BUG] url not properly handled for try_files and error_page redirect in ngx_http_internal_redirect Message-ID: url is changed in ngx_http_internal_redirect, but some flags like r->valid_unparsed_uri are not always reset. Then in ngx_http_proxy_create_request the original uri is sent to backends?instead of the new one. This affects the redirects in ngx_http_core_try_files_phase and ngx_http_send_error_page. simple fix: diff -ruN nginx-1.1.11/src/http/ngx_http_core_module.c nginx-1.1.11_zls/src/http/ngx_http_core_module.c --- nginx-1.1.11/src/http/ngx_http_core_module.c 2011-12-06 21:23:37.000000000 +0800 +++ nginx-1.1.11_zls/src/http/ngx_http_core_module.c 2011-12-16 16:31:27.751927635 +0800 @@ -2481,6 +2481,8 @@ r->uri = *uri; + r->valid_unparsed_uri = 0; + if (args) { r->args = *args; diff -ruN nginx-1.1.11/src/http/ngx_http_upstream.c nginx-1.1.11_zls/src/http/ngx_http_upstream.c --- nginx-1.1.11/src/http/ngx_http_upstream.c 2011-12-09 21:19:57.000000000 +0800 +++ nginx-1.1.11_zls/src/http/ngx_http_upstream.c 2011-12-16 16:30:25.399218885 +0800 @@ -1895,8 +1895,6 @@ r->method = NGX_HTTP_GET; } - r->valid_unparsed_uri = 0; - ngx_http_internal_redirect(r, uri, &args); ngx_http_finalize_request(r, NGX_DONE); return NGX_DONE; -------------- next part -------------- A non-text attachment was scrubbed... Name: valid_unparsed_uri.patch Type: application/octet-stream Size: 907 bytes Desc: not available URL: From mdounin at mdounin.ru Fri Dec 16 17:17:41 2011 From: mdounin at mdounin.ru (Maxim Dounin) Date: Fri, 16 Dec 2011 21:17:41 +0400 Subject: [BUG] url not properly handled for try_files and error_page redirect in ngx_http_internal_redirect In-Reply-To: References: Message-ID: <20111216171741.GI67687@mdounin.ru> Hello! On Sat, Dec 17, 2011 at 12:34:15AM +0800, lanshun zhou wrote: > url is changed in ngx_http_internal_redirect, but some flags like > r->valid_unparsed_uri > are not always reset. Then in ngx_http_proxy_create_request the > original uri is sent to > backends?instead of the new one. > > This affects the redirects in ngx_http_core_try_files_phase and > ngx_http_send_error_page. For others, from http://trac.nginx.org/nginx/ticket/70: Historically, such behaviour of the ngx_http_internal_redirect() was a feature: it allowed to pass the same request to (another) upstream server via error_page redirection. Since then named locations appeared though, and it's probably time to start resetting r->valid_unparsed_uri on internal redirects. (The try_files behaviour outlined above is certainly a bug.) > > simple fix: > > diff -ruN nginx-1.1.11/src/http/ngx_http_core_module.c > nginx-1.1.11_zls/src/http/ngx_http_core_module.c > --- nginx-1.1.11/src/http/ngx_http_core_module.c 2011-12-06 > 21:23:37.000000000 +0800 > +++ nginx-1.1.11_zls/src/http/ngx_http_core_module.c 2011-12-16 > 16:31:27.751927635 +0800 > @@ -2481,6 +2481,8 @@ > > r->uri = *uri; > > + r->valid_unparsed_uri = 0; > + > if (args) { > r->args = *args; > > diff -ruN nginx-1.1.11/src/http/ngx_http_upstream.c > nginx-1.1.11_zls/src/http/ngx_http_upstream.c > --- nginx-1.1.11/src/http/ngx_http_upstream.c 2011-12-09 > 21:19:57.000000000 +0800 > +++ nginx-1.1.11_zls/src/http/ngx_http_upstream.c 2011-12-16 > 16:30:25.399218885 +0800 > @@ -1895,8 +1895,6 @@ > r->method = NGX_HTTP_GET; > } > > - r->valid_unparsed_uri = 0; > - > ngx_http_internal_redirect(r, uri, &args); > ngx_http_finalize_request(r, NGX_DONE); > return NGX_DONE; I think the patch is right and should be committed. If somebody is still using old-style error_page + proxy_pass without uri, it's time to start using named locations instead. (Not sure if we're going to merge it into 1.0.x stable branch though.) Maxim Dounin From mdounin at mdounin.ru Mon Dec 19 11:21:47 2011 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Mon, 19 Dec 2011 11:21:47 +0000 Subject: [nginx] svn commit: r4371 - in trunk/src: core http/modules/perl Message-ID: <20111219112147.5EC983F9C27@mail.nginx.com> Author: mdounin Date: 2011-12-19 11:21:46 +0000 (Mon, 19 Dec 2011) New Revision: 4371 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 2011-12-15 14:05:08 UTC (rev 4370) +++ trunk/src/core/nginx.h 2011-12-19 11:21:46 UTC (rev 4371) @@ -9,7 +9,7 @@ #define nginx_version 1001011 -#define NGINX_VERSION "1.1.11" +#define NGINX_VERSION "1.1.12" #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 2011-12-15 14:05:08 UTC (rev 4370) +++ trunk/src/http/modules/perl/nginx.pm 2011-12-19 11:21:46 UTC (rev 4371) @@ -48,7 +48,7 @@ HTTP_INSUFFICIENT_STORAGE ); -our $VERSION = '1.1.11'; +our $VERSION = '1.1.12'; require XSLoader; XSLoader::load('nginx', $VERSION); From mdounin at mdounin.ru Mon Dec 19 11:23:16 2011 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Mon, 19 Dec 2011 11:23:16 +0000 Subject: [nginx] svn commit: r4372 - trunk/src/http/modules Message-ID: <20111219112316.9758B3F9C27@mail.nginx.com> Author: mdounin Date: 2011-12-19 11:23:16 +0000 (Mon, 19 Dec 2011) New Revision: 4372 Log: Fixed incorrect use of r->http_version in scgi module. The r->http_version is a version of client's request, and modules must not set it unless they are really willing to downgrade protocol version used for a response (i.e. to HTTP/0.9 if no response headers are available). In neither case r->http_version may be upgraded. The former code downgraded response from HTTP/1.1 to HTTP/1.0 for no reason, causing various problems (see ticket #66). It was also possible that HTTP/0.9 requests were upgraded to HTTP/1.0. Modified: trunk/src/http/modules/ngx_http_scgi_module.c Modified: trunk/src/http/modules/ngx_http_scgi_module.c =================================================================== --- trunk/src/http/modules/ngx_http_scgi_module.c 2011-12-19 11:21:46 UTC (rev 4371) +++ trunk/src/http/modules/ngx_http_scgi_module.c 2011-12-19 11:23:16 UTC (rev 4372) @@ -857,11 +857,7 @@ } if (rc == NGX_ERROR) { - - r->http_version = NGX_HTTP_VERSION_9; - u->process_header = ngx_http_scgi_process_header; - return ngx_http_scgi_process_header(r); } @@ -961,12 +957,12 @@ ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "http scgi header done"); - if (r->http_version > NGX_HTTP_VERSION_9) { + u = r->upstream; + + if (u->headers_in.status_n) { return NGX_OK; } - u = r->upstream; - if (u->headers_in.status) { status_line = &u->headers_in.status->value; @@ -978,12 +974,10 @@ return NGX_HTTP_UPSTREAM_INVALID_HEADER; } - r->http_version = NGX_HTTP_VERSION_10; u->headers_in.status_n = status; u->headers_in.status_line = *status_line; } else if (u->headers_in.location) { - r->http_version = NGX_HTTP_VERSION_10; u->headers_in.status_n = 302; ngx_str_set(&u->headers_in.status_line, "302 Moved Temporarily"); From mdounin at mdounin.ru Mon Dec 19 11:24:33 2011 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Mon, 19 Dec 2011 11:24:33 +0000 Subject: [nginx] svn commit: r4373 - trunk/src/http/modules Message-ID: <20111219112433.1CA013F9C22@mail.nginx.com> Author: mdounin Date: 2011-12-19 11:24:32 +0000 (Mon, 19 Dec 2011) New Revision: 4373 Log: Scgi: removed duplicate function declaration. Modified: trunk/src/http/modules/ngx_http_scgi_module.c Modified: trunk/src/http/modules/ngx_http_scgi_module.c =================================================================== --- trunk/src/http/modules/ngx_http_scgi_module.c 2011-12-19 11:23:16 UTC (rev 4372) +++ trunk/src/http/modules/ngx_http_scgi_module.c 2011-12-19 11:24:32 UTC (rev 4373) @@ -36,7 +36,6 @@ static ngx_int_t ngx_http_scgi_reinit_request(ngx_http_request_t *r); static ngx_int_t ngx_http_scgi_process_status_line(ngx_http_request_t *r); static ngx_int_t ngx_http_scgi_process_header(ngx_http_request_t *r); -static ngx_int_t ngx_http_scgi_process_header(ngx_http_request_t *r); static void ngx_http_scgi_abort_request(ngx_http_request_t *r); static void ngx_http_scgi_finalize_request(ngx_http_request_t *r, ngx_int_t rc); From mdounin at mdounin.ru Mon Dec 19 11:25:41 2011 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Mon, 19 Dec 2011 11:25:41 +0000 Subject: [nginx] svn commit: r4374 - trunk/src/http/modules Message-ID: <20111219112541.295173F9C22@mail.nginx.com> Author: mdounin Date: 2011-12-19 11:25:40 +0000 (Mon, 19 Dec 2011) New Revision: 4374 Log: Scgi: removed error if there is no Status header. The SCGI specification doesn't specify format of the response, and assuming CGI specs should be used there is no reason to complain. RFC 3875 explicitly states that "A Status header field is optional, and status 200 'OK' is assumed if it is omitted". Modified: trunk/src/http/modules/ngx_http_scgi_module.c Modified: trunk/src/http/modules/ngx_http_scgi_module.c =================================================================== --- trunk/src/http/modules/ngx_http_scgi_module.c 2011-12-19 11:24:32 UTC (rev 4373) +++ trunk/src/http/modules/ngx_http_scgi_module.c 2011-12-19 11:25:40 UTC (rev 4374) @@ -982,9 +982,6 @@ "302 Moved Temporarily"); } else { - ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, - "upstream sent neither valid HTTP/1.0 header " - "nor \"Status\" header line"); u->headers_in.status_n = 200; ngx_str_set(&u->headers_in.status_line, "200 OK"); } From vbart at nginx.com Mon Dec 19 13:28:23 2011 From: vbart at nginx.com (vbart at nginx.com) Date: Mon, 19 Dec 2011 13:28:23 +0000 Subject: [nginx] svn commit: r4375 - trunk/src/http/modules Message-ID: Author: vbart Date: 2011-12-19 13:28:22 +0000 (Mon, 19 Dec 2011) New Revision: 4375 Modified: trunk/src/http/modules/ngx_http_ssi_filter_module.c Log: SSI bugfix: the "if" command did not work inside the "block" command and produced parsing errors. Modified: trunk/src/http/modules/ngx_http_ssi_filter_module.c =================================================================== --- trunk/src/http/modules/ngx_http_ssi_filter_module.c 2011-12-19 11:25:40 UTC (rev 4374) +++ trunk/src/http/modules/ngx_http_ssi_filter_module.c 2011-12-19 13:28:22 UTC (rev 4375) @@ -624,16 +624,6 @@ continue; } - if (cmd->conditional - && (ctx->conditional == 0 - || ctx->conditional > cmd->conditional)) - { - ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, - "invalid context of SSI command: \"%V\"", - &ctx->command); - goto ssi_error; - } - if (!ctx->output && !cmd->block) { if (ctx->block) { @@ -709,6 +699,16 @@ } } + if (cmd->conditional + && (ctx->conditional == 0 + || ctx->conditional > cmd->conditional)) + { + ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, + "invalid context of SSI command: \"%V\"", + &ctx->command); + goto ssi_error; + } + if (ctx->params.nelts > NGX_HTTP_SSI_MAX_PARAMS) { ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "too many SSI command paramters: \"%V\"", From mdounin at mdounin.ru Mon Dec 19 14:11:48 2011 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Mon, 19 Dec 2011 14:11:48 +0000 Subject: [nginx] svn commit: r4376 - trunk/src/http Message-ID: <20111219141148.957653F9C27@mail.nginx.com> Author: mdounin Date: 2011-12-19 14:11:48 +0000 (Mon, 19 Dec 2011) New Revision: 4376 Log: Added clearing of r->valid_unparsed_uri on internal redirects. This resolves issue with try_files (see ticket #70), configuration like location / { try_files $uri /index.php; } location /index.php { proxy_pass http://backend; } caused nginx to use original request uri in a request to a backend. Historically, not clearing of the r->valid_unparsed_uri on internal redirect was a feature: it allowed to pass the same request to (another) upstream server via error_page redirection. Since then named locations appeared though, and it's time to start resetting r->valid_unparsed_uri on internal redirects. Configurations still using this feature should be converted to use named locations instead. Patch by Lanshun Zhou. Modified: trunk/src/http/ngx_http_core_module.c trunk/src/http/ngx_http_upstream.c Modified: trunk/src/http/ngx_http_core_module.c =================================================================== --- trunk/src/http/ngx_http_core_module.c 2011-12-19 13:28:22 UTC (rev 4375) +++ trunk/src/http/ngx_http_core_module.c 2011-12-19 14:11:48 UTC (rev 4376) @@ -2506,6 +2506,7 @@ #endif r->internal = 1; + r->valid_unparsed_uri = 0; r->add_uri_to_alias = 0; r->main->count++; Modified: trunk/src/http/ngx_http_upstream.c =================================================================== --- trunk/src/http/ngx_http_upstream.c 2011-12-19 13:28:22 UTC (rev 4375) +++ trunk/src/http/ngx_http_upstream.c 2011-12-19 14:11:48 UTC (rev 4376) @@ -1895,8 +1895,6 @@ r->method = NGX_HTTP_GET; } - r->valid_unparsed_uri = 0; - ngx_http_internal_redirect(r, uri, &args); ngx_http_finalize_request(r, NGX_DONE); return NGX_DONE; From mdounin at mdounin.ru Mon Dec 19 14:13:14 2011 From: mdounin at mdounin.ru (Maxim Dounin) Date: Mon, 19 Dec 2011 18:13:14 +0400 Subject: [BUG] url not properly handled for try_files and error_page redirect in ngx_http_internal_redirect In-Reply-To: <20111216171741.GI67687@mdounin.ru> References: <20111216171741.GI67687@mdounin.ru> Message-ID: <20111219141314.GY67687@mdounin.ru> Hello! On Fri, Dec 16, 2011 at 09:17:41PM +0400, Maxim Dounin wrote: > Hello! > > On Sat, Dec 17, 2011 at 12:34:15AM +0800, lanshun zhou wrote: > > > url is changed in ngx_http_internal_redirect, but some flags like > > r->valid_unparsed_uri > > are not always reset. Then in ngx_http_proxy_create_request the > > original uri is sent to > > backends?instead of the new one. > > > > This affects the redirects in ngx_http_core_try_files_phase and > > ngx_http_send_error_page. > > For others, from http://trac.nginx.org/nginx/ticket/70: > > Historically, such behaviour of the ngx_http_internal_redirect() > was a feature: it allowed to pass the same request to (another) > upstream server via error_page redirection. Since then named > locations appeared though, and it's probably time to start > resetting r->valid_unparsed_uri on internal redirects. (The > try_files behaviour outlined above is certainly a bug.) > > > > > simple fix: > > > > diff -ruN nginx-1.1.11/src/http/ngx_http_core_module.c > > nginx-1.1.11_zls/src/http/ngx_http_core_module.c > > --- nginx-1.1.11/src/http/ngx_http_core_module.c 2011-12-06 > > 21:23:37.000000000 +0800 > > +++ nginx-1.1.11_zls/src/http/ngx_http_core_module.c 2011-12-16 > > 16:31:27.751927635 +0800 > > @@ -2481,6 +2481,8 @@ > > > > r->uri = *uri; > > > > + r->valid_unparsed_uri = 0; > > + > > if (args) { > > r->args = *args; > > > > diff -ruN nginx-1.1.11/src/http/ngx_http_upstream.c > > nginx-1.1.11_zls/src/http/ngx_http_upstream.c > > --- nginx-1.1.11/src/http/ngx_http_upstream.c 2011-12-09 > > 21:19:57.000000000 +0800 > > +++ nginx-1.1.11_zls/src/http/ngx_http_upstream.c 2011-12-16 > > 16:30:25.399218885 +0800 > > @@ -1895,8 +1895,6 @@ > > r->method = NGX_HTTP_GET; > > } > > > > - r->valid_unparsed_uri = 0; > > - > > ngx_http_internal_redirect(r, uri, &args); > > ngx_http_finalize_request(r, NGX_DONE); > > return NGX_DONE; > > I think the patch is right and should be committed. > > If somebody is still using old-style error_page + proxy_pass > without uri, it's time to start using named locations instead. > > (Not sure if we're going to merge it into 1.0.x stable branch > though.) Committed, thanks. Maxim Dounin From sb at waeme.net Tue Dec 20 16:20:23 2011 From: sb at waeme.net (sb at waeme.net) Date: Tue, 20 Dec 2011 16:20:23 +0000 Subject: [nginx] svn commit: r4377 - trunk/auto Message-ID: <20111220162023.CE57E3F9C25@mail.nginx.com> Author: fabler Date: 2011-12-20 16:20:23 +0000 (Tue, 20 Dec 2011) New Revision: 4377 Log: configure on Solaris fixed Modified: trunk/auto/install Modified: trunk/auto/install =================================================================== --- trunk/auto/install 2011-12-19 14:11:48 UTC (rev 4376) +++ trunk/auto/install 2011-12-20 16:20:23 UTC (rev 4377) @@ -72,7 +72,7 @@ esac -if test -e man/nginx.8 ; then +if test -f man/nginx.8 ; then NGX_MAN=man/nginx.8 else NGX_MAN=docs/man/nginx.8 From mdounin at mdounin.ru Tue Dec 20 18:45:05 2011 From: mdounin at mdounin.ru (Maxim Dounin) Date: Tue, 20 Dec 2011 21:45:05 +0300 Subject: [PATCH 0 of 2] limit_rate fixes Message-ID: Hello! Here are couple of limit_rate related fixes. Review and testing appreciated. Maxim Dounin From mdounin at mdounin.ru Tue Dec 20 18:45:06 2011 From: mdounin at mdounin.ru (Maxim Dounin) Date: Tue, 20 Dec 2011 21:45:06 +0300 Subject: [PATCH 1 of 2] Fixed throughput problems with large limit_rate In-Reply-To: References: Message-ID: <77a59d0863ef59a5ddce.1324403106@vm-bsd.mdounin.ru> # HG changeset patch # User Maxim Dounin # Date 1324314500 -10800 # Node ID 77a59d0863ef59a5ddce4322d94b325a923a7624 # Parent 52194af4217ad48e290058ba133e3cbf74b2d28f Fixed throughput problems with large limit_rate. Previous attempt to fix this was in r1658 (0.6.18), though that one wasn't enough (it was a noop). diff --git a/src/http/ngx_http_write_filter_module.c b/src/http/ngx_http_write_filter_module.c --- a/src/http/ngx_http_write_filter_module.c +++ b/src/http/ngx_http_write_filter_module.c @@ -262,7 +262,7 @@ ngx_http_write_filter(ngx_http_request_t } } - delay = (ngx_msec_t) ((nsent - sent) * 1000 / r->limit_rate + 1); + delay = (ngx_msec_t) ((nsent - sent) * 1000 / r->limit_rate); if (delay > 0) { c->write->delayed = 1; From mdounin at mdounin.ru Tue Dec 20 18:45:07 2011 From: mdounin at mdounin.ru (Maxim Dounin) Date: Tue, 20 Dec 2011 21:45:07 +0300 Subject: [PATCH 2 of 2] Fixed interaction of limit_rate and sendfile_max_chunk In-Reply-To: References: Message-ID: <317692c5ce9afc2c810a.1324403107@vm-bsd.mdounin.ru> # HG changeset patch # User Maxim Dounin # Date 1324402652 -10800 # Node ID 317692c5ce9afc2c810ae974392fb64f2d02113e # Parent 77a59d0863ef59a5ddce4322d94b325a923a7624 Fixed interaction of limit_rate and sendfile_max_chunk. It's possible that configured limit_rate will permit more bytes per single operation than sendfile_max_chunk. To protect disk from takeover by a single client it is necessary to apply sendfile_max_chunk as a limit regardless of configured limit_rate. See here for report (in Russian): http://mailman.nginx.org/pipermail/nginx-ru/2010-March/032806.html diff --git a/src/http/ngx_http_write_filter_module.c b/src/http/ngx_http_write_filter_module.c --- a/src/http/ngx_http_write_filter_module.c +++ b/src/http/ngx_http_write_filter_module.c @@ -223,11 +223,14 @@ ngx_http_write_filter(ngx_http_request_t return NGX_AGAIN; } - } else if (clcf->sendfile_max_chunk) { - limit = clcf->sendfile_max_chunk; + if (clcf->sendfile_max_chunk + && (off_t) clcf->sendfile_max_chunk < limit) + { + limit = clcf->sendfile_max_chunk; + } } else { - limit = 0; + limit = clcf->sendfile_max_chunk; } sent = c->sent; @@ -265,14 +268,15 @@ ngx_http_write_filter(ngx_http_request_t delay = (ngx_msec_t) ((nsent - sent) * 1000 / r->limit_rate); if (delay > 0) { + limit = 0; c->write->delayed = 1; ngx_add_timer(c->write, delay); } + } - } else if (c->write->ready - && clcf->sendfile_max_chunk - && (size_t) (c->sent - sent) - >= clcf->sendfile_max_chunk - 2 * ngx_pagesize) + if (limit + && c->write->ready + && c->sent - sent >= limit - (off_t) (2 * ngx_pagesize)) { c->write->delayed = 1; ngx_add_timer(c->write, 1); From agentzh at gmail.com Thu Dec 22 03:19:00 2011 From: agentzh at gmail.com (agentzh) Date: Thu, 22 Dec 2011 11:19:00 +0800 Subject: [PATCH] Fix a memory invalid read issue in ngx_http_gzip_ok Message-ID: Hello! Here attaches a patch for ngx_http_core_module (of the Nginx 1.0.10 core) to fix a memory invalid read bug captured by the valgrind memcheck tool on my side. When the Accept-Encoding request header takes the exact "gzip" value, the ngx_http_gzip_ok function might run out of the memory block by 1 byte when calling ngx_memcmp to compare exactly 5 bytes of data. Hopefully this patch can be applied to the mainstream nginx :) Thanks! -agentzh --- nginx-1.0.10/src/http/ngx_http_core_module.c 2011-11-01 21:45:33.000000000 +0800 +++ nginx-1.0.10-patched/src/http/ngx_http_core_module.c 2011-12-22 11:08:02.546297974 +0800 @@ -2070,7 +2070,7 @@ * Opera: "gzip, deflate" */ - if (ngx_memcmp(ae->value.data, "gzip,", 5) != 0 + if (ngx_memcmp(ae->value.data, "gzip,", ngx_min(ae->value.len, 5)) != 0 && ngx_http_gzip_accept_encoding(&ae->value) != NGX_OK) { return NGX_DECLINED; -------------- next part -------------- A non-text attachment was scrubbed... Name: nginx-1.0.10-gzip_ok_invalid_read_fix.patch Type: application/octet-stream Size: 477 bytes Desc: not available URL: From mdounin at mdounin.ru Thu Dec 22 09:00:27 2011 From: mdounin at mdounin.ru (Maxim Dounin) Date: Thu, 22 Dec 2011 13:00:27 +0400 Subject: [PATCH] Fix a memory invalid read issue in ngx_http_gzip_ok In-Reply-To: References: Message-ID: <20111222090027.GB67687@mdounin.ru> Hello! On Thu, Dec 22, 2011 at 11:19:00AM +0800, agentzh wrote: > Hello! > > Here attaches a patch for ngx_http_core_module (of the Nginx 1.0.10 > core) to fix a memory invalid read bug captured by the valgrind > memcheck tool on my side. > > When the Accept-Encoding request header takes the exact "gzip" value, > the ngx_http_gzip_ok function might run out of the memory block by 1 > byte when calling ngx_memcmp to compare exactly 5 bytes of data. > > Hopefully this patch can be applied to the mainstream nginx :) > > Thanks! > -agentzh > > --- nginx-1.0.10/src/http/ngx_http_core_module.c 2011-11-01 > 21:45:33.000000000 +0800 > +++ nginx-1.0.10-patched/src/http/ngx_http_core_module.c 2011-12-22 > 11:08:02.546297974 +0800 > @@ -2070,7 +2070,7 @@ > * Opera: "gzip, deflate" > */ > > - if (ngx_memcmp(ae->value.data, "gzip,", 5) != 0 > + if (ngx_memcmp(ae->value.data, "gzip,", ngx_min(ae->value.len, 5)) != 0 > && ngx_http_gzip_accept_encoding(&ae->value) != NGX_OK) > { > return NGX_DECLINED; There is no problem here. The "ae" is from r->headers_in and must be null-terminated. And ae->value.len is checked in previous condition to be at least 4 bytes, i.e. at least 5 bytes can be read ae->value.data. I suppose the problem is instead in your code which (incorrectly) adds headers to r->headers_in. (And the patch is wrong even if one assume we need extra checks here: it should check value.len instead of capping one passed to ngx_memcmp.) Maxim Dounin From agentzh at gmail.com Thu Dec 22 12:18:41 2011 From: agentzh at gmail.com (agentzh) Date: Thu, 22 Dec 2011 20:18:41 +0800 Subject: [PATCH] Fix a memory invalid read issue in ngx_http_gzip_ok In-Reply-To: <20111222090027.GB67687@mdounin.ru> References: <20111222090027.GB67687@mdounin.ru> Message-ID: On Thu, Dec 22, 2011 at 5:00 PM, Maxim Dounin wrote: > I suppose the problem is instead in your code which (incorrectly) > adds headers to r->headers_in. > I do strongly suggest we *should* support manipulating request headers, it's often desired by many people in real world settings :) Regards, -agentzh From mdounin at mdounin.ru Thu Dec 22 13:21:28 2011 From: mdounin at mdounin.ru (Maxim Dounin) Date: Thu, 22 Dec 2011 17:21:28 +0400 Subject: [PATCH] Fix a memory invalid read issue in ngx_http_gzip_ok In-Reply-To: References: <20111222090027.GB67687@mdounin.ru> Message-ID: <20111222132128.GG67687@mdounin.ru> Hello! On Thu, Dec 22, 2011 at 08:18:41PM +0800, agentzh wrote: > On Thu, Dec 22, 2011 at 5:00 PM, Maxim Dounin wrote: > > I suppose the problem is instead in your code which (incorrectly) > > adds headers to r->headers_in. > > > > I do strongly suggest we *should* support manipulating request > headers, it's often desired by many people in real world settings :) As I already said more than once, I don't think we should. If it's needed - it means something else needs fixing. We do support arbitrary modification of headers passed to upstream servers, and this should be enough. But, actually, nobody stops you from adding headers correctly, i.e. null-terminated. Maxim Dounin From agentzh at gmail.com Thu Dec 22 13:37:46 2011 From: agentzh at gmail.com (agentzh) Date: Thu, 22 Dec 2011 21:37:46 +0800 Subject: [PATCH] Fix a memory invalid read issue in ngx_http_gzip_ok In-Reply-To: <20111222132128.GG67687@mdounin.ru> References: <20111222090027.GB67687@mdounin.ru> <20111222132128.GG67687@mdounin.ru> Message-ID: On Thu, Dec 22, 2011 at 9:21 PM, Maxim Dounin wrote: > > As I already said more than once, I don't think we should. ?If > it's needed - it means something else needs fixing. ?We do support > arbitrary modification of headers passed to upstream servers, and > this should be enough. > > But, actually, nobody stops you from adding headers correctly, > i.e. null-terminated. > Creating null-terminated buffers ourselves often means extra memory allocations and data copying because ngx_str_t does not require a C string at all ;) Is it really so hard to just add a dead simple check there? ;) It does not break the current behavior of the Nginx core at all. If there's any other issues as you've mentioned, I'm very willing to help preparing patches :) Best, -agentzh From mdounin at mdounin.ru Thu Dec 22 15:17:25 2011 From: mdounin at mdounin.ru (Maxim Dounin) Date: Thu, 22 Dec 2011 19:17:25 +0400 Subject: [PATCH] Fix a memory invalid read issue in ngx_http_gzip_ok In-Reply-To: References: <20111222090027.GB67687@mdounin.ru> <20111222132128.GG67687@mdounin.ru> Message-ID: <20111222151725.GH67687@mdounin.ru> Hello! On Thu, Dec 22, 2011 at 09:37:46PM +0800, agentzh wrote: > On Thu, Dec 22, 2011 at 9:21 PM, Maxim Dounin wrote: > > > > As I already said more than once, I don't think we should. ?If > > it's needed - it means something else needs fixing. ?We do support > > arbitrary modification of headers passed to upstream servers, and > > this should be enough. > > > > But, actually, nobody stops you from adding headers correctly, > > i.e. null-terminated. > > > > Creating null-terminated buffers ourselves often means extra memory > allocations and data copying because ngx_str_t does not require a C > string at all ;) Yes, this is exactly the reason why headers in r->headers_in are null-terminated (as well as e.g. arguments in config parsing functions). This saves memory allocations and data copying if/when these strings will be used when null-terminated strings are required for external interfaces (and simplifies some internal code as well). In typical (and the only one as of vanilla nginx) case of headers being read from client it costs nothing. In other cases it usually means reserving another byte at configuration stage, which isn't something overwhelming either. > Is it really so hard to just add a dead simple check there? ;) It does > not break the current behavior of the Nginx core at all. If there's > any other issues as you've mentioned, I'm very willing to help > preparing patches :) Non-null-terminated headers in r->headers_in *will* break nginx, ngx_http_gzip_ok() isn't the only place which relies on r->headers_in headers being null-terminated. Take a look e.g. at ngx_http_dav_module.c. Maxim Dounin From q2011oct at gmail.com Thu Dec 22 21:51:49 2011 From: q2011oct at gmail.com (J.Q. S.) Date: Thu, 22 Dec 2011 16:51:49 -0500 Subject: ngx_http_set_ctx Message-ID: Could someone please explain what the ngx_http_set_ctx macro is doing and when it should be used? A related question, are patches that add documentation to the code welcome? Or are we trying to keep comments out of the code? -------------- next part -------------- An HTML attachment was scrubbed... URL: From agentzh at gmail.com Fri Dec 23 11:11:39 2011 From: agentzh at gmail.com (agentzh) Date: Fri, 23 Dec 2011 19:11:39 +0800 Subject: [PATCH] Fix a memory invalid read issue in ngx_http_gzip_ok In-Reply-To: <20111222151725.GH67687@mdounin.ru> References: <20111222090027.GB67687@mdounin.ru> <20111222132128.GG67687@mdounin.ru> <20111222151725.GH67687@mdounin.ru> Message-ID: On Thu, Dec 22, 2011 at 11:17 PM, Maxim Dounin wrote: > > Yes, this is exactly the reason why headers in r->headers_in are > null-terminated (as well as e.g. arguments in config parsing > functions). ?This saves memory allocations and data copying > if/when these strings will be used when null-terminated strings > are required for external interfaces (and simplifies some internal > code as well). > > In typical (and the only one as of vanilla nginx) case of headers > being read from client it costs nothing. ?In other cases it > usually means reserving another byte at configuration stage, which > isn't something overwhelming either. > [snip] > > Non-null-terminated headers in r->headers_in *will* break nginx, > ngx_http_gzip_ok() isn't the only place which relies on > r->headers_in headers being null-terminated. ?Take a look e.g. at > ngx_http_dav_module.c. > Okay, I'll ensure the header value strings null-terminated in my code. Thanks for your explanation! :) Thanks! -agentzh From mdounin at mdounin.ru Fri Dec 23 13:55:17 2011 From: mdounin at mdounin.ru (Maxim Dounin) Date: Fri, 23 Dec 2011 17:55:17 +0400 Subject: ngx_http_set_ctx In-Reply-To: References: Message-ID: <20111223135517.GP67687@mdounin.ru> Hello! On Thu, Dec 22, 2011 at 04:51:49PM -0500, J.Q. S. wrote: > Could someone please explain what the ngx_http_set_ctx macro is doing and > when it should be used? It sets pointer to a module context structure within request. It is expected to be used when module needs to preserve some information between different invocations within the same request. It's commonly used by filter modules, see e.g. src/http/modules/ngx_http_sub_filter_module.c. > A related question, are patches that add documentation to the code welcome? > Or are we trying to keep comments out of the code? Not really. We prefer to comment only non-trivial aspects of the code. Maxim Dounin From mdounin at mdounin.ru Fri Dec 23 16:04:09 2011 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Fri, 23 Dec 2011 16:04:09 +0000 Subject: [nginx] svn commit: r4378 - trunk/src/http/modules Message-ID: <20111223160410.5C24A3F9C3B@mail.nginx.com> Author: mdounin Date: 2011-12-23 16:04:09 +0000 (Fri, 23 Dec 2011) New Revision: 4378 Log: Proxy: made proxy_pass with variables more consistent. If proxy_pass was used with variables and there was no URI component, nginx always used unparsed URI. This isn't consistent with "no variables" case, where e.g. rewrites are applied even if there is no URI component. Fix is to use the same logic in both cases, i.e. only use unparsed URI if it's valid and request is the main one. Modified: trunk/src/http/modules/ngx_http_proxy_module.c Modified: trunk/src/http/modules/ngx_http_proxy_module.c =================================================================== --- trunk/src/http/modules/ngx_http_proxy_module.c 2011-12-20 16:20:23 UTC (rev 4377) +++ trunk/src/http/modules/ngx_http_proxy_module.c 2011-12-23 16:04:09 UTC (rev 4378) @@ -736,9 +736,6 @@ url.uri.len++; url.uri.data = p - 1; } - - } else { - url.uri = r->unparsed_uri; } ctx->vars.key_start = u->schema; @@ -806,7 +803,7 @@ return NGX_ERROR; } - if (plcf->proxy_lengths) { + if (plcf->proxy_lengths && ctx->vars.uri.len) { *key = ctx->vars.uri; u->uri = ctx->vars.uri; @@ -916,7 +913,7 @@ loc_len = 0; unparsed_uri = 0; - if (plcf->proxy_lengths) { + if (plcf->proxy_lengths && ctx->vars.uri.len) { uri_len = ctx->vars.uri.len; } else if (ctx->vars.uri.len == 0 && r->valid_unparsed_uri && r == r->main) @@ -1022,7 +1019,7 @@ u->uri.data = b->last; - if (plcf->proxy_lengths) { + if (plcf->proxy_lengths && ctx->vars.uri.len) { b->last = ngx_copy(b->last, ctx->vars.uri.data, ctx->vars.uri.len); } else if (unparsed_uri) { From maxim at nginx.com Sat Dec 24 06:31:58 2011 From: maxim at nginx.com (maxim at nginx.com) Date: Sat, 24 Dec 2011 06:31:58 +0000 Subject: [nginx] svn commit: r4379 - trunk/docs/xml/nginx Message-ID: <20111224063158.5D18F3F9C29@mail.nginx.com> Author: maxim Date: 2011-12-24 06:31:57 +0000 (Sat, 24 Dec 2011) New Revision: 4379 Log: Words duplications removed. Modified: trunk/docs/xml/nginx/changes.xml Modified: trunk/docs/xml/nginx/changes.xml =================================================================== --- trunk/docs/xml/nginx/changes.xml 2011-12-23 16:04:09 UTC (rev 4378) +++ trunk/docs/xml/nginx/changes.xml 2011-12-24 06:31:57 UTC (rev 4379) @@ -14812,7 +14812,7 @@ ???? ? ????????? proxy_pass ???????????? URI, ?? ?????? ????????????? ???? 80. -if the URI part is omitted in "proxy_pass" directive, the the 80 port was +if the URI part is omitted in "proxy_pass" directive, the 80 port was always used. @@ -15601,7 +15601,7 @@ the segmentation fault may occurred if there were errors while working with proxied or FastCGI server; -in the proxied mode the the bug had appeared in 0.1.29. +in the proxied mode the bug had appeared in 0.1.29.
@@ -15618,7 +15618,7 @@ the segmentation fault occurred or the worker process may got caught in an endless loop if the proxied or FastCGI server sent the "Cache-Control" header line and the "expires" directive was used; -in the proxied mode the the bug had appeared in 0.1.29. +in the proxied mode the bug had appeared in 0.1.29. @@ -15855,7 +15855,7 @@ ????????? limit_rate ?????????????? ? ?????? ?????? ? FastCGI. -the "limit_rate" directive is supported in in proxy and FastCGI mode. +the "limit_rate" directive is supported in proxy and FastCGI mode. @@ -16362,7 +16362,7 @@ if the length of the response part received at once from proxied or FastCGI server was equal to 500, then nginx returns the 500 response code; -in proxy mode the the bug had appeared in 0.1.29 only. +in proxy mode the bug had appeared in 0.1.29 only. @@ -17182,7 +17182,7 @@ ?? ????? ?????? ???? ??????? ??????? ? SSL ?????????? ??? ????????? ???????. -the timeout may occur while reading of the the client request body +the timeout may occur while reading of the client request body via SSL connections. From vbart at nginx.com Sun Dec 25 19:15:57 2011 From: vbart at nginx.com (vbart at nginx.com) Date: Sun, 25 Dec 2011 19:15:57 +0000 Subject: [nginx] svn commit: r4380 - trunk/conf Message-ID: <20111225191557.8BA603F9C2E@mail.nginx.com> Author: vbart Date: 2011-12-25 19:15:56 +0000 (Sun, 25 Dec 2011) New Revision: 4380 Log: Added the HTTPS fastcgi_param to fastcgi.conf. Modified: trunk/conf/fastcgi.conf Modified: trunk/conf/fastcgi.conf =================================================================== --- trunk/conf/fastcgi.conf 2011-12-24 06:31:57 UTC (rev 4379) +++ trunk/conf/fastcgi.conf 2011-12-25 19:15:56 UTC (rev 4380) @@ -10,6 +10,7 @@ fastcgi_param DOCUMENT_URI $document_uri; fastcgi_param DOCUMENT_ROOT $document_root; fastcgi_param SERVER_PROTOCOL $server_protocol; +fastcgi_param HTTPS $https if_not_empty; fastcgi_param GATEWAY_INTERFACE CGI/1.1; fastcgi_param SERVER_SOFTWARE nginx/$nginx_version; From vbart at nginx.com Sun Dec 25 19:32:32 2011 From: vbart at nginx.com (vbart at nginx.com) Date: Sun, 25 Dec 2011 19:32:32 +0000 Subject: [nginx] svn commit: r4381 - trunk/src/http/modules Message-ID: <20111225193233.123653F9C1F@mail.nginx.com> Author: vbart Date: 2011-12-25 19:32:31 +0000 (Sun, 25 Dec 2011) New Revision: 4381 Log: Fixed limit_conn_log_level/limit_req_log_level inheritance. The directives did not work if there were no limit_conn/limit_req specified on the same level. Modified: trunk/src/http/modules/ngx_http_limit_conn_module.c trunk/src/http/modules/ngx_http_limit_req_module.c Modified: trunk/src/http/modules/ngx_http_limit_conn_module.c =================================================================== --- trunk/src/http/modules/ngx_http_limit_conn_module.c 2011-12-25 19:15:56 UTC (rev 4380) +++ trunk/src/http/modules/ngx_http_limit_conn_module.c 2011-12-25 19:32:31 UTC (rev 4381) @@ -483,7 +483,7 @@ ngx_http_limit_conn_conf_t *conf = child; if (conf->limits.elts == NULL) { - *conf = *prev; + conf->limits = prev->limits; } ngx_conf_merge_uint_value(conf->log_level, prev->log_level, NGX_LOG_ERR); Modified: trunk/src/http/modules/ngx_http_limit_req_module.c =================================================================== --- trunk/src/http/modules/ngx_http_limit_req_module.c 2011-12-25 19:15:56 UTC (rev 4380) +++ trunk/src/http/modules/ngx_http_limit_req_module.c 2011-12-25 19:32:31 UTC (rev 4381) @@ -569,7 +569,7 @@ ngx_http_limit_req_conf_t *conf = child; if (conf->shm_zone == NULL) { - *conf = *prev; + conf->shm_zone = prev->shm_zone; } ngx_conf_merge_uint_value(conf->limit_log_level, prev->limit_log_level, From vbart at nginx.com Sun Dec 25 20:08:37 2011 From: vbart at nginx.com (vbart at nginx.com) Date: Sun, 25 Dec 2011 20:08:37 +0000 Subject: [nginx] svn commit: r4382 - trunk/src/http/modules Message-ID: <20111225200837.B34053F9C2E@mail.nginx.com> Author: vbart Date: 2011-12-25 20:08:37 +0000 (Sun, 25 Dec 2011) New Revision: 4382 Log: SSI: added regex captures support in the expression of the "if" command. Modified: trunk/src/http/modules/ngx_http_ssi_filter_module.c trunk/src/http/modules/ngx_http_ssi_filter_module.h Modified: trunk/src/http/modules/ngx_http_ssi_filter_module.c =================================================================== --- trunk/src/http/modules/ngx_http_ssi_filter_module.c 2011-12-25 19:32:31 UTC (rev 4381) +++ trunk/src/http/modules/ngx_http_ssi_filter_module.c 2011-12-25 20:08:37 UTC (rev 4382) @@ -78,6 +78,8 @@ ngx_str_t *name, ngx_uint_t key); static ngx_int_t ngx_http_ssi_evaluate_string(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ctx, ngx_str_t *text, ngx_uint_t flags); +static ngx_int_t ngx_http_ssi_regex_match(ngx_http_request_t *r, + ngx_str_t *pattern, ngx_str_t *str); static ngx_int_t ngx_http_ssi_include(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ctx, ngx_str_t **params); @@ -1531,6 +1533,30 @@ ctx = ngx_http_get_module_ctx(r->main, ngx_http_ssi_filter_module); +#if (NGX_PCRE) + { + ngx_str_t *value; + + if (key >= '0' && key <= '9') { + i = key - '0'; + + if (i < ctx->ncaptures) { + value = ngx_palloc(r->pool, sizeof(ngx_str_t)); + if (value == NULL) { + return NULL; + } + + i *= 2; + + value->data = ctx->captures_data + ctx->captures[i]; + value->len = ctx->captures[i + 1] - ctx->captures[i]; + + return value; + } + } + } +#endif + if (ctx->variables == NULL) { return NULL; } @@ -1820,6 +1846,115 @@ static ngx_int_t +ngx_http_ssi_regex_match(ngx_http_request_t *r, ngx_str_t *pattern, + ngx_str_t *str) +{ +#if (NGX_PCRE) + int rc, *captures; + u_char *p, errstr[NGX_MAX_CONF_ERRSTR]; + size_t size; + ngx_int_t key; + ngx_str_t *vv, name, value; + ngx_uint_t i, n; + ngx_http_ssi_ctx_t *ctx; + ngx_http_ssi_var_t *var; + ngx_regex_compile_t rgc; + + ngx_memzero(&rgc, sizeof(ngx_regex_compile_t)); + + rgc.pattern = *pattern; + rgc.pool = r->pool; + rgc.err.len = NGX_MAX_CONF_ERRSTR; + rgc.err.data = errstr; + + if (ngx_regex_compile(&rgc) != NGX_OK) { + ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "%V", &rgc.err); + return NGX_HTTP_SSI_ERROR; + } + + n = (rgc.captures + 1) * 3; + + captures = ngx_palloc(r->pool, n * sizeof(int)); + if (captures == NULL) { + return NGX_ERROR; + } + + rc = ngx_regex_exec(rgc.regex, str, captures, n); + + if (rc < NGX_REGEX_NO_MATCHED) { + ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0, + ngx_regex_exec_n " failed: %i on \"%V\" using \"%V\"", + rc, str, pattern); + return NGX_HTTP_SSI_ERROR; + } + + if (rc == NGX_REGEX_NO_MATCHED) { + return NGX_DECLINED; + } + + ctx = ngx_http_get_module_ctx(r->main, ngx_http_ssi_filter_module); + + ctx->ncaptures = rc; + ctx->captures = captures; + ctx->captures_data = str->data; + + if (rgc.named_captures > 0) { + + if (ctx->variables == NULL) { + ctx->variables = ngx_list_create(r->pool, 4, + sizeof(ngx_http_ssi_var_t)); + if (ctx->variables == NULL) { + return NGX_ERROR; + } + } + + size = rgc.name_size; + p = rgc.names; + + for (i = 0; i < (ngx_uint_t) rgc.named_captures; i++, p += size) { + + name.data = &p[2]; + name.len = ngx_strlen(name.data); + + n = 2 * ((p[0] << 8) + p[1]); + + value.data = &str->data[captures[n]]; + value.len = captures[n + 1] - captures[n]; + + key = ngx_hash_strlow(name.data, name.data, name.len); + + vv = ngx_http_ssi_get_variable(r, &name, key); + + if (vv) { + *vv = value; + continue; + } + + var = ngx_list_push(ctx->variables); + if (var == NULL) { + return NGX_ERROR; + } + + var->name = name; + var->key = key; + var->value = value; + } + } + + return NGX_OK; + +#else + + ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0, + "the using of the regex \"%V\" in SSI requires PCRE library", + pattern); + return NGX_HTTP_SSI_ERROR; + +#endif +} + + +static ngx_int_t ngx_http_ssi_include(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ctx, ngx_str_t **params) { @@ -2451,39 +2586,17 @@ } } else { -#if (NGX_PCRE) - ngx_regex_compile_t rgc; - u_char errstr[NGX_MAX_CONF_ERRSTR]; - right.data[right.len] = '\0'; - ngx_memzero(&rgc, sizeof(ngx_regex_compile_t)); + rc = ngx_http_ssi_regex_match(r, &right, &left); - rgc.pattern = right; - rgc.pool = r->pool; - rgc.err.len = NGX_MAX_CONF_ERRSTR; - rgc.err.data = errstr; - - if (ngx_regex_compile(&rgc) != NGX_OK) { - ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "%V", &rgc.err); - return NGX_HTTP_SSI_ERROR; + if (rc == NGX_OK) { + rc = 0; + } else if (rc == NGX_DECLINED) { + rc = -1; + } else { + return rc; } - - rc = ngx_regex_exec(rgc.regex, &left, NULL, 0); - - if (rc < NGX_REGEX_NO_MATCHED) { - ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0, - ngx_regex_exec_n " failed: %i on \"%V\" using \"%V\"", - rc, &left, &right); - return NGX_HTTP_SSI_ERROR; - } -#else - ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0, - "the using of the regex \"%V\" in SSI " - "requires PCRE library", &right); - - return NGX_HTTP_SSI_ERROR; -#endif } if ((rc == 0 && !negative) || (rc != 0 && negative)) { Modified: trunk/src/http/modules/ngx_http_ssi_filter_module.h =================================================================== --- trunk/src/http/modules/ngx_http_ssi_filter_module.h 2011-12-25 19:32:31 UTC (rev 4381) +++ trunk/src/http/modules/ngx_http_ssi_filter_module.h 2011-12-25 20:08:37 UTC (rev 4382) @@ -64,6 +64,12 @@ ngx_list_t *variables; ngx_array_t *blocks; +#if (NGX_PCRE) + ngx_uint_t ncaptures; + int *captures; + u_char *captures_data; +#endif + unsigned conditional:2; unsigned encoding:2; unsigned block:1; From q2011oct at gmail.com Sun Dec 25 23:08:02 2011 From: q2011oct at gmail.com (J.Q. S.) Date: Sun, 25 Dec 2011 18:08:02 -0500 Subject: Could someone please review this code snippet and tell me what I've missed? Message-ID: As an exercise I've written a module which receives a request, sets a 10 second timer, then replies "Hello World!" when the timer expires. I'm running nginx with deamon off/master off to make things as simple as possible. The first time through everything seems to work perfectly. However, the second time I don't get any response at all - from any url the server normally handles. This code does work though multiple invocations if I call bottom handler function directly from the top handler function, without using the timer. I was wondering if someone could spot check my code and tell me what I'm doing wrong? static u_char ngx_hello_string[] = "Hello, world!"; static ngx_int_t ngx_http_alpha_handler_top(ngx_http_request_t *r) { ngx_int_t rc; ngx_http_alpha_loc_conf_t *ctx; /* we response to 'GET' and 'HEAD' requests only */ if (!(r->method & (NGX_HTTP_GET|NGX_HTTP_HEAD))) { return(NGX_HTTP_NOT_ALLOWED); } /* discard request body, since we don't need it here */ rc = ngx_http_discard_request_body(r); if (rc != NGX_OK) { return(rc); } ctx = ngx_http_get_module_loc_conf(r, ngx_http_alpha_module); if (ctx->event == NULL) { ctx->event = ngx_calloc(sizeof(ngx_event_t), r->connection->log); if (ctx->event == NULL) { return NGX_HTTP_INTERNAL_SERVER_ERROR; } } ngx_memzero(ctx->event, sizeof(ngx_event_t)); ctx->event->handler = ngx_http_alpha_handler_bottom; ctx->event->data = r; ctx->event->log = r->connection->log; ngx_add_timer(ctx->event, 10 * 1000); r->main->count++; return(NGX_DONE); } static ngx_int_t ngx_http_alpha_handler_bottom(ngx_event_t *ev) { ngx_http_request_t *r; ngx_int_t rc; ngx_buf_t *b; ngx_chain_t out; r = (ngx_http_request_t *)ev->data; /* set the 'Content-type' header */ r->headers_out.content_type_len = sizeof("text/html") - 1; r->headers_out.content_type.len = sizeof("text/html") - 1; r->headers_out.content_type.data = (u_char *) "text/html"; /* send the header only, if the request type is http 'HEAD' */ if (r->method == NGX_HTTP_HEAD) { r->headers_out.status = NGX_HTTP_OK; r->headers_out.content_length_n = sizeof(ngx_hello_string) - 1; return(ngx_http_send_header(r)); } /* allocate a buffer for your response body */ b = ngx_pcalloc(r->pool, sizeof(ngx_buf_t)); if (b == NULL) { return(NGX_HTTP_INTERNAL_SERVER_ERROR); } /* attach this buffer to the buffer chain */ out.buf = b; out.next = NULL; /* adjust the pointers of the buffer */ b->pos = ngx_hello_string; b->last = ngx_hello_string + sizeof(ngx_hello_string) - 1; b->memory = 1; /* this buffer is in memory */ b->last_buf = 1; /* this is the last buffer in the buffer chain */ /* set the status line */ r->headers_out.status = NGX_HTTP_OK; r->headers_out.content_length_n = sizeof(ngx_hello_string) - 1; /* send the headers of your response */ rc = ngx_http_send_header(r); if (rc == NGX_ERROR || rc > NGX_OK || r->header_only) { return(rc); } /* send the buffer chain of your response */ return(ngx_http_output_filter(r, &out)); } -------------- next part -------------- An HTML attachment was scrubbed... URL: From zzz at zzz.org.ua Mon Dec 26 00:20:21 2011 From: zzz at zzz.org.ua (Alexandr Gomoliako) Date: Mon, 26 Dec 2011 02:20:21 +0200 Subject: Could someone please review this code snippet and tell me what I've missed? In-Reply-To: References: Message-ID: On Mon, Dec 26, 2011 at 1:08 AM, J.Q. S. wrote: > As an exercise I've written a module which receives a request, sets a 10 > second timer, then replies "Hello World!" when the timer expires. I'm > running nginx with deamon off/master off to make things as simple as > possible. The first time through everything seems to work perfectly. > However, the second time I don't get any response at all - from any url the > server normally handles. This code does work though multiple invocations if > I call bottom handler function directly from the top handler function, > without using the timer. I was wondering if someone could spot check my code > and tell me what I'm doing wrong? > static ngx_int_t ngx_http_alpha_handler_bottom(ngx_event_t *ev) { ... > ? return(ngx_http_output_filter(r, &out)); You have to finalize your request manually here. P.S. I have a simple call tracer for nginx, should help you figure out how everything works in no time, literally. Check it out: https://github.com/zzzcpan/ngx_trace From wandenberg at gmail.com Mon Dec 26 01:33:41 2011 From: wandenberg at gmail.com (Wandenberg Peixoto) Date: Sun, 25 Dec 2011 23:33:41 -0200 Subject: Could someone please review this code snippet and tell me what I've missed? In-Reply-To: References: Message-ID: You probably should use ngx_http_get_module_ctx/ngx_http_set_module_ctx to keep your timer reference, if you want to have one timer per request. ngx_http_get_module_loc_conf will do one timer per location. On Sun, Dec 25, 2011 at 10:20 PM, Alexandr Gomoliako wrote: > On Mon, Dec 26, 2011 at 1:08 AM, J.Q. S. wrote: > > As an exercise I've written a module which receives a request, sets a 10 > > second timer, then replies "Hello World!" when the timer expires. I'm > > running nginx with deamon off/master off to make things as simple as > > possible. The first time through everything seems to work perfectly. > > However, the second time I don't get any response at all - from any url > the > > server normally handles. This code does work though multiple invocations > if > > I call bottom handler function directly from the top handler function, > > without using the timer. I was wondering if someone could spot check my > code > > and tell me what I'm doing wrong? > > > static ngx_int_t ngx_http_alpha_handler_bottom(ngx_event_t *ev) { > ... > > > return(ngx_http_output_filter(r, &out)); > > You have to finalize your request manually here. > > P.S. > I have a simple call tracer for nginx, should help you figure out > how everything works in no time, literally. > > Check it out: > https://github.com/zzzcpan/ngx_trace > > _______________________________________________ > 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 zzz at zzz.org.ua Mon Dec 26 02:28:51 2011 From: zzz at zzz.org.ua (Alexandr Gomoliako) Date: Mon, 26 Dec 2011 04:28:51 +0200 Subject: Could someone please review this code snippet and tell me what I've missed? In-Reply-To: References: Message-ID: On Mon, Dec 26, 2011 at 3:33 AM, Wandenberg Peixoto wrote: > You probably should use ngx_http_get_module_ctx/ngx_http_set_module_ctx to > keep your timer reference, > ngx_http_get_module_loc_conf will do one timer per location. Exactly. My guess was wrong then. I don't have enough patience to carefully read messy code. From q2011oct at gmail.com Mon Dec 26 03:23:47 2011 From: q2011oct at gmail.com (J.Q. S.) Date: Sun, 25 Dec 2011 22:23:47 -0500 Subject: Could someone please review this code snippet and tell me what I've missed? In-Reply-To: References: Message-ID: Yes, I will want to do that once I have it working per location, thank you. I am trying to build up from a simple example to a more complex one. On Sun, Dec 25, 2011 at 8:33 PM, Wandenberg Peixoto wrote: > You probably should use ngx_http_get_module_ctx/ngx_http_set_module_ctx to > keep your timer reference, > if you want to have one timer per request. > > ngx_http_get_module_loc_conf will do one timer per location. > > > > On Sun, Dec 25, 2011 at 10:20 PM, Alexandr Gomoliako wrote: > >> On Mon, Dec 26, 2011 at 1:08 AM, J.Q. S. wrote: >> > As an exercise I've written a module which receives a request, sets a 10 >> > second timer, then replies "Hello World!" when the timer expires. I'm >> > running nginx with deamon off/master off to make things as simple as >> > possible. The first time through everything seems to work perfectly. >> > However, the second time I don't get any response at all - from any url >> the >> > server normally handles. This code does work though multiple >> invocations if >> > I call bottom handler function directly from the top handler function, >> > without using the timer. I was wondering if someone could spot check my >> code >> > and tell me what I'm doing wrong? >> >> > static ngx_int_t ngx_http_alpha_handler_bottom(ngx_event_t *ev) { >> ... >> >> > return(ngx_http_output_filter(r, &out)); >> >> You have to finalize your request manually here. >> >> P.S. >> I have a simple call tracer for nginx, should help you figure out >> how everything works in no time, literally. >> >> Check it out: >> https://github.com/zzzcpan/ngx_trace >> >> _______________________________________________ >> 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 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From q2011oct at gmail.com Mon Dec 26 05:07:26 2011 From: q2011oct at gmail.com (J.Q. S.) Date: Mon, 26 Dec 2011 00:07:26 -0500 Subject: Could someone please review this code snippet and tell me what I've missed? In-Reply-To: References: Message-ID: Thanks, that was the issue exactly, its working now. On Sun, Dec 25, 2011 at 7:20 PM, Alexandr Gomoliako wrote: > On Mon, Dec 26, 2011 at 1:08 AM, J.Q. S. wrote: > > As an exercise I've written a module which receives a request, sets a 10 > > second timer, then replies "Hello World!" when the timer expires. I'm > > running nginx with deamon off/master off to make things as simple as > > possible. The first time through everything seems to work perfectly. > > However, the second time I don't get any response at all - from any url > the > > server normally handles. This code does work though multiple invocations > if > > I call bottom handler function directly from the top handler function, > > without using the timer. I was wondering if someone could spot check my > code > > and tell me what I'm doing wrong? > > > static ngx_int_t ngx_http_alpha_handler_bottom(ngx_event_t *ev) { > ... > > > return(ngx_http_output_filter(r, &out)); > > You have to finalize your request manually here. > > P.S. > I have a simple call tracer for nginx, should help you figure out > how everything works in no time, literally. > > Check it out: > https://github.com/zzzcpan/ngx_trace > > _______________________________________________ > 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 mdounin at mdounin.ru Mon Dec 26 10:49:04 2011 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Mon, 26 Dec 2011 10:49:04 +0000 Subject: [nginx] svn commit: r4383 - trunk/src/http/modules Message-ID: <20111226104904.8E6773F9C94@mail.nginx.com> Author: mdounin Date: 2011-12-26 10:49:03 +0000 (Mon, 26 Dec 2011) New Revision: 4383 Log: Fixed mp4 if first entry in stsc was skipped (ticket #72). If first entry in stsc atom was skipped, and seek was to chunk boundary, than first_chunk in the generated stsc table wasn't set to 1. Modified: trunk/src/http/modules/ngx_http_mp4_module.c Modified: trunk/src/http/modules/ngx_http_mp4_module.c =================================================================== --- trunk/src/http/modules/ngx_http_mp4_module.c 2011-12-25 20:08:37 UTC (rev 4382) +++ trunk/src/http/modules/ngx_http_mp4_module.c 2011-12-26 10:49:03 UTC (rev 4383) @@ -2382,6 +2382,8 @@ data->pos = (u_char *) entry; atom_size = sizeof(ngx_mp4_stsc_atom_t) + (data->last - data->pos); + ngx_mp4_set_32value(entry->chunk, 1); + if (trak->chunk_samples) { first = &trak->stsc_chunk_entry; From mdounin at mdounin.ru Mon Dec 26 10:49:57 2011 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Mon, 26 Dec 2011 10:49:57 +0000 Subject: [nginx] svn commit: r4384 - trunk/src/http Message-ID: <20111226104957.D48C93F9C1A@mail.nginx.com> Author: mdounin Date: 2011-12-26 10:49:57 +0000 (Mon, 26 Dec 2011) New Revision: 4384 Log: Fixed throughput problems with large limit_rate. Previous attempt to fix this was in r1658 (0.6.18), though that one wasn't enough (it was a noop). Modified: trunk/src/http/ngx_http_write_filter_module.c Modified: trunk/src/http/ngx_http_write_filter_module.c =================================================================== --- trunk/src/http/ngx_http_write_filter_module.c 2011-12-26 10:49:03 UTC (rev 4383) +++ trunk/src/http/ngx_http_write_filter_module.c 2011-12-26 10:49:57 UTC (rev 4384) @@ -262,7 +262,7 @@ } } - delay = (ngx_msec_t) ((nsent - sent) * 1000 / r->limit_rate + 1); + delay = (ngx_msec_t) ((nsent - sent) * 1000 / r->limit_rate); if (delay > 0) { c->write->delayed = 1; From mdounin at mdounin.ru Mon Dec 26 10:51:24 2011 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Mon, 26 Dec 2011 10:51:24 +0000 Subject: [nginx] svn commit: r4385 - trunk/src/http Message-ID: <20111226105124.4F2953F9C22@mail.nginx.com> Author: mdounin Date: 2011-12-26 10:51:24 +0000 (Mon, 26 Dec 2011) New Revision: 4385 Log: Fixed interaction of limit_rate and sendfile_max_chunk. It's possible that configured limit_rate will permit more bytes per single operation than sendfile_max_chunk. To protect disk from takeover by a single client it is necessary to apply sendfile_max_chunk as a limit regardless of configured limit_rate. See here for report (in Russian): http://mailman.nginx.org/pipermail/nginx-ru/2010-March/032806.html Modified: trunk/src/http/ngx_http_write_filter_module.c Modified: trunk/src/http/ngx_http_write_filter_module.c =================================================================== --- trunk/src/http/ngx_http_write_filter_module.c 2011-12-26 10:49:57 UTC (rev 4384) +++ trunk/src/http/ngx_http_write_filter_module.c 2011-12-26 10:51:24 UTC (rev 4385) @@ -223,11 +223,14 @@ return NGX_AGAIN; } - } else if (clcf->sendfile_max_chunk) { - limit = clcf->sendfile_max_chunk; + if (clcf->sendfile_max_chunk + && (off_t) clcf->sendfile_max_chunk < limit) + { + limit = clcf->sendfile_max_chunk; + } } else { - limit = 0; + limit = clcf->sendfile_max_chunk; } sent = c->sent; @@ -265,14 +268,15 @@ delay = (ngx_msec_t) ((nsent - sent) * 1000 / r->limit_rate); if (delay > 0) { + limit = 0; c->write->delayed = 1; ngx_add_timer(c->write, delay); } + } - } else if (c->write->ready - && clcf->sendfile_max_chunk - && (size_t) (c->sent - sent) - >= clcf->sendfile_max_chunk - 2 * ngx_pagesize) + if (limit + && c->write->ready + && c->sent - sent >= limit - (off_t) (2 * ngx_pagesize)) { c->write->delayed = 1; ngx_add_timer(c->write, 1); From mdounin at mdounin.ru Mon Dec 26 11:15:24 2011 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Mon, 26 Dec 2011 11:15:24 +0000 Subject: [nginx] svn commit: r4386 - in trunk/src/http: . modules Message-ID: <20111226111524.4DE0B3F9C94@mail.nginx.com> Author: mdounin Date: 2011-12-26 11:15:23 +0000 (Mon, 26 Dec 2011) New Revision: 4386 Log: Cache locks initial implementation. New directives: proxy_cache_lock on/off, proxy_cache_lock_timeout. With proxy_cache_lock set to on, only one request will be allowed to go to upstream for a particular cache item. Others will wait for a response to appear in cache (or cache lock released) up to proxy_cache_lock_timeout. Waiting requests will recheck if they have cached response ready (or are allowed to run) every 500ms. Note: we intentionally don't intercept NGX_DECLINED possibly returned by ngx_http_file_cache_read(). This needs more work (possibly safe, but needs further investigation). Anyway, it's exceptional situation. Note: probably there should be a way to disable caching of responses if there is already one request fetching resource to cache (without waiting at all). Two possible ways include another cache lock option ("no_cache") or using proxy_no_cache with some supplied variable. Note: probably there should be a way to lock updating requests as well. For now "proxy_cache_use_stale updating" is available. Modified: trunk/src/http/modules/ngx_http_proxy_module.c trunk/src/http/ngx_http_cache.h trunk/src/http/ngx_http_file_cache.c trunk/src/http/ngx_http_upstream.c trunk/src/http/ngx_http_upstream.h Modified: trunk/src/http/modules/ngx_http_proxy_module.c =================================================================== --- trunk/src/http/modules/ngx_http_proxy_module.c 2011-12-26 10:51:24 UTC (rev 4385) +++ trunk/src/http/modules/ngx_http_proxy_module.c 2011-12-26 11:15:23 UTC (rev 4386) @@ -402,6 +402,20 @@ offsetof(ngx_http_proxy_loc_conf_t, upstream.cache_methods), &ngx_http_upstream_cache_method_mask }, + { ngx_string("proxy_cache_lock"), + 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_proxy_loc_conf_t, upstream.cache_lock), + NULL }, + + { ngx_string("proxy_cache_lock_timeout"), + NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, + ngx_conf_set_msec_slot, + NGX_HTTP_LOC_CONF_OFFSET, + offsetof(ngx_http_proxy_loc_conf_t, upstream.cache_lock_timeout), + NULL }, + #endif { ngx_string("proxy_temp_path"), @@ -2435,6 +2449,8 @@ conf->upstream.cache_bypass = NGX_CONF_UNSET_PTR; conf->upstream.no_cache = NGX_CONF_UNSET_PTR; conf->upstream.cache_valid = NGX_CONF_UNSET_PTR; + conf->upstream.cache_lock = NGX_CONF_UNSET; + conf->upstream.cache_lock_timeout = NGX_CONF_UNSET_MSEC; #endif conf->upstream.hide_headers = NGX_CONF_UNSET_PTR; @@ -2681,6 +2697,12 @@ conf->cache_key = prev->cache_key; } + ngx_conf_merge_value(conf->upstream.cache_lock, + prev->upstream.cache_lock, 0); + + ngx_conf_merge_msec_value(conf->upstream.cache_lock_timeout, + prev->upstream.cache_lock_timeout, 5000); + #endif if (conf->method.len == 0) { Modified: trunk/src/http/ngx_http_cache.h =================================================================== --- trunk/src/http/ngx_http_cache.h 2011-12-26 10:51:24 UTC (rev 4385) +++ trunk/src/http/ngx_http_cache.h 2011-12-26 11:15:23 UTC (rev 4386) @@ -79,6 +79,14 @@ ngx_http_file_cache_t *file_cache; ngx_http_file_cache_node_t *node; + ngx_msec_t lock_timeout; + ngx_msec_t wait_time; + + ngx_event_t wait_event; + + unsigned lock:1; + unsigned waiting:1; + unsigned updated:1; unsigned updating:1; unsigned exists:1; Modified: trunk/src/http/ngx_http_file_cache.c =================================================================== --- trunk/src/http/ngx_http_file_cache.c 2011-12-26 10:51:24 UTC (rev 4385) +++ trunk/src/http/ngx_http_file_cache.c 2011-12-26 11:15:23 UTC (rev 4386) @@ -10,6 +10,9 @@ #include +static ngx_int_t ngx_http_file_cache_lock(ngx_http_request_t *r, + ngx_http_cache_t *c); +static void ngx_http_file_cache_lock_wait_handler(ngx_event_t *ev); static ngx_int_t ngx_http_file_cache_read(ngx_http_request_t *r, ngx_http_cache_t *c); static ssize_t ngx_http_file_cache_aio_read(ngx_http_request_t *r, @@ -181,13 +184,13 @@ return NGX_ERROR; } + cln->handler = ngx_http_file_cache_cleanup; + cln->data = c; + if (ngx_http_file_cache_exists(cache, c) == NGX_ERROR) { return NGX_ERROR; } - cln->handler = ngx_http_file_cache_cleanup; - cln->data = c; - if (ngx_http_file_cache_name(r, cache->path) != NGX_OK) { return NGX_ERROR; } @@ -244,15 +247,24 @@ c = r->cache; + if (c->waiting) { + return NGX_AGAIN; + } + if (c->buf) { return ngx_http_file_cache_read(r, c); } cache = c->file_cache; - cln = ngx_pool_cleanup_add(r->pool, 0); - if (cln == NULL) { - return NGX_ERROR; + if (c->node == NULL) { + cln = ngx_pool_cleanup_add(r->pool, 0); + if (cln == NULL) { + return NGX_ERROR; + } + + cln->handler = ngx_http_file_cache_cleanup; + cln->data = c; } rc = ngx_http_file_cache_exists(cache, c); @@ -264,9 +276,6 @@ return rc; } - cln->handler = ngx_http_file_cache_cleanup; - cln->data = c; - if (rc == NGX_AGAIN) { return NGX_HTTP_CACHE_SCARCE; } @@ -306,7 +315,7 @@ } if (!test) { - return NGX_DECLINED; + goto done; } clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); @@ -330,7 +339,7 @@ case NGX_ENOENT: case NGX_ENOTDIR: - return rv; + goto done; default: ngx_log_error(NGX_LOG_CRIT, r->connection->log, of.err, @@ -354,10 +363,118 @@ } return ngx_http_file_cache_read(r, c); + +done: + + if (rv == NGX_DECLINED) { + return ngx_http_file_cache_lock(r, c); + } + + return rv; } static ngx_int_t +ngx_http_file_cache_lock(ngx_http_request_t *r, ngx_http_cache_t *c) +{ + ngx_msec_t now, timer; + ngx_http_file_cache_t *cache; + + if (!c->lock) { + return NGX_DECLINED; + } + + cache = c->file_cache; + + ngx_shmtx_lock(&cache->shpool->mutex); + + if (!c->node->updating) { + c->node->updating = 1; + c->updating = 1; + } + + ngx_shmtx_unlock(&cache->shpool->mutex); + + ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, + "http file cache lock u:%d wt:%M", + c->updating, c->wait_time); + + if (c->updating) { + return NGX_DECLINED; + } + + c->waiting = 1; + + now = ngx_current_msec; + + if (c->wait_time == 0) { + c->wait_time = now + c->lock_timeout; + + c->wait_event.handler = ngx_http_file_cache_lock_wait_handler; + c->wait_event.data = r; + c->wait_event.log = r->connection->log; + } + + timer = c->wait_time - now; + + ngx_add_timer(&c->wait_event, (timer > 500) ? 500 : timer); + + r->main->blocked++; + + return NGX_AGAIN; +} + + +static void +ngx_http_file_cache_lock_wait_handler(ngx_event_t *ev) +{ + ngx_uint_t wait; + ngx_msec_t timer; + ngx_http_cache_t *c; + ngx_http_request_t *r; + ngx_http_file_cache_t *cache; + + r = ev->data; + c = r->cache; + + ngx_log_debug0(NGX_LOG_DEBUG_HTTP, ev->log, 0, + "http file cache wait handler wt:%M cur:%M", + c->wait_time, ngx_current_msec); + + timer = c->wait_time - ngx_current_msec; + + if ((ngx_msec_int_t) timer <= 0) { + ngx_log_debug0(NGX_LOG_DEBUG_HTTP, ev->log, 0, + "http file cache lock timeout"); + c->lock = 0; + goto wakeup; + } + + cache = c->file_cache; + wait = 0; + + ngx_shmtx_lock(&cache->shpool->mutex); + + if (c->node->updating) { + wait = 1; + } + + ngx_shmtx_unlock(&cache->shpool->mutex); + + if (wait) { + ngx_add_timer(ev, (timer > 500) ? 500 : timer); + return; + } + +wakeup: + + c->waiting = 0; + r->main->blocked--; + r->connection->write->handler(r->connection->write); +} + + +static ngx_int_t ngx_http_file_cache_read(ngx_http_request_t *r, ngx_http_cache_t *c) { time_t now; @@ -518,13 +635,19 @@ ngx_shmtx_lock(&cache->shpool->mutex); - fcn = ngx_http_file_cache_lookup(cache, c->key); + fcn = c->node; + if (fcn == NULL) { + fcn = ngx_http_file_cache_lookup(cache, c->key); + } + if (fcn) { ngx_queue_remove(&fcn->queue); - fcn->uses++; - fcn->count++; + if (c->node == NULL) { + fcn->uses++; + fcn->count++; + } if (fcn->error) { @@ -621,6 +744,10 @@ c = r->cache; + if (c->file.name.len) { + return NGX_OK; + } + c->file.name.len = path->name.len + 1 + path->len + 2 * NGX_HTTP_CACHE_KEY_LEN; @@ -957,6 +1084,10 @@ } } } + + if (c->wait_event.timer_set) { + ngx_del_timer(&c->wait_event); + } } Modified: trunk/src/http/ngx_http_upstream.c =================================================================== --- trunk/src/http/ngx_http_upstream.c 2011-12-26 10:51:24 UTC (rev 4385) +++ trunk/src/http/ngx_http_upstream.c 2011-12-26 11:15:23 UTC (rev 4386) @@ -707,6 +707,9 @@ c->body_start = u->conf->buffer_size; c->file_cache = u->conf->cache->data; + c->lock = u->conf->cache_lock; + c->lock_timeout = u->conf->cache_lock_timeout; + u->cache_status = NGX_HTTP_CACHE_MISS; } Modified: trunk/src/http/ngx_http_upstream.h =================================================================== --- trunk/src/http/ngx_http_upstream.h 2011-12-26 10:51:24 UTC (rev 4385) +++ trunk/src/http/ngx_http_upstream.h 2011-12-26 11:15:23 UTC (rev 4386) @@ -165,6 +165,9 @@ ngx_uint_t cache_use_stale; ngx_uint_t cache_methods; + ngx_flag_t cache_lock; + ngx_msec_t cache_lock_timeout; + ngx_array_t *cache_valid; ngx_array_t *cache_bypass; ngx_array_t *no_cache; From mdounin at mdounin.ru Mon Dec 26 11:16:20 2011 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Mon, 26 Dec 2011 11:16:20 +0000 Subject: [nginx] svn commit: r4387 - trunk/src/http/modules Message-ID: <20111226111620.D6FB83F9CB1@mail.nginx.com> Author: mdounin Date: 2011-12-26 11:16:19 +0000 (Mon, 26 Dec 2011) New Revision: 4387 Log: Cache lock support for fastcgi, scgi, uwsgi. Modified: trunk/src/http/modules/ngx_http_fastcgi_module.c trunk/src/http/modules/ngx_http_scgi_module.c trunk/src/http/modules/ngx_http_uwsgi_module.c Modified: trunk/src/http/modules/ngx_http_fastcgi_module.c =================================================================== --- trunk/src/http/modules/ngx_http_fastcgi_module.c 2011-12-26 11:15:23 UTC (rev 4386) +++ trunk/src/http/modules/ngx_http_fastcgi_module.c 2011-12-26 11:16:19 UTC (rev 4387) @@ -380,6 +380,20 @@ offsetof(ngx_http_fastcgi_loc_conf_t, upstream.cache_methods), &ngx_http_upstream_cache_method_mask }, + { ngx_string("fastcgi_cache_lock"), + 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_fastcgi_loc_conf_t, upstream.cache_lock), + NULL }, + + { ngx_string("fastcgi_cache_lock_timeout"), + NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, + ngx_conf_set_msec_slot, + NGX_HTTP_LOC_CONF_OFFSET, + offsetof(ngx_http_fastcgi_loc_conf_t, upstream.cache_lock_timeout), + NULL }, + #endif { ngx_string("fastcgi_temp_path"), @@ -2086,6 +2100,8 @@ conf->upstream.cache_bypass = NGX_CONF_UNSET_PTR; conf->upstream.no_cache = NGX_CONF_UNSET_PTR; conf->upstream.cache_valid = NGX_CONF_UNSET_PTR; + conf->upstream.cache_lock = NGX_CONF_UNSET; + conf->upstream.cache_lock_timeout = NGX_CONF_UNSET_MSEC; #endif conf->upstream.hide_headers = NGX_CONF_UNSET_PTR; @@ -2323,6 +2339,12 @@ conf->cache_key = prev->cache_key; } + ngx_conf_merge_value(conf->upstream.cache_lock, + prev->upstream.cache_lock, 0); + + ngx_conf_merge_msec_value(conf->upstream.cache_lock_timeout, + prev->upstream.cache_lock_timeout, 5000); + #endif ngx_conf_merge_value(conf->upstream.pass_request_headers, Modified: trunk/src/http/modules/ngx_http_scgi_module.c =================================================================== --- trunk/src/http/modules/ngx_http_scgi_module.c 2011-12-26 11:15:23 UTC (rev 4386) +++ trunk/src/http/modules/ngx_http_scgi_module.c 2011-12-26 11:16:19 UTC (rev 4387) @@ -246,6 +246,20 @@ offsetof(ngx_http_scgi_loc_conf_t, upstream.cache_methods), &ngx_http_upstream_cache_method_mask }, + { ngx_string("scgi_cache_lock"), + 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_scgi_loc_conf_t, upstream.cache_lock), + NULL }, + + { ngx_string("scgi_cache_lock_timeout"), + NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, + ngx_conf_set_msec_slot, + NGX_HTTP_LOC_CONF_OFFSET, + offsetof(ngx_http_scgi_loc_conf_t, upstream.cache_lock_timeout), + NULL }, + #endif { ngx_string("scgi_temp_path"), @@ -1062,6 +1076,8 @@ conf->upstream.cache_bypass = NGX_CONF_UNSET_PTR; conf->upstream.no_cache = NGX_CONF_UNSET_PTR; conf->upstream.cache_valid = NGX_CONF_UNSET_PTR; + conf->upstream.cache_lock = NGX_CONF_UNSET; + conf->upstream.cache_lock_timeout = NGX_CONF_UNSET_MSEC; #endif conf->upstream.hide_headers = NGX_CONF_UNSET_PTR; @@ -1289,6 +1305,12 @@ conf->cache_key = prev->cache_key; } + ngx_conf_merge_value(conf->upstream.cache_lock, + prev->upstream.cache_lock, 0); + + ngx_conf_merge_msec_value(conf->upstream.cache_lock_timeout, + prev->upstream.cache_lock_timeout, 5000); + #endif ngx_conf_merge_value(conf->upstream.pass_request_headers, Modified: trunk/src/http/modules/ngx_http_uwsgi_module.c =================================================================== --- trunk/src/http/modules/ngx_http_uwsgi_module.c 2011-12-26 11:15:23 UTC (rev 4386) +++ trunk/src/http/modules/ngx_http_uwsgi_module.c 2011-12-26 11:16:19 UTC (rev 4387) @@ -274,6 +274,20 @@ offsetof(ngx_http_uwsgi_loc_conf_t, upstream.cache_methods), &ngx_http_upstream_cache_method_mask }, + { ngx_string("uwsgi_cache_lock"), + 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_uwsgi_loc_conf_t, upstream.cache_lock), + NULL }, + + { ngx_string("uwsgi_cache_lock_timeout"), + NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, + ngx_conf_set_msec_slot, + NGX_HTTP_LOC_CONF_OFFSET, + offsetof(ngx_http_uwsgi_loc_conf_t, upstream.cache_lock_timeout), + NULL }, + #endif { ngx_string("uwsgi_temp_path"), @@ -1114,6 +1128,8 @@ conf->upstream.cache_bypass = NGX_CONF_UNSET_PTR; conf->upstream.no_cache = NGX_CONF_UNSET_PTR; conf->upstream.cache_valid = NGX_CONF_UNSET_PTR; + conf->upstream.cache_lock = NGX_CONF_UNSET; + conf->upstream.cache_lock_timeout = NGX_CONF_UNSET_MSEC; #endif conf->upstream.hide_headers = NGX_CONF_UNSET_PTR; @@ -1341,6 +1357,12 @@ conf->cache_key = prev->cache_key; } + ngx_conf_merge_value(conf->upstream.cache_lock, + prev->upstream.cache_lock, 0); + + ngx_conf_merge_msec_value(conf->upstream.cache_lock_timeout, + prev->upstream.cache_lock_timeout, 5000); + #endif ngx_conf_merge_value(conf->upstream.pass_request_headers, From mdounin at mdounin.ru Mon Dec 26 11:33:11 2011 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Mon, 26 Dec 2011 11:33:11 +0000 Subject: [nginx] svn commit: r4388 - trunk/src/http Message-ID: <20111226113311.D72C63F9C1F@mail.nginx.com> Author: mdounin Date: 2011-12-26 11:33:11 +0000 (Mon, 26 Dec 2011) New Revision: 4388 Log: Fixed build without debug. Modified: trunk/src/http/ngx_http_file_cache.c Modified: trunk/src/http/ngx_http_file_cache.c =================================================================== --- trunk/src/http/ngx_http_file_cache.c 2011-12-26 11:16:19 UTC (rev 4387) +++ trunk/src/http/ngx_http_file_cache.c 2011-12-26 11:33:11 UTC (rev 4388) @@ -395,7 +395,7 @@ ngx_shmtx_unlock(&cache->shpool->mutex); - ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, + ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "http file cache lock u:%d wt:%M", c->updating, c->wait_time); @@ -437,7 +437,7 @@ r = ev->data; c = r->cache; - ngx_log_debug0(NGX_LOG_DEBUG_HTTP, ev->log, 0, + ngx_log_debug2(NGX_LOG_DEBUG_HTTP, ev->log, 0, "http file cache wait handler wt:%M cur:%M", c->wait_time, ngx_current_msec); From vbart at nginx.com Mon Dec 26 13:10:36 2011 From: vbart at nginx.com (vbart at nginx.com) Date: Mon, 26 Dec 2011 13:10:36 +0000 Subject: [nginx] svn commit: r4389 - in trunk: auto auto/lib/pcre src/core Message-ID: <20111226131036.BEAD43F9C78@mail.nginx.com> Author: vbart Date: 2011-12-26 13:10:36 +0000 (Mon, 26 Dec 2011) New Revision: 4389 Log: Added support for regex study and PCRE JIT (ticket #41) optimizations on configuration phase. Modified: trunk/auto/lib/pcre/conf trunk/auto/lib/pcre/make trunk/auto/modules trunk/auto/options trunk/auto/sources trunk/src/core/ngx_regex.c trunk/src/core/ngx_regex.h Modified: trunk/auto/lib/pcre/conf =================================================================== --- trunk/auto/lib/pcre/conf 2011-12-26 11:33:11 UTC (rev 4388) +++ trunk/auto/lib/pcre/conf 2011-12-26 13:10:36 UTC (rev 4389) @@ -4,8 +4,6 @@ if [ $PCRE != NONE ]; then CORE_INCS="$CORE_INCS $PCRE" - CORE_DEPS="$CORE_DEPS $REGEX_DEPS" - CORE_SRCS="$CORE_SRCS $REGEX_SRCS" case "$NGX_CC_NAME" in @@ -81,6 +79,12 @@ esac + + if [ $PCRE_JIT = YES ]; then + have=NGX_HAVE_PCRE_JIT . auto/have + PCRE_CONF_OPT="$PCRE_CONF_OPT --enable-jit" + fi + else if [ "$NGX_PLATFORM" != win32 ]; then @@ -156,12 +160,23 @@ fi if [ $ngx_found = yes ]; then - CORE_DEPS="$CORE_DEPS $REGEX_DEPS" - CORE_SRCS="$CORE_SRCS $REGEX_SRCS" CORE_INCS="$CORE_INCS $ngx_feature_path" CORE_LIBS="$CORE_LIBS $ngx_feature_libs" PCRE=YES fi + + if [ $PCRE == YES ]; then + ngx_feature="PCRE JIT support" + ngx_feature_name="NGX_HAVE_PCRE_JIT" + ngx_feature_test="int jit = 0; + pcre_config(PCRE_CONFIG_JIT, &jit); + if (jit != 1) return 1;" + . auto/feature + + if [ $ngx_found = yes ]; then + PCRE_JIT=YES + fi + fi fi if [ $PCRE != YES ]; then Modified: trunk/auto/lib/pcre/make =================================================================== --- trunk/auto/lib/pcre/make 2011-12-26 11:33:11 UTC (rev 4388) +++ trunk/auto/lib/pcre/make 2011-12-26 13:10:36 UTC (rev 4389) @@ -50,7 +50,7 @@ cd $PCRE \\ && if [ -f Makefile ]; then \$(MAKE) distclean; fi \\ && CC="\$(CC)" CFLAGS="$PCRE_OPT" \\ - ./configure --disable-shared + ./configure --disable-shared $PCRE_CONF_OPT $PCRE/.libs/libpcre.a: $PCRE/Makefile cd $PCRE \\ Modified: trunk/auto/modules =================================================================== --- trunk/auto/modules 2011-12-26 11:33:11 UTC (rev 4388) +++ trunk/auto/modules 2011-12-26 13:10:36 UTC (rev 4389) @@ -396,6 +396,12 @@ CORE_SRCS="$CORE_SRCS $OPENSSL_SRCS" fi +if [ $USE_PCRE = YES ]; then + modules="$modules $REGEX_MODULE" + CORE_DEPS="$CORE_DEPS $REGEX_DEPS" + CORE_SRCS="$CORE_SRCS $REGEX_SRCS" +fi + if [ $HTTP = YES ]; then modules="$modules $HTTP_MODULES $HTTP_FILTER_MODULES \ $HTTP_HEADERS_FILTER_MODULE \ Modified: trunk/auto/options =================================================================== --- trunk/auto/options 2011-12-26 11:33:11 UTC (rev 4388) +++ trunk/auto/options 2011-12-26 13:10:36 UTC (rev 4389) @@ -111,6 +111,8 @@ USE_PCRE=NO PCRE=NONE PCRE_OPT= +PCRE_CONF_OPT= +PCRE_JIT=NO USE_OPENSSL=NO OPENSSL=NONE @@ -274,6 +276,7 @@ --with-pcre) USE_PCRE=YES ;; --with-pcre=*) PCRE="$value" ;; --with-pcre-opt=*) PCRE_OPT="$value" ;; + --with-pcre-jit) PCRE_JIT=YES ;; --with-openssl=*) OPENSSL="$value" ;; --with-openssl-opt=*) OPENSSL_OPT="$value" ;; @@ -421,6 +424,7 @@ --with-pcre force PCRE library usage --with-pcre=DIR set path to PCRE library sources --with-pcre-opt=OPTIONS set additional build options for PCRE + --with-pcre-jit build PCRE with JIT compilation support --with-md5=DIR set path to md5 library sources --with-md5-opt=OPTIONS set additional build options for md5 Modified: trunk/auto/sources =================================================================== --- trunk/auto/sources 2011-12-26 11:33:11 UTC (rev 4388) +++ trunk/auto/sources 2011-12-26 13:10:36 UTC (rev 4389) @@ -69,6 +69,7 @@ src/core/ngx_crypt.c" +REGEX_MODULE=ngx_regex_module REGEX_DEPS=src/core/ngx_regex.h REGEX_SRCS=src/core/ngx_regex.c Modified: trunk/src/core/ngx_regex.c =================================================================== --- trunk/src/core/ngx_regex.c 2011-12-26 11:33:11 UTC (rev 4388) +++ trunk/src/core/ngx_regex.c 2011-12-26 13:10:36 UTC (rev 4389) @@ -8,11 +8,61 @@ #include +typedef struct { + ngx_flag_t pcre_jit; +} ngx_regex_conf_t; + + static void * ngx_libc_cdecl ngx_regex_malloc(size_t size); static void ngx_libc_cdecl ngx_regex_free(void *p); +static ngx_int_t ngx_regex_module_init(ngx_cycle_t *cycle); +static void *ngx_regex_create_conf(ngx_cycle_t *cycle); +static char *ngx_regex_init_conf(ngx_cycle_t *cycle, void *conf); + +static char *ngx_regex_pcre_jit(ngx_conf_t *cf, void *post, void *data); +static ngx_conf_post_t ngx_regex_pcre_jit_post = { ngx_regex_pcre_jit }; + + +static ngx_command_t ngx_regex_commands[] = { + + { ngx_string("pcre_jit"), + NGX_MAIN_CONF|NGX_DIRECT_CONF|NGX_CONF_TAKE1, + ngx_conf_set_flag_slot, + 0, + offsetof(ngx_regex_conf_t, pcre_jit), + &ngx_regex_pcre_jit_post }, + + ngx_null_command +}; + + +static ngx_core_module_t ngx_regex_module_ctx = { + ngx_string("regex"), + ngx_regex_create_conf, + ngx_regex_init_conf +}; + + +ngx_module_t ngx_regex_module = { + NGX_MODULE_V1, + &ngx_regex_module_ctx, /* module context */ + ngx_regex_commands, /* module directives */ + NGX_CORE_MODULE, /* module type */ + NULL, /* init master */ + ngx_regex_module_init, /* init module */ + NULL, /* init process */ + NULL, /* init thread */ + NULL, /* exit thread */ + NULL, /* exit process */ + NULL, /* exit master */ + NGX_MODULE_V1_PADDING +}; + + static ngx_pool_t *ngx_pcre_pool; +static ngx_list_t *ngx_pcre_studies; void @@ -62,10 +112,11 @@ ngx_int_t ngx_regex_compile(ngx_regex_compile_t *rc) { - int n, erroff; - char *p; - const char *errstr; - ngx_regex_t *re; + int n, erroff; + char *p; + pcre *re; + const char *errstr; + ngx_regex_elt_t *elt; ngx_regex_malloc_init(rc->pool); @@ -92,8 +143,25 @@ return NGX_ERROR; } - rc->regex = re; + rc->regex = ngx_pcalloc(rc->pool, sizeof(ngx_regex_t)); + if (rc->regex == NULL) { + return NGX_ERROR; + } + rc->regex->pcre = re; + + /* do not study at runtime */ + + if (ngx_pcre_studies != NULL) { + elt = ngx_list_push(ngx_pcre_studies); + if (elt == NULL) { + return NGX_ERROR; + } + + elt->regex = rc->regex; + elt->name = rc->pattern.data; + } + n = pcre_fullinfo(re, NULL, PCRE_INFO_CAPTURECOUNT, &rc->captures); if (n < 0) { p = "pcre_fullinfo(\"%V\", PCRE_INFO_CAPTURECOUNT) failed: %d"; @@ -203,3 +271,140 @@ { return; } + + +static ngx_int_t +ngx_regex_module_init(ngx_cycle_t *cycle) +{ + int opt; + const char *errstr; + ngx_uint_t i; + ngx_list_part_t *part; + ngx_regex_elt_t *elts; + + opt = 0; + +#if (NGX_HAVE_PCRE_JIT) + { + ngx_regex_conf_t *rcf; + + rcf = (ngx_regex_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_regex_module); + + if (rcf->pcre_jit) { + opt = PCRE_STUDY_JIT_COMPILE; + } + } +#endif + + ngx_regex_malloc_init(cycle->pool); + + part = &ngx_pcre_studies->part; + elts = part->elts; + + for (i = 0 ; /* void */ ; i++) { + + if (i >= part->nelts) { + if (part->next == NULL) { + break; + } + + part = part->next; + elts = part->elts; + i = 0; + } + + elts[i].regex->extra = pcre_study(elts[i].regex->pcre, opt, &errstr); + + if (errstr != NULL) { + ngx_log_error(NGX_LOG_ALERT, cycle->log, 0, + "pcre_study() failed: %s in \"%s\"", + errstr, elts[i].name); + } + +#if (NGX_HAVE_PCRE_JIT) + if (opt & PCRE_STUDY_JIT_COMPILE) { + int jit, n; + + jit = 0; + n = pcre_fullinfo(elts[i].regex->pcre, elts[i].regex->extra, + PCRE_INFO_JIT, &jit); + + if (n != 0 || jit != 1) { + ngx_log_error(NGX_LOG_INFO, cycle->log, 0, + "JIT compiler does not support pattern: \"%s\"", + elts[i].name); + } + } +#endif + } + + ngx_regex_malloc_done(); + + ngx_pcre_studies = NULL; + + return NGX_OK; +} + + +static void * +ngx_regex_create_conf(ngx_cycle_t *cycle) +{ + ngx_regex_conf_t *rcf; + + rcf = ngx_pcalloc(cycle->pool, sizeof(ngx_regex_conf_t)); + if (rcf == NULL) { + return NULL; + } + + rcf->pcre_jit = NGX_CONF_UNSET; + + ngx_pcre_studies = ngx_list_create(cycle->pool, 8, sizeof(ngx_regex_elt_t)); + if (ngx_pcre_studies == NULL) { + return NULL; + } + + return rcf; +} + + +static char * +ngx_regex_init_conf(ngx_cycle_t *cycle, void *conf) +{ + ngx_regex_conf_t *rcf = conf; + + ngx_conf_init_value(rcf->pcre_jit, 0); + + return NGX_CONF_OK; +} + + +static char * +ngx_regex_pcre_jit(ngx_conf_t *cf, void *post, void *data) +{ + ngx_flag_t *fp = data; + + if (*fp == 0) { + return NGX_CONF_OK; + } + +#if (NGX_HAVE_PCRE_JIT) + { + int jit, r; + + jit = 0; + r = pcre_config(PCRE_CONFIG_JIT, &jit); + + if (r != 0 || jit != 1) { + ngx_conf_log_error(NGX_LOG_WARN, cf, 0, + "PCRE library does not support JIT"); + *fp = 0; + } + } +#else + ngx_conf_log_error(NGX_LOG_WARN, cf, 0, + "nginx was build without PCRE JIT support"); + *fp = 0; +#endif + + return NGX_CONF_OK; +} Modified: trunk/src/core/ngx_regex.h =================================================================== --- trunk/src/core/ngx_regex.h 2011-12-26 11:33:11 UTC (rev 4388) +++ trunk/src/core/ngx_regex.h 2011-12-26 13:10:36 UTC (rev 4389) @@ -18,9 +18,13 @@ #define NGX_REGEX_CASELESS PCRE_CASELESS -typedef pcre ngx_regex_t; +typedef struct { + pcre *pcre; + pcre_extra *extra; +} ngx_regex_t; + typedef struct { ngx_str_t pattern; ngx_pool_t *pool; @@ -45,7 +49,7 @@ ngx_int_t ngx_regex_compile(ngx_regex_compile_t *rc); #define ngx_regex_exec(re, s, captures, size) \ - pcre_exec(re, NULL, (const char *) (s)->data, (s)->len, 0, 0, \ + pcre_exec(re->pcre, re->extra, (const char *) (s)->data, (s)->len, 0, 0, \ captures, size) #define ngx_regex_exec_n "pcre_exec()" From mdounin at mdounin.ru Mon Dec 26 15:05:17 2011 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Mon, 26 Dec 2011 15:05:17 +0000 Subject: [nginx] svn commit: r4390 - trunk/docs/xml/nginx Message-ID: <20111226150517.6FA293F9C1F@mail.nginx.com> Author: mdounin Date: 2011-12-26 15:05:17 +0000 (Mon, 26 Dec 2011) New Revision: 4390 Log: nginx-1.1.12-RELEASE Modified: trunk/docs/xml/nginx/changes.xml Modified: trunk/docs/xml/nginx/changes.xml =================================================================== --- trunk/docs/xml/nginx/changes.xml 2011-12-26 13:10:36 UTC (rev 4389) +++ trunk/docs/xml/nginx/changes.xml 2011-12-26 15:05:17 UTC (rev 4390) @@ -9,6 +9,146 @@ nginx changelog + + + + +????? ??????????????? ??????? ? ??????? ????????? error_page +????????? proxy_pass ??? URI ?????? ?????????? ?????????? URI;
+??????? Lanshun Zhou. +
+ +a "proxy_pass" directive without URI part now uses changed URI +after redirection with the "error_page" directive;
+Thanks to Lanshun Zhou. +
+
+ + + +????????? proxy/fastcgi/scgi/uwsgi_cache_lock, +proxy/fastcgi/scgi/uwsgi_cache_lock_timeout. + + +the "proxy/fastcgi/scgi/uwsgi_cache_lock", +"proxy/fastcgi/scgi/uwsgi_cache_lock_timeout" directives. + + + + + +????????? pcre_jit. + + +the "pcre_jit" directive. + + + + + +SSI ??????? if ???????????? ????????? ? ?????????? ??????????. + + +the "if" SSI command supports captures in regular expressions. + + + + + +SSI ??????? if ?? ???????? ?????? ??????? block. + + +the "if" SSI command did not work inside the "block" command. + + + + + +????????? limit_conn_log_level ? limit_req_log_level ????? ?? ????????. + + +the "limit_conn_log_level" and "limit_req_log_level" directives might not work. + + + + + +????????? limit_rate ?? ????????? ?????????? ?? ?????? ????????, +???? ???? ??? ?????? ????? ??????? ?????. + + +the "limit_rate" directive did not allow to use full throughput, +even if limit value was very high. + + + + + +????????? sendfile_max_chunk ?? ????????, +???? ?????????????? ????????? limit_rate. + + +the "sendfile_max_chunk" directive did not work, +if the "limit_rate" directive was used. + + + + + +???? ? ????????? proxy_pass ?????????????? ?????????? ? ?? ??? ?????? URI, +?????? ????????????? URI ????????? ???????. + + +a "proxy_pass" directive without URI part always used original request URI +if variables were used. + + + + + +????? ??????????????? ??????? ? ??????? ????????? try_files +????????? proxy_pass ??? URI ????? ???????????? URI ????????? ???????;
+??????? Lanshun Zhou. +
+ +a "proxy_pass" directive without URI part might use original request +after redirection with the "try_files" directive;
+Thanks to Lanshun Zhou. +
+
+ + + +? ?????? ngx_http_scgi_module. + + +in the ngx_http_scgi_module. + + + + + +? ?????? ngx_http_mp4_module. + + +in the ngx_http_mp4_module. + + + + + +nginx ?? ????????? ?? Solaris; +?????? ????????? ? 1.1.9. + + +nginx could not be built on Solaris; +the bug had appeared in 1.1.9. + + + +
+ + From mdounin at mdounin.ru Mon Dec 26 15:05:38 2011 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Mon, 26 Dec 2011 15:05:38 +0000 Subject: [nginx] svn commit: r4391 - tags Message-ID: <20111226150538.C52653F9CF1@mail.nginx.com> Author: mdounin Date: 2011-12-26 15:05:38 +0000 (Mon, 26 Dec 2011) New Revision: 4391 Log: release-1.1.12 tag Added: tags/release-1.1.12/ From mdounin at mdounin.ru Tue Dec 27 11:56:49 2011 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Tue, 27 Dec 2011 11:56:49 +0000 Subject: [nginx] svn commit: r4392 - in trunk/src: core http/modules/perl Message-ID: <20111227115649.4F3C13F9C23@mail.nginx.com> Author: mdounin Date: 2011-12-27 11:56:48 +0000 (Tue, 27 Dec 2011) New Revision: 4392 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 2011-12-26 15:05:38 UTC (rev 4391) +++ trunk/src/core/nginx.h 2011-12-27 11:56:48 UTC (rev 4392) @@ -8,8 +8,8 @@ #define _NGINX_H_INCLUDED_ -#define nginx_version 1001011 -#define NGINX_VERSION "1.1.12" +#define nginx_version 1001013 +#define NGINX_VERSION "1.1.13" #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 2011-12-26 15:05:38 UTC (rev 4391) +++ trunk/src/http/modules/perl/nginx.pm 2011-12-27 11:56:48 UTC (rev 4392) @@ -48,7 +48,7 @@ HTTP_INSUFFICIENT_STORAGE ); -our $VERSION = '1.1.12'; +our $VERSION = '1.1.13'; require XSLoader; XSLoader::load('nginx', $VERSION); From sb at waeme.net Tue Dec 27 12:35:52 2011 From: sb at waeme.net (sb at waeme.net) Date: Tue, 27 Dec 2011 12:35:52 +0000 Subject: [nginx] svn commit: r4393 - trunk/misc Message-ID: <20111227123552.8A5853F9CAB@mail.nginx.com> Author: fabler Date: 2011-12-27 12:35:52 +0000 (Tue, 27 Dec 2011) New Revision: 4393 Log: zlib license file include fixed Modified: trunk/misc/GNUmakefile Modified: trunk/misc/GNUmakefile =================================================================== --- trunk/misc/GNUmakefile 2011-12-27 11:56:48 UTC (rev 4392) +++ trunk/misc/GNUmakefile 2011-12-27 12:35:52 UTC (rev 4393) @@ -111,7 +111,7 @@ cp -p $(OBJS)/lib/$(PCRE)/LICENCE \ $(TEMP)/$(NGINX)/docs/PCRE.LICENCE - perl -ne 'print if /^ \(C\) 1995-2004/ .. /^ jloup\@gzip.org/' \ + perl -ne 'print if /^ \(C\) 1995-20/ .. /^ jloup\@gzip.org/' \ $(OBJS)/lib/$(ZLIB)/README \ > $(TEMP)/$(NGINX)/docs/zlib.LICENSE From sb at waeme.net Tue Dec 27 12:39:12 2011 From: sb at waeme.net (sb at waeme.net) Date: Tue, 27 Dec 2011 12:39:12 +0000 Subject: [nginx] svn commit: r4394 - trunk/misc Message-ID: <20111227123912.4E03C3F9CC8@mail.nginx.com> Author: fabler Date: 2011-12-27 12:39:11 +0000 (Tue, 27 Dec 2011) New Revision: 4394 Log: libraries versions updated Modified: trunk/misc/GNUmakefile Modified: trunk/misc/GNUmakefile =================================================================== --- trunk/misc/GNUmakefile 2011-12-27 12:35:52 UTC (rev 4393) +++ trunk/misc/GNUmakefile 2011-12-27 12:39:11 UTC (rev 4394) @@ -6,9 +6,9 @@ REPO = $(shell svn info | sed -n 's/^Repository Root: //p') OBJS = objs.msvc8 -OPENSSL = openssl-1.0.0d -ZLIB = zlib-1.2.3 -PCRE = pcre-7.9 +OPENSSL = openssl-1.0.0e +ZLIB = zlib-1.2.5 +PCRE = pcre-8.12 release: From mdounin at mdounin.ru Wed Dec 28 13:30:57 2011 From: mdounin at mdounin.ru (mdounin at mdounin.ru) Date: Wed, 28 Dec 2011 13:30:57 +0000 Subject: [nginx] svn commit: r4395 - trunk/docs/xml/nginx Message-ID: <20111228133057.E4BC63F9C24@mail.nginx.com> Author: mdounin Date: 2011-12-28 13:30:56 +0000 (Wed, 28 Dec 2011) New Revision: 4395 Log: Fixed punctuation. Modified: trunk/docs/xml/nginx/changes.xml Modified: trunk/docs/xml/nginx/changes.xml =================================================================== --- trunk/docs/xml/nginx/changes.xml 2011-12-27 12:39:11 UTC (rev 4394) +++ trunk/docs/xml/nginx/changes.xml 2011-12-28 13:30:56 UTC (rev 4395) @@ -14,12 +14,12 @@ ????? ??????????????? ??????? ? ??????? ????????? error_page -????????? proxy_pass ??? URI ?????? ?????????? ?????????? URI;
+????????? proxy_pass ??? URI ?????? ?????????? ?????????? URI.
??????? Lanshun Zhou.
a "proxy_pass" directive without URI part now uses changed URI -after redirection with the "error_page" directive;
+after redirection with the "error_page" directive.
Thanks to Lanshun Zhou.
@@ -107,12 +107,12 @@ ????? ??????????????? ??????? ? ??????? ????????? try_files -????????? proxy_pass ??? URI ????? ???????????? URI ????????? ???????;
+????????? proxy_pass ??? URI ????? ???????????? URI ????????? ???????.
??????? Lanshun Zhou.
a "proxy_pass" directive without URI part might use original request -after redirection with the "try_files" directive;
+after redirection with the "try_files" directive.
Thanks to Lanshun Zhou.
From rdkehn at yahoo.com Wed Dec 28 15:46:05 2011 From: rdkehn at yahoo.com (Doug Kehn) Date: Wed, 28 Dec 2011 07:46:05 -0800 (PST) Subject: Cross Compiling Nginx Message-ID: <1325087165.87649.YahooMailNeo@web39301.mail.mud.yahoo.com> Hi All, I'm cross compiling Nginx for an ARM Cortex A8 processor.? Attached is a patch for review which allows Nginx to be cross compiled.? I believe the patch is generic enough to allow Nginx to be cross compiled in any cross compile environment.? I also don't believe that I've broken any existing functionality.? After applying the patch, Nginx can be cross compiled with: ./configure \--prefix= \ --crossbuild=Linux:$(ARCH) \ --with-cc-opt="$(CFLAGS)" \ --with-ld-opt="$(LDFLAGS)" \ --with-endian=$(ENDIAN) \ --with-int=4 \ --with-long=4 \ --with-long-long=8 \ --with-ptr-size=4 \ --with-sig-atomic-t=4 \ --with-size-t=4 \ --with-off-t=4 \ --with-time-t=4 \ --with-sys-nerr=132 make In my case $(ARCH) = arm, $(ENDIAN) = little, and $(CFLAGS)/$(LDFLAGS) are set according to my environment.? The variable sizes were determined empirically by cross compiling a simple program and executing on the target. Regards, ...doug -------------- next part -------------- A non-text attachment was scrubbed... Name: nginx-1.0.11.patch Type: application/octet-stream Size: 8962 bytes Desc: not available URL: From mdounin at mdounin.ru Wed Dec 28 17:40:25 2011 From: mdounin at mdounin.ru (Maxim Dounin) Date: Wed, 28 Dec 2011 21:40:25 +0400 Subject: Cross Compiling Nginx In-Reply-To: <1325087165.87649.YahooMailNeo@web39301.mail.mud.yahoo.com> References: <1325087165.87649.YahooMailNeo@web39301.mail.mud.yahoo.com> Message-ID: <20111228174025.GV67687@mdounin.ru> Hello! On Wed, Dec 28, 2011 at 07:46:05AM -0800, Doug Kehn wrote: > Hi All, > > I'm cross compiling Nginx for an ARM Cortex A8 processor.? > Attached is a patch for review which allows Nginx to be cross > compiled.? I believe the patch is generic enough to allow Nginx > to be cross compiled in any cross compile environment.? I also > don't believe that I've broken any existing functionality.? > After applying the patch, Nginx can be cross compiled with: > > ./configure \--prefix= \ > > --crossbuild=Linux:$(ARCH) \ > --with-cc-opt="$(CFLAGS)" \ > --with-ld-opt="$(LDFLAGS)" \ > --with-endian=$(ENDIAN) \ > --with-int=4 \ > --with-long=4 \ > --with-long-long=8 \ > --with-ptr-size=4 \ > --with-sig-atomic-t=4 \ > --with-size-t=4 \ > --with-off-t=4 \ > --with-time-t=4 \ > --with-sys-nerr=132 > make > > In my case $(ARCH) = arm, $(ENDIAN) = little, and > $(CFLAGS)/$(LDFLAGS) are set according to my environment.? The > variable sizes were determined empirically by cross compiling a > simple program and executing on the target. I would like to support cross-compilation of nginx, but I would like to see something more extensible, not configure arguments to specify anything. I.e. some configuration file and/or defaults for type sizes, ngx_feature_run=yes tests and so on. First step would probably be to audit ngx_feature_run=yes tests and remove "yes" in cases where it's not needed/can be handled at runtime. Maxim Dounin From maxim at nginx.com Thu Dec 29 15:36:08 2011 From: maxim at nginx.com (maxim at nginx.com) Date: Thu, 29 Dec 2011 15:36:08 +0000 Subject: [nginx] svn commit: r4396 - trunk/auto/cc Message-ID: <20111229153608.2AFC33F9C24@mail.nginx.com> Author: maxim Date: 2011-12-29 15:36:07 +0000 (Thu, 29 Dec 2011) New Revision: 4396 Log: Some questionable optomizations flags for icc were removed in order to simplify support of its future versions. Modified: trunk/auto/cc/icc Modified: trunk/auto/cc/icc =================================================================== --- trunk/auto/cc/icc 2011-12-28 13:30:56 UTC (rev 4395) +++ trunk/auto/cc/icc 2011-12-29 15:36:07 UTC (rev 4396) @@ -2,7 +2,7 @@ # Copyright (C) Igor Sysoev -# Intel C++ compiler 7.1, 8.0, 8.1, 9.0 +# Intel C++ compiler 7.1, 8.0, 8.1, 9.0, 11.1 NGX_ICC_VER=`$CC -V 2>&1 | grep 'Version' 2>&1 \ | sed -e 's/^.* Version \([^ ]*\) *Build.*$/\1/'` @@ -15,32 +15,7 @@ # optimizations CFLAGS="$CFLAGS -O" -# inline the functions declared with __inline -#CFLAGS="$CFLAGS -Ob1" -# inline any function, at the compiler's discretion -CFLAGS="$CFLAGS -Ob2" -# multi-file IP optimizations -case "$NGX_ICC_VER" in - 9.*) - IPO="-ipo" - ;; - - # 8.1.38 under FreeBSD can not link -ipo - 8.1) - IPO="-ip" - ;; - - *) - IPO="-ipo -ipo_obj" - ;; -esac - -# single-file IP optimizations -#IPO="-ip" - -CFLAGS="$CFLAGS $IPO" -CORE_LINK="$CORE_LINK $IPO" CORE_LINK="$CORE_LINK -opt_report_file=$NGX_OBJS/opt_report_file" @@ -64,15 +39,15 @@ CFLAGS="$CFLAGS $CPU_OPT" if [ ".$PCRE_OPT" = "." ]; then - PCRE_OPT="-O $IPO $CPU_OPT" + PCRE_OPT="-O $CPU_OPT" fi if [ ".$MD5_OPT" = "." ]; then - MD5_OPT="-O $IPO $CPU_OPT" + MD5_OPT="-O $CPU_OPT" fi if [ ".$ZLIB_OPT" = "." ]; then - ZLIB_OPT="-O $IPO $CPU_OPT" + ZLIB_OPT="-O $CPU_OPT" fi From vbart at nginx.com Thu Dec 29 15:58:54 2011 From: vbart at nginx.com (vbart at nginx.com) Date: Thu, 29 Dec 2011 15:58:54 +0000 Subject: [nginx] svn commit: r4397 - trunk/auto/lib/pcre Message-ID: Author: vbart Date: 2011-12-29 15:58:53 +0000 (Thu, 29 Dec 2011) New Revision: 4397 Modified: trunk/auto/lib/pcre/conf Log: Fixed configure with system PCRE library on Solaris. The bug has been introduced in r4389. Modified: trunk/auto/lib/pcre/conf =================================================================== --- trunk/auto/lib/pcre/conf 2011-12-29 15:36:07 UTC (rev 4396) +++ trunk/auto/lib/pcre/conf 2011-12-29 15:58:53 UTC (rev 4397) @@ -165,7 +165,7 @@ PCRE=YES fi - if [ $PCRE == YES ]; then + if [ $PCRE = YES ]; then ngx_feature="PCRE JIT support" ngx_feature_name="NGX_HAVE_PCRE_JIT" ngx_feature_test="int jit = 0;