changeset 617:7858d4f8dec4 NGINX_0_8_39

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.
author Igor Sysoev <http://sysoev.ru>
date Mon, 31 May 2010 00:00:00 +0400
parents 7cbc7affef15
children 6ad548c0b830
files CHANGES CHANGES.ru src/core/nginx.h src/core/ngx_connection.c src/core/ngx_times.c src/http/modules/perl/nginx.pm src/http/ngx_http_core_module.c src/http/ngx_http_core_module.h src/http/ngx_http_request.h
diffstat 9 files changed, 60 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- 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.
--- 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 не 
--- 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"
--- a/src/core/ngx_connection.c
+++ b/src/core/ngx_connection.c
@@ -96,14 +96,12 @@ ngx_set_inherited_sockets(ngx_cycle_t *c
     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 "
--- 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];
 
--- 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);
--- 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_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_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_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_reques
 
     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_reques
         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_reques
 
 #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_requ
 #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_c
     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_c
         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] == '/') {
--- 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;
 
--- 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;