changeset 535:80f7156c2965 NGINX_0_8_14

nginx 0.8.14 *) Bugfix: an expired cached response might stick in the "UPDATING" state. *) Bugfix: a segmentation fault might occur in worker process, if error_log was set to info or debug level. Thanks to Sergey Bochenkov. *) Bugfix: in embedded perl module; the bug had appeared in 0.8.11. *) Bugfix: an "error_page" directive did not redirect a 413 error; the bug had appeared in 0.6.10.
author Igor Sysoev <http://sysoev.ru>
date Mon, 07 Sep 2009 00:00:00 +0400
parents 441fbf722b8c
children 1b64f9884263
files CHANGES CHANGES.ru src/core/nginx.h src/http/modules/perl/nginx.pm src/http/modules/perl/ngx_http_perl_module.c src/http/ngx_http_copy_filter_module.c src/http/ngx_http_core_module.c src/http/ngx_http_parse.c src/http/ngx_http_request.c src/http/ngx_http_request.h src/http/ngx_http_request_body.c src/http/ngx_http_upstream.c src/os/unix/ngx_freebsd_sendfile_chain.c
diffstat 13 files changed, 68 insertions(+), 34 deletions(-) [+]
line wrap: on
line diff
--- a/CHANGES
+++ b/CHANGES
@@ -1,7 +1,22 @@
 
+Changes with nginx 0.8.14                                        07 Sep 2009
+
+    *) Bugfix: an expired cached response might stick in the "UPDATING" 
+       state.
+
+    *) Bugfix: a segmentation fault might occur in worker process, if 
+       error_log was set to info or debug level.
+       Thanks to Sergey Bochenkov.
+
+    *) Bugfix: in embedded perl module; the bug had appeared in 0.8.11.
+
+    *) Bugfix: an "error_page" directive did not redirect a 413 error; the 
+       bug had appeared in 0.6.10.
+
+
 Changes with nginx 0.8.13                                        31 Aug 2009
 
-    *) Bugfix: in the "aio sendfile" directive. the bug had appeared in 
+    *) Bugfix: in the "aio sendfile" directive; the bug had appeared in 
        0.8.12.
 
     *) Bugfix: nginx could not be built without the --with-file-aio option 
--- a/CHANGES.ru
+++ b/CHANGES.ru
@@ -1,4 +1,20 @@
 
+Изменения в nginx 0.8.14                                          07.09.2009
+
+    *) Исправление: устаревший закэшированный запрос мог залипнуть в 
+       состоянии "UPDATING".
+
+    *) Исправление: при использовании error_log на уровне info или debug в 
+       рабочем процессе мог произойти segmentation fault.
+       Спасибо Сергею Боченкову.
+
+    *) Исправление: ошибки при использовании встроенного перла; ошибка 
+       появилась в 0.8.11.
+
+    *) Исправление: директива error_page не перенаправляла ошибку 413; 
+       ошибка появилась в 0.6.10.
+
+
 Изменения в nginx 0.8.13                                          31.08.2009
 
     *) Исправление: в директиве "aio sendfile"; ошибка появилась в 0.8.12.
--- a/src/core/nginx.h
+++ b/src/core/nginx.h
@@ -8,8 +8,8 @@
 #define _NGINX_H_INCLUDED_
 
 
-#define nginx_version         8013
-#define NGINX_VERSION      "0.8.13"
+#define nginx_version         8014
+#define NGINX_VERSION      "0.8.14"
 #define NGINX_VER          "nginx/" NGINX_VERSION
 
 #define NGINX_VAR          "NGINX"
--- 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.13';
+our $VERSION = '0.8.14';
 
 require XSLoader;
 XSLoader::load('nginx', $VERSION);
--- a/src/http/modules/perl/ngx_http_perl_module.c
+++ b/src/http/modules/perl/ngx_http_perl_module.c
@@ -179,6 +179,8 @@ ngx_http_perl_handler(ngx_http_request_t
         return NGX_HTTP_NOT_FOUND;
     }
 
+    r->main->count++;
+
     ngx_http_perl_handle_request(r);
 
     return NGX_DONE;
@@ -232,6 +234,9 @@ ngx_http_perl_handle_request(ngx_http_re
 
     }
 
+    ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
+                   "perl handler done: %i", rc);
+
     if (rc == NGX_DONE) {
         return;
     }
@@ -240,9 +245,6 @@ ngx_http_perl_handle_request(ngx_http_re
         rc = NGX_OK;
     }
 
