changeset 449:6281966854a5 NGINX_0_7_32

nginx 0.7.32 *) Feature: now a directory existence testing can be set explicitly in the "try_files" directive. *) Bugfix: fastcgi_store stored files not always. *) Bugfix: in geo ranges. *) Bugfix: in shared memory allocations if nginx was built without debugging. Thanks to Andrey Kvasov.
author Igor Sysoev <http://sysoev.ru>
date Mon, 26 Jan 2009 00:00:00 +0300
parents 02687ee42c28
children 52bbf0e6dfad
files CHANGES CHANGES.ru src/core/nginx.h src/core/ngx_cycle.c src/core/ngx_open_file_cache.c src/core/ngx_slab.c src/http/modules/ngx_http_fastcgi_module.c src/http/modules/ngx_http_geo_module.c src/http/modules/ngx_http_gzip_filter_module.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_upstream.c
diffstat 13 files changed, 98 insertions(+), 38 deletions(-) [+]
line wrap: on
line diff
--- a/CHANGES
+++ b/CHANGES
@@ -1,4 +1,18 @@
 
+Changes with nginx 0.7.32                                        26 Jan 2009
+
+    *) Feature: now a directory existence testing can be set explicitly in 
+       the "try_files" directive.
+
+    *) Bugfix: fastcgi_store stored files not always.
+
+    *) Bugfix: in geo ranges.
+
+    *) Bugfix: in shared memory allocations if nginx was built without 
+       debugging.
+       Thanks to Andrey Kvasov.
+
+
 Changes with nginx 0.7.31                                        19 Jan 2009
 
     *) Change: now the "try_files" directive tests files only and ignores 
--- a/CHANGES.ru
+++ b/CHANGES.ru
@@ -1,4 +1,18 @@
 
+Изменения в nginx 0.7.32                                          26.01.2009
+
+    *) Добавление: теперь в директиве try_files можно явно указать проверку 
+       каталога.
+
+    *) Исправление: fastcgi_store не всегда сохранял файлы.
+
+    *) Исправление: в гео-диапазонах.
+
+    *) Исправление: ошибки выделения больших блоков в разделяемой памяти, 
+       если nginx был собран без отладки.
+       Спасибо Андрею Квасову.
+
+
 Изменения в nginx 0.7.31                                          19.01.2009
 
     *) Изменение: теперь директива try_files проверяет только файлы, 
--- a/src/core/nginx.h
+++ b/src/core/nginx.h
@@ -8,7 +8,7 @@
 #define _NGINX_H_INCLUDED_
 
 
-#define NGINX_VERSION      "0.7.31"
+#define NGINX_VERSION      "0.7.32"
 #define NGINX_VER          "nginx/" NGINX_VERSION
 
 #define NGINX_VAR          "NGINX"
--- a/src/core/ngx_cycle.c
+++ b/src/core/ngx_cycle.c
@@ -394,6 +394,10 @@ ngx_init_cycle(ngx_cycle_t *old_cycle)
     cycle->log = cycle->new_log;
     pool->log = cycle->new_log;
 
+    if (cycle->log->log_level == 0) {
+        cycle->log->log_level = NGX_LOG_ERR;
+    }
+
 
     /* create shared memory */
 
--- a/src/core/ngx_open_file_cache.c
+++ b/src/core/ngx_open_file_cache.c
@@ -457,7 +457,7 @@ ngx_open_and_stat_file(u_char *name, ngx
             goto failed;
         }
 
-        if (of->is_dir) {
+        if (ngx_is_dir(&fi)) {
             goto done;
         }
     }
--- a/src/core/ngx_slab.c
+++ b/src/core/ngx_slab.c
@@ -661,11 +661,8 @@ ngx_slab_alloc_pages(ngx_slab_pool_t *po
             }
 
             page->slab = pages | NGX_SLAB_PAGE_START;
-
-#if (NGX_DEBUG)
             page->next = NULL;
             page->prev = NGX_SLAB_PAGE;
