From 825cda25d19afb6b8a9fa129f6200e1cce1bffee Mon Sep 17 00:00:00 2001 From: Igor Sysoev Date: Mon, 31 May 2010 00:00:00 +0400 Subject: [PATCH] nginx 0.8.39 *) Bugfix: an inherited "alias" directive worked incorrectly in inclusive location. *) Bugfix: in "alias" with variables and "try_files" directives combination. *) Bugfix: listen unix domain and IPv6 sockets did not inherit while online upgrade. Thanks to Maxim Dounin. --- CHANGES | 13 +++++++++++++ CHANGES.ru | 14 +++++++++++++- src/core/nginx.h | 4 ++-- src/core/ngx_connection.c | 6 ++---- src/core/ngx_times.c | 2 -- src/http/modules/perl/nginx.pm | 2 +- src/http/ngx_http_core_module.c | 38 ++++++++++++++++++++++++++------------ src/http/ngx_http_core_module.h | 3 ++- src/http/ngx_http_request.h | 1 + 9 files changed, 60 insertions(+), 23 deletions(-) diff --git a/CHANGES b/CHANGES index b017eed..d0c74e7 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,17 @@ +Changes with nginx 0.8.39 31 May 2010 + + *) Bugfix: an inherited "alias" directive worked incorrectly in + inclusive location. + + *) Bugfix: in "alias" with variables and "try_files" directives + combination. + + *) Bugfix: listen unix domain and IPv6 sockets did not inherit while + online upgrade. + Thanks to Maxim Dounin. + + Changes with nginx 0.8.38 24 May 2010 *) Feature: the "proxy_no_cache" and "fastcgi_no_cache" directives. diff --git a/CHANGES.ru b/CHANGES.ru index ba47d73..aef4eb0 100644 --- a/CHANGES.ru +++ b/CHANGES.ru @@ -1,4 +1,16 @@ +éÚÍÅÎÅÎÉÑ × nginx 0.8.39 31.05.2010 + + *) éÓÐÒÁ×ÌÅÎÉÅ: ÎÁÓÌÅÄÕÅÍÁÑ ÄÉÒÅËÔÉ×Á alias ÎÅÐÒÁ×ÉÌØÎÏ ÒÁÂÏÔÁÌÁ ×Ï + ×ÌÏÖÅÎÎÏÍ location'Å. + + *) éÓÐÒÁ×ÌÅÎÉÅ: × ËÏÍÂÉÎÁÃÉÉ ÄÉÒÅËÔÉ× alias Ó ÐÅÒÅÍÅÎÎÙÍÉ É try_files; + + *) éÓÐÒÁ×ÌÅÎÉÅ: listen unix domain É IPv6 ÓÏËÅÔÙ ÎÅ ÎÁÓÌÅÄÏ×ÁÌÉÓØ ×Ï + ×ÒÅÍÑ ÏÂÎÏ×ÌÅÎÉÑ ÂÅÚ ÐÅÒÅÒÙ×Á. + óÐÁÓÉÂÏ íÁËÓÉÍÕ äÕÎÉÎÕ. + + éÚÍÅÎÅÎÉÑ × nginx 0.8.38 24.05.2010 *) äÏÂÁ×ÌÅÎÉÅ: ÄÉÒÅËÔÉ×Ù proxy_no_cache É fastcgi_no_cache. @@ -312,7 +324,7 @@ *) âÅÚÏÐÁÓÎÏÓÔØ: ÔÅÐÅÒØ SSL/TLS renegotiation ÚÁÐÒÅÝ£Î. óÐÁÓÉÂÏ íÁËÓÉÍÕ äÕÎÉÎÕ. - *) éÓÐÒÁ×ÌÅÎÉÅ: listen unix domain ÓÏËÅÔ ÎÅ ÎÁÓÌÅÄÏ×ÁÌÉÓØ ×Ï ×ÒÅÍÑ + *) éÓÐÒÁ×ÌÅÎÉÅ: listen unix domain ÓÏËÅÔ ÎÅ ÎÁÓÌÅÄÏ×ÁÌÓÑ ×Ï ×ÒÅÍÑ ÏÂÎÏ×ÌÅÎÉÑ ÂÅÚ ÐÅÒÅÒÙ×Á. *) éÓÐÒÁ×ÌÅÎÉÅ: ÐÁÒÁÍÅÔÒ "unix:" × ÄÉÒÅËÔÉ×Å set_real_ip_from ÎÅ diff --git a/src/core/nginx.h b/src/core/nginx.h index 784d554..5069f29 100644 --- a/src/core/nginx.h +++ b/src/core/nginx.h @@ -8,8 +8,8 @@ #define _NGINX_H_INCLUDED_ -#define nginx_version 8038 -#define NGINX_VERSION "0.8.38" +#define nginx_version 8039 +#define NGINX_VERSION "0.8.39" #define NGINX_VER "nginx/" NGINX_VERSION #define NGINX_VAR "NGINX" diff --git a/src/core/ngx_connection.c b/src/core/ngx_connection.c index 1f6a195..4a90b61 100644 --- a/src/core/ngx_connection.c +++ b/src/core/ngx_connection.c @@ -96,14 +96,12 @@ ngx_set_inherited_sockets(ngx_cycle_t *cycle) ls = cycle->listening.elts; for (i = 0; i < cycle->listening.nelts; i++) { - /* AF_INET only */ - - ls[i].sockaddr = ngx_palloc(cycle->pool, sizeof(struct sockaddr_in)); + ls[i].sockaddr = ngx_palloc(cycle->pool, NGX_SOCKADDRLEN); if (ls[i].sockaddr == NULL) { return NGX_ERROR; } - ls[i].socklen = sizeof(struct sockaddr_in); + ls[i].socklen = NGX_SOCKADDRLEN; if (getsockname(ls[i].fd, ls[i].sockaddr, &ls[i].socklen) == -1) { ngx_log_error(NGX_LOG_CRIT, cycle->log, ngx_socket_errno, "getsockname() of the inherited " diff --git a/src/core/ngx_times.c b/src/core/ngx_times.c index d9f5aa2..5050124 100644 --- a/src/core/ngx_times.c +++ b/src/core/ngx_times.c @@ -172,7 +172,6 @@ ngx_time_sigsafe_update(void) u_char *p; ngx_tm_t tm; time_t sec; - ngx_uint_t msec; ngx_time_t *tp; struct timeval tv; @@ -183,7 +182,6 @@ ngx_time_sigsafe_update(void) ngx_gettimeofday(&tv); sec = tv.tv_sec; - msec = tv.tv_usec / 1000; tp = &cached_time[slot]; diff --git a/src/http/modules/perl/nginx.pm b/src/http/modules/perl/nginx.pm index 3e173eb..460ecb7 100644 --- a/src/http/modules/perl/nginx.pm +++ b/src/http/modules/perl/nginx.pm @@ -47,7 +47,7 @@ our @EXPORT = qw( HTTP_INSUFFICIENT_STORAGE ); -our $VERSION = '0.8.38'; +our $VERSION = '0.8.39'; require XSLoader; XSLoader::load('nginx', $VERSION); diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c index 21ea7e9..af035cc 100644 --- a/src/http/ngx_http_core_module.c +++ b/src/http/ngx_http_core_module.c @@ -1152,7 +1152,7 @@ ngx_http_core_try_files_phase(ngx_http_request_t *r, tf = clcf->try_files; - alias = clcf->alias ? clcf->name.len : 0; + alias = clcf->alias; for ( ;; ) { @@ -1222,8 +1222,9 @@ ngx_http_core_try_files_phase(ngx_http_request_t *r, tf++; - ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, - "try to use file: \"%s\" \"%s\"", name, path.data); + ngx_log_debug3(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, + "try to use %s: \"%s\" \"%s\"", + test_dir ? "dir" : "file", name, path.data); if (tf->lengths == NULL && tf->name.len == 0) { @@ -1281,6 +1282,13 @@ ngx_http_core_try_files_phase(ngx_http_request_t *r, if (!alias) { r->uri = path; +#if (NGX_PCRE) + } else if (clcf->regex) { + if (!test_dir) { + r->uri = path; + r->add_uri_to_alias = 1; + } +#endif } else { r->uri.len = alias + path.len; r->uri.data = ngx_pnalloc(r->pool, r->uri.len); @@ -1748,7 +1756,7 @@ ngx_http_map_uri_to_path(ngx_http_request_t *r, ngx_str_t *path, clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); - alias = clcf->alias ? clcf->name.len : 0; + alias = clcf->alias; if (alias && !r->valid_location) { ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0, @@ -1776,7 +1784,9 @@ ngx_http_map_uri_to_path(ngx_http_request_t *r, ngx_str_t *path, ngx_uint_t captures; captures = alias && clcf->regex; - reserved += captures ? 1 : r->uri.len - alias + 1; + + reserved += captures ? r->add_uri_to_alias ? r->uri.len + 1 : 1 + : r->uri.len - alias + 1; #else reserved += r->uri.len - alias + 1; #endif @@ -1797,8 +1807,12 @@ ngx_http_map_uri_to_path(ngx_http_request_t *r, ngx_str_t *path, #if (NGX_PCRE) if (captures) { - *last = '\0'; - return last; + if (!r->add_uri_to_alias) { + *last = '\0'; + return last; + } + + alias = 0; } #endif } @@ -2206,6 +2220,7 @@ ngx_http_internal_redirect(ngx_http_request_t *r, #endif r->internal = 1; + r->add_uri_to_alias = 0; r->main->count++; ngx_http_handler(r); @@ -3589,16 +3604,15 @@ ngx_http_core_root(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) ngx_http_core_loc_conf_t *clcf = conf; ngx_str_t *value; - ngx_uint_t alias, n; + ngx_int_t alias; + ngx_uint_t n; ngx_http_script_compile_t sc; alias = (cmd->name.len == sizeof("alias") - 1) ? 1 : 0; if (clcf->root.data) { - /* the (ngx_uint_t) cast is required by gcc 2.7.2.3 */ - - if ((ngx_uint_t) clcf->alias == alias) { + if ((clcf->alias != 0) == alias) { ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "\"%V\" directive is duplicate", &cmd->name); @@ -3644,7 +3658,7 @@ ngx_http_core_root(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) return NGX_CONF_ERROR; } - clcf->alias = alias; + clcf->alias = alias ? clcf->name.len : 0; clcf->root = value[1]; if (!alias && clcf->root.data[clcf->root.len - 1] == '/') { diff --git a/src/http/ngx_http_core_module.h b/src/http/ngx_http_core_module.h index 631f399..01a2fbe 100644 --- a/src/http/ngx_http_core_module.h +++ b/src/http/ngx_http_core_module.h @@ -289,7 +289,6 @@ struct ngx_http_core_loc_conf_s { unsigned noregex:1; unsigned auto_redirect:1; - unsigned alias:1; #if (NGX_HTTP_GZIP) unsigned gzip_disable_msie6:2; #endif @@ -307,6 +306,8 @@ struct ngx_http_core_loc_conf_s { ngx_http_handler_pt handler; + /* location name length for inclusive location with inherited alias */ + size_t alias; ngx_str_t root; /* root, alias */ ngx_str_t post_action; diff --git a/src/http/ngx_http_request.h b/src/http/ngx_http_request.h index f962271..0559b46 100644 --- a/src/http/ngx_http_request.h +++ b/src/http/ngx_http_request.h @@ -437,6 +437,7 @@ struct ngx_http_request_s { unsigned invalid_header:1; + unsigned add_uri_to_alias:1; unsigned valid_location:1; unsigned valid_unparsed_uri:1; unsigned uri_changed:1; -- 2.11.4.GIT