-    ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
-                   "perl handler done: %i", rc);
-
     if (ctx->redirect_uri.len) {
         uri = ctx->redirect_uri;
         args = ctx->redirect_args;
--- a/src/http/ngx_http_copy_filter_module.c
+++ b/src/http/ngx_http_copy_filter_module.c
@@ -171,7 +171,7 @@ ngx_http_copy_filter(ngx_http_request_t 
             c->busy_sendfile = NULL;
             e = (ngx_http_ephemeral_t *) &r->uri_start;
 
-            n = ngx_file_aio_read(file, e->preload, 4, offset, r->pool);
+            n = ngx_file_aio_read(file, &e->aio_preload, 1, offset, r->pool);
 
             if (n > 0) {
                 continue;
--- a/src/http/ngx_http_core_module.c
+++ b/src/http/ngx_http_core_module.c
@@ -917,6 +917,7 @@ ngx_http_core_find_config_phase(ngx_http
                       "client intended to send too large body: %O bytes",
                       r->headers_in.content_length_n);
 
+        (void) ngx_http_discard_request_body(r);
         ngx_http_finalize_request(r, NGX_HTTP_REQUEST_ENTITY_TOO_LARGE);
         return NGX_OK;
     }
--- a/src/http/ngx_http_parse.c
+++ b/src/http/ngx_http_parse.c
@@ -739,6 +739,7 @@ ngx_http_parse_header_line(ngx_http_requ
 
         /* first char */
         case sw_start:
+            r->header_name_start = p;
             r->invalid_header = 0;
 
             switch (ch) {
@@ -751,7 +752,6 @@ ngx_http_parse_header_line(ngx_http_requ
                 goto header_done;
             default:
                 state = sw_name;
-                r->header_name_start = p;
 
                 c = lowcase[ch];
 
--- a/src/http/ngx_http_request.c
+++ b/src/http/ngx_http_request.c
@@ -893,9 +893,10 @@ ngx_http_process_request_line(ngx_event_
 static void
 ngx_http_process_request_headers(ngx_event_t *rev)
 {
+    u_char                     *p;
+    size_t                      len;
     ssize_t                     n;
     ngx_int_t                   rc, rv;
-    ngx_str_t                   header;
     ngx_table_elt_t            *h;
     ngx_connection_t           *c;
     ngx_http_header_t          *hh;
@@ -935,19 +936,17 @@ ngx_http_process_request_headers(ngx_eve
                 }
 
                 if (rv == NGX_DECLINED) {
-                    header.len = r->header_in->end - r->header_name_start;
-                    header.data = r->header_name_start;
-
-                    if (header.len > NGX_MAX_ERROR_STR - 300) {
-                        header.len = NGX_MAX_ERROR_STR - 300;
-                        header.data[header.len++] = '.';
-                        header.data[header.len++] = '.';
-                        header.data[header.len++] = '.';
+                    len = r->header_in->end - r->header_name_start;
+                    p = r->header_name_start;
+
+                    if (len > NGX_MAX_ERROR_STR - 300) {
+                        len = NGX_MAX_ERROR_STR - 300;
+                        p[len++] = '.'; p[len++] = '.'; p[len++] = '.';
                     }
 
                     ngx_log_error(NGX_LOG_INFO, c->log, 0,
-                                  "client sent too long header line: \"%V\"",
-                                  &header);
+                                  "client sent too long header line: \"%*s\"",
+                                  len, r->header_name_start);
                     ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST);
                     return;
                 }
@@ -969,12 +968,10 @@ ngx_http_process_request_headers(ngx_eve
 
                 /* there was error while a header line parsing */
 
-                header.len = r->header_end - r->header_name_start;
-                header.data = r->header_name_start;
-
                 ngx_log_error(NGX_LOG_INFO, c->log, 0,
-                              "client sent invalid header line: \"%V\"",
-                              &header);
+                              "client sent invalid header line: \"%*s\"",
+                              r->header_end - r->header_name_start,
+                              r->header_name_start);
                 continue;
             }
 
@@ -1054,11 +1051,10 @@ ngx_http_process_request_headers(ngx_eve
 
         /* rc == NGX_HTTP_PARSE_INVALID_HEADER: "\r" is not followed by "\n" */
 
-        header.len = r->header_end - r->header_name_start;
-        header.data = r->header_name_start;
         ngx_log_error(NGX_LOG_INFO, c->log, 0,
-                      "client sent invalid header line: \"%V\\r...\"",
-                      &header);
+                      "client sent invalid header line: \"%*s\\r...\"",
+                      r->header_end - r->header_name_start,
+                      r->header_name_start);
         ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST);
         return;
     }
--- a/src/http/ngx_http_request.h
+++ b/src/http/ngx_http_request.h
@@ -547,7 +547,7 @@ struct ngx_http_request_s {
 typedef struct {
     ngx_http_posted_request_t         terminal_posted_request;
 #if (NGX_HAVE_AIO_SENDFILE)
-    u_char                            preload[4];
+    u_char                            aio_preload;
 #endif
 } ngx_http_ephemeral_t;
 
--- a/src/http/ngx_http_request_body.c
+++ b/src/http/ngx_http_request_body.c
@@ -477,6 +477,7 @@ ngx_http_discard_request_body(ngx_http_r
         return NGX_HTTP_INTERNAL_SERVER_ERROR;
     }
 
+    r->count++;
     (void) ngx_http_read_discarded_request_body(r);
 
     return NGX_OK;
--- a/src/http/ngx_http_upstream.c
+++ b/src/http/ngx_http_upstream.c
@@ -2113,6 +2113,10 @@ ngx_http_upstream_send_response(ngx_http
     ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0,
                    "http cacheable: %d", u->cacheable);
 
+    if (u->cacheable == 0 && r->cache) {
+        ngx_http_file_cache_free(r, u->pipe->temp_file);
+    }
+
 #endif
 
     p = u->pipe;
--- a/src/os/unix/ngx_freebsd_sendfile_chain.c
+++ b/src/os/unix/ngx_freebsd_sendfile_chain.c
@@ -295,14 +295,13 @@ ngx_freebsd_sendfile_chain(ngx_connectio
 
                 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, err,
                                "sendfile() sent only %O bytes", sent);
-            }
 
             /*
              * sendfile() in FreeBSD 3.x-4.x may return value >= 0
              * on success, although only 0 is documented
              */
 
-            if (rc >= 0 && sent == 0) {
+            } else if (rc >= 0 && sent == 0) {
 
                 /*
                  * if rc is OK and sent equal to zero, then someone
@@ -311,8 +310,8 @@ ngx_freebsd_sendfile_chain(ngx_connectio
                  */
 
                 ngx_log_error(NGX_LOG_ALERT, c->log, 0,
-                              "sendfile() reported that \"%s\" was truncated",
-                              file->file->name.data);
+                         "sendfile() reported that \"%s\" was truncated at %O",
+                         file->file->name.data, file->file_pos);
 
                 return NGX_CHAIN_ERROR;
             }