changeset 440: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	Mon Jan 19 00:00:00 2009 +0300
+++ b/CHANGES	Mon Jan 26 00:00:00 2009 +0300
@@ -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	Mon Jan 19 00:00:00 2009 +0300
+++ b/CHANGES.ru	Mon Jan 26 00:00:00 2009 +0300
@@ -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	Mon Jan 19 00:00:00 2009 +0300
+++ b/src/core/nginx.h	Mon Jan 26 00:00:00 2009 +0300
@@ -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	Mon Jan 19 00:00:00 2009 +0300
+++ b/src/core/ngx_cycle.c	Mon Jan 26 00:00:00 2009 +0300
@@ -394,6 +394,10 @@
     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	Mon Jan 19 00:00:00 2009 +0300
+++ b/src/core/ngx_open_file_cache.c	Mon Jan 26 00:00:00 2009 +0300
@@ -457,7 +457,7 @@
             goto failed;
         }
 
-        if (of->is_dir) {
+        if (ngx_is_dir(&fi)) {
             goto done;
         }
     }
--- a/src/core/ngx_slab.c	Mon Jan 19 00:00:00 2009 +0300
+++ b/src/core/ngx_slab.c	Mon Jan 26 00:00:00 2009 +0300
@@ -661,11 +661,8 @@
             }
 
             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 @@
 
             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	Mon Jan 19 00:00:00 2009 +0300
+++ b/src/http/modules/ngx_http_fastcgi_module.c	Mon Jan 26 00:00:00 2009 +0300
@@ -135,8 +135,8 @@
     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_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_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 @@
 }
 
 
-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 @@
     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	Mon Jan 19 00:00:00 2009 +0300
+++ b/src/http/modules/ngx_http_geo_module.c	Mon Jan 26 00:00:00 2009 +0300
@@ -636,8 +636,8 @@
 
                 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	Mon Jan 19 00:00:00 2009 +0300
+++ b/src/http/modules/ngx_http_gzip_filter_module.c	Mon Jan 26 00:00:00 2009 +0300
@@ -302,18 +302,18 @@
     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	Mon Jan 19 00:00:00 2009 +0300
+++ b/src/http/modules/perl/nginx.pm	Mon Jan 26 00:00:00 2009 +0300
@@ -47,7 +47,7 @@
     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	Mon Jan 19 00:00:00 2009 +0300
+++ b/src/http/ngx_http_core_module.c	Mon Jan 26 00:00:00 2009 +0300
@@ -1038,6 +1038,7 @@
     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 @@
             }
         }
 
+        test_dir = tf->test_dir;
+
         tf++;
 
         ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
@@ -1172,7 +1175,7 @@
             continue;
         }
 
-        if (!of.is_file) {
+        if (of.is_dir && !test_dir) {
             continue;
         }
 
@@ -3853,6 +3856,11 @@
 
         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	Mon Jan 19 00:00:00 2009 +0300
+++ b/src/http/ngx_http_core_module.h	Mon Jan 26 00:00:00 2009 +0300
@@ -245,6 +245,7 @@
     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	Mon Jan 19 00:00:00 2009 +0300
+++ b/src/http/ngx_http_upstream.c	Mon Jan 26 00:00:00 2009 +0300
@@ -2217,7 +2217,7 @@
 
             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