-#endif
 
             if (--pages == 0) {
                 return page;
@@ -673,10 +670,8 @@ ngx_slab_alloc_pages(ngx_slab_pool_t *po
 
             for (p = page + 1; pages; pages--) {
                 p->slab = NGX_SLAB_PAGE_BUSY;
-#if (NGX_DEBUG)
                 p->next = NULL;
                 p->prev = NGX_SLAB_PAGE;
-#endif
                 p++;
             }
 
--- a/src/http/modules/ngx_http_fastcgi_module.c
+++ b/src/http/modules/ngx_http_fastcgi_module.c
@@ -135,8 +135,8 @@ static ngx_int_t ngx_http_fastcgi_script
     ngx_http_variable_value_t *v, uintptr_t data);
 static ngx_int_t ngx_http_fastcgi_path_info_variable(ngx_http_request_t *r,
     ngx_http_variable_value_t *v, uintptr_t data);
-static ngx_int_t ngx_http_fastcgi_split(ngx_http_request_t *r,
-    ngx_http_fastcgi_ctx_t *f, ngx_http_fastcgi_loc_conf_t *flcf);
+static ngx_http_fastcgi_ctx_t *ngx_http_fastcgi_split(ngx_http_request_t *r,
+    ngx_http_fastcgi_loc_conf_t *flcf);
 
 static char *ngx_http_fastcgi_pass(ngx_conf_t *cf, ngx_command_t *cmd,
     void *conf);
@@ -2111,10 +2111,11 @@ ngx_http_fastcgi_script_name_variable(ng
     ngx_http_fastcgi_ctx_t       *f;
     ngx_http_fastcgi_loc_conf_t  *flcf;
 
-    f = ngx_http_get_module_ctx(r, ngx_http_fastcgi_module);
     flcf = ngx_http_get_module_loc_conf(r, ngx_http_fastcgi_module);
 
-    if (ngx_http_fastcgi_split(r, f, flcf) != NGX_OK) {
+    f = ngx_http_fastcgi_split(r, flcf);
+
+    if (f == NULL) {
         return NGX_ERROR;
     }
 
@@ -2151,10 +2152,11 @@ ngx_http_fastcgi_path_info_variable(ngx_
     ngx_http_fastcgi_ctx_t       *f;
     ngx_http_fastcgi_loc_conf_t  *flcf;
 
-    f = ngx_http_get_module_ctx(r, ngx_http_fastcgi_module);
     flcf = ngx_http_get_module_loc_conf(r, ngx_http_fastcgi_module);
 
-    if (ngx_http_fastcgi_split(r, f, flcf) != NGX_OK) {
+    f = ngx_http_fastcgi_split(r, flcf);
+
+    if (f == NULL) {
         return NGX_ERROR;
     }
 
@@ -2168,35 +2170,46 @@ ngx_http_fastcgi_path_info_variable(ngx_
 }
 
 
-static ngx_int_t
-ngx_http_fastcgi_split(ngx_http_request_t *r, ngx_http_fastcgi_ctx_t *f,
-    ngx_http_fastcgi_loc_conf_t *flcf)
+static ngx_http_fastcgi_ctx_t *
+ngx_http_fastcgi_split(ngx_http_request_t *r, ngx_http_fastcgi_loc_conf_t *flcf)
 {
+    ngx_http_fastcgi_ctx_t       *f;
 #if (NGX_PCRE)
-    ngx_int_t  n;
-    int        captures[(1 + 2) * 3];
+    ngx_int_t                     n;
+    int                           captures[(1 + 2) * 3];
+
+    f = ngx_http_get_module_ctx(r, ngx_http_fastcgi_module);
+
+    if (f == NULL) {
+        f = ngx_pcalloc(r->pool, sizeof(ngx_http_fastcgi_ctx_t));
+        if (f == NULL) {
+            return NULL;
+        }
+
+        ngx_http_set_ctx(r, f, ngx_http_fastcgi_module);
+    }
 
     if (f->script_name.len) {
-        return NGX_OK;
+        return f;
     }
 
     if (flcf->split_regex == NULL) {
         f->script_name = r->uri;
-        return NGX_OK;
+        return f;
     }
 
     n = ngx_regex_exec(flcf->split_regex, &r->uri, captures, (1 + 2) * 3);
 
     if (n == NGX_REGEX_NO_MATCHED) {
         f->script_name = r->uri;
-        return NGX_OK;
+        return f;
     }
 
     if (n < 0) {
         ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0,
                       ngx_regex_exec_n " failed: %d on \"%V\" using \"%V\"",
                       n, &r->uri, &flcf->split_name);
-        return NGX_ERROR;
+        return NULL;
     }
 
     /* match */
@@ -2207,13 +2220,24 @@ ngx_http_fastcgi_split(ngx_http_request_
     f->path_info.len = captures[5] - captures[4];
     f->path_info.data = r->uri.data + f->script_name.len;
 
-    return NGX_OK;
+    return f;
 
 #else
 
+    f = ngx_http_get_module_ctx(r, ngx_http_fastcgi_module);
+
+    if (f == NULL) {
+        f = ngx_pcalloc(r->pool, sizeof(ngx_http_fastcgi_ctx_t));
+        if (f == NULL) {
+            return NULL;
+        }
+
+        ngx_http_set_ctx(r, f, ngx_http_fastcgi_module);
+    }
+
     f->script_name = r->uri;
 
-    return NGX_OK;
+    return f;
 
 #endif
 }
--- a/src/http/modules/ngx_http_geo_module.c
+++ b/src/http/modules/ngx_http_geo_module.c
@@ -636,8 +636,8 @@ ngx_http_geo_add_range(ngx_conf_t *cf, n
 
                 range = a->elts;
 
-                ngx_memcpy(&range[i + 2], &range[i + 1],
-                           (a->nelts - 2 - i) * sizeof(ngx_http_geo_range_t));
+                ngx_memcpy(&range[i + 1], &range[i],
+                           (a->nelts - 1 - i) * sizeof(ngx_http_geo_range_t));
 
                 range[i + 1].start = (u_short) (e + 1);
 
--- a/src/http/modules/ngx_http_gzip_filter_module.c
+++ b/src/http/modules/ngx_http_gzip_filter_module.c
@@ -302,18 +302,18 @@ ngx_http_gzip_body_filter(ngx_http_reque
     if (ctx->buffering) {
 
         if (in) {
-	    switch (ngx_http_gzip_filter_copy_recycled(ctx, in)) {
+            switch (ngx_http_gzip_filter_copy_recycled(ctx, in)) {
 
-	    case NGX_OK:
-		return NGX_OK;
+            case NGX_OK:
+                return NGX_OK;
 
-	    case NGX_DONE:
-		in = NULL;
-		break;
+            case NGX_DONE:
+                in = NULL;
+                break;
 
-	    default:  /* NGX_ERROR */
-		goto failed;
-	    }
+            default:  /* NGX_ERROR */
+                goto failed;
+            }
 
         } else {
             ctx->buffering = 0;
--- 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.7.31';
+our $VERSION = '0.7.32';
 
 require XSLoader;
 XSLoader::load('nginx', $VERSION);
--- a/src/http/ngx_http_core_module.c
+++ b/src/http/ngx_http_core_module.c
@@ -1038,6 +1038,7 @@ ngx_http_core_try_files_phase(ngx_http_r
     ssize_t                       reserve, allocated;
     u_char                       *p, *name;
     ngx_str_t                     path;
+    ngx_uint_t                    test_dir;
     ngx_http_try_file_t          *tf;
     ngx_open_file_info_t          of;
     ngx_http_script_code_pt       code;
@@ -1133,6 +1134,8 @@ ngx_http_core_try_files_phase(ngx_http_r
             }
         }
 
+        test_dir = tf->test_dir;
+
         tf++;
 
         ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
@@ -1172,7 +1175,7 @@ ngx_http_core_try_files_phase(ngx_http_r
             continue;
         }
 
-        if (!of.is_file) {
+        if (of.is_dir && !test_dir) {
             continue;
         }
 
@@ -3853,6 +3856,11 @@ ngx_http_core_try_files(ngx_conf_t *cf, 
 
         tf[i].name = value[i + 1];
 
+        if (tf[i].name.data[tf[i].name.len - 1] == '/') {
+            tf[i].test_dir = 1;
+            tf[i].name.len--;
+        }
+
         n = ngx_http_script_variables_count(&tf[i].name);
 
         if (n) {
--- a/src/http/ngx_http_core_module.h
+++ b/src/http/ngx_http_core_module.h
@@ -245,6 +245,7 @@ typedef struct {
     ngx_array_t               *lengths;
     ngx_array_t               *values;
     ngx_str_t                  name;
+    ngx_uint_t                 test_dir;   /* unsigned  test_dir:1; */
 } ngx_http_try_file_t;
 
 
--- a/src/http/ngx_http_upstream.c
+++ b/src/http/ngx_http_upstream.c
@@ -2217,7 +2217,7 @@ ngx_http_upstream_process_request(ngx_ht
 
             tf = u->pipe->temp_file;
 
-            if (p->upstream_eof) {
+            if (p->upstream_eof || p->upstream_done) {
 
                 if (u->headers_in.status_n == NGX_HTTP_OK
                     && (u->headers_in.content_length_n == -1