changeset 282:675a39fd14cd NGINX_0_5_11

nginx 0.5.11 *) Feature: now configure detects system PCRE library in MacPorts. Thanks to Chris McGrath. *) Bugfix: the response was incorrect if several ranges were requested; bug appeared in 0.5.6. *) Bugfix: the "create_full_put_path" directive could not create the intermediate directories if no "dav_access" directive was set. Thanks to Evan Miller. *) Bugfix: the "0" response code might be logged in the access_log instead of the "400" and "408" error codes. *) Bugfix: a segmentation fault might occur in worker process if nginx was built with -O2 optimization.
author Igor Sysoev <http://sysoev.ru>
date Mon, 05 Feb 2007 00:00:00 +0300
parents 5338da501733
children 48810289fcb1
files CHANGES CHANGES.ru auto/lib/pcre/conf src/core/nginx.h src/core/ngx_file.c src/core/ngx_times.c src/event/ngx_event.c src/http/modules/ngx_http_dav_module.c src/http/modules/ngx_http_memcached_module.c src/http/modules/ngx_http_range_filter_module.c src/http/modules/perl/nginx.pm src/http/ngx_http_request.c src/os/unix/ngx_files.h
diffstat 13 files changed, 95 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/CHANGES
+++ b/CHANGES
@@ -1,4 +1,23 @@
 
+Changes with nginx 0.5.11                                        05 Feb 2007
+
+    *) Feature: now configure detects system PCRE library in MacPorts.
+       Thanks to Chris McGrath.
+
+    *) Bugfix: the response was incorrect if several ranges were requested; 
+       bug appeared in 0.5.6.
+
+    *) Bugfix: the "create_full_put_path" directive could not create the 
+       intermediate directories if no "dav_access" directive was set.
+       Thanks to Evan Miller.
+
+    *) Bugfix: the "0" response code might be logged in the access_log 
+       instead of the "400" and "408" error codes.
+
+    *) Bugfix: a segmentation fault might occur in worker process if nginx 
+       was built with -O2 optimization.
+
+
 Changes with nginx 0.5.10                                        26 Jan 2007
 
     *) Bugfix: while online executable file upgrade the new master process 
--- a/CHANGES.ru
+++ b/CHANGES.ru
@@ -1,4 +1,25 @@
 
+Изменения в nginx 0.5.11                                          05.02.2007
+
+    *) Добавление: теперь configure определяет библиотеку PCRE в 
+       MacPorts.
+       Спасибо Chris McGrath.
+
+    *) Исправление: ответ был неверным, если запрашивалось несколько 
+       диапазонов; ошибка появилась в 0.5.6.
+
+    *) Исправление: директива create_full_put_path не могла создавать 
+       промежуточные каталоги, если не была установлена директива 
+       dav_access.
+       Спасибо Evan Miller.
+
+    *) Исправление: вместо кодов ошибок "400" и "408" в access_log мог 
+       записываться код "0".
+
+    *) Исправление: при сборке с оптимизацией -O2 в рабочем процессе мог 
+       произойти segmentation fault.
+
+
 Изменения в nginx 0.5.10                                          26.01.2007
 
     *) Исправление: во время обновления исполняемого файла новый процесс не 
--- a/auto/lib/pcre/conf
+++ b/auto/lib/pcre/conf
@@ -169,6 +169,31 @@ else
             CORE_LIBS="$CORE_LIBS $ngx_feature_libs"
             PCRE=YES
             ngx_found=no
+
+        else
+            # MacPorts
+
+            if [ $PCRE = NO ]; then
+
+                ngx_feature="PCRE library in /opt/local/"
+                ngx_feature_name="NGX_PCRE"
+                ngx_feature_run=no
+                ngx_feature_incs="#include <pcre.h>"
+                ngx_feature_path="/opt/local/include"
+                ngx_feature_libs="-L/opt/local/lib -lpcre"
+                ngx_feature_test="pcre *re;
+                                  re = pcre_compile(NULL, 0, NULL, 0, NULL)"
+                . auto/feature
+            fi
+        fi
+
+        if [ $ngx_found = yes ]; then
+            CORE_DEPS="$CORE_DEPS $REGEX_DEPS"
+            CORE_SRCS="$CORE_SRCS $REGEX_SRCS"
+            CORE_INCS="$CORE_INCS $ngx_feature_path"
+            CORE_LIBS="$CORE_LIBS $ngx_feature_libs"
+            PCRE=YES
+            ngx_found=no
         fi
 
     fi
--- a/src/core/nginx.h
+++ b/src/core/nginx.h
@@ -8,7 +8,7 @@
 #define _NGINX_H_INCLUDED_
 
 
-#define NGINX_VERSION      "0.5.10"
+#define NGINX_VERSION      "0.5.11"
 #define NGINX_VER          "nginx/" NGINX_VERSION
 
 #define NGINX_VAR          "NGINX"
--- a/src/core/ngx_file.c
+++ b/src/core/ngx_file.c
@@ -39,12 +39,12 @@ ngx_int_t
 ngx_create_temp_file(ngx_file_t *file, ngx_path_t *path, ngx_pool_t *pool,
     ngx_uint_t persistent, ngx_uint_t clean, ngx_uint_t access)
 {
+    uint32_t                  n;
     ngx_err_t                 err;
-    ngx_atomic_uint_t         n;
     ngx_pool_cleanup_t       *cln;
     ngx_pool_cleanup_file_t  *clnf;
 
-    file->name.len = path->name.len + 1 + path->len + NGX_ATOMIC_T_LEN;
+    file->name.len = path->name.len + 1 + path->len + 10;
 
     file->name.data = ngx_palloc(pool, file->name.len + 1);
     if (file->name.data == NULL) {
@@ -59,11 +59,11 @@ ngx_create_temp_file(ngx_file_t *file, n
 
     ngx_memcpy(file->name.data, path->name.data, path->name.len);
 
-    n = ngx_next_temp_number(0);
+    n = (uint32_t) ngx_next_temp_number(0);
 
     for ( ;; ) {
         (void) ngx_sprintf(file->name.data + path->name.len + 1 + path->len,
-                           "%0muA%Z", n);
+                           "%010uD%Z", n);
 
         ngx_create_hashed_filename(file, path);
 
@@ -92,7 +92,7 @@ ngx_create_temp_file(ngx_file_t *file, n
         err = ngx_errno;
 
         if (err == NGX_EEXIST) {
-            n = ngx_next_temp_number(1);
+            n = (uint32_t) ngx_next_temp_number(1);
             continue;
         }
 
--- a/src/core/ngx_times.c
+++ b/src/core/ngx_times.c
@@ -87,7 +87,7 @@ ngx_time_update(time_t sec, ngx_uint_t m
         return;
     }
 
-    if (slot == NGX_TIME_SLOTS) {
+    if (slot == NGX_TIME_SLOTS - 1) {
         slot = 0;
     } else {
         slot++;
--- a/src/event/ngx_event.c
+++ b/src/event/ngx_event.c
@@ -845,7 +845,8 @@ ngx_send_lowat(ngx_connection_t *c, size
     sndlowat = (int) lowat;
 
     if (setsockopt(c->fd, SOL_SOCKET, SO_SNDLOWAT,
-                                  (const void *) &sndlowat, sizeof(int)) == -1)
+                   (const void *) &sndlowat, sizeof(int))
+        == -1)
     {
         ngx_connection_error(c, ngx_socket_errno,
                              "setsockopt(SO_SNDLOWAT) failed");
--- a/src/http/modules/ngx_http_dav_module.c
+++ b/src/http/modules/ngx_http_dav_module.c
@@ -252,7 +252,9 @@ ngx_http_dav_handler(ngx_http_request_t 
         ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
                        "http mkcol path: \"%s\"", path.data);
 
-        if (ngx_create_dir(path.data, dlcf->access) != NGX_FILE_ERROR) {
+        if (ngx_create_dir(path.data, ngx_dir_access(dlcf->access))
+            != NGX_FILE_ERROR)
+        {
             if (ngx_http_dav_location(r, path.data) != NGX_OK) {
                 return NGX_HTTP_INTERNAL_SERVER_ERROR;
             }
@@ -351,7 +353,7 @@ ngx_http_dav_put_handler(ngx_http_reques
 
 #if !(NGX_WIN32)
 
-    if (ngx_change_file_access(temp->data, dlcf->access & ~0111)
+    if (ngx_change_file_access(temp->data, dlcf->access)
         == NGX_FILE_ERROR)
     {
         err = ngx_errno;
@@ -393,7 +395,7 @@ ngx_http_dav_put_handler(ngx_http_reques
     if (err == NGX_ENOENT) {
 
         if (dlcf->create_full_put_path) {
-            err = ngx_create_full_path(path.data, dlcf->access);
+            err = ngx_create_full_path(path.data, ngx_dir_access(dlcf->access));
 
             if (err == 0) {
                 if (ngx_rename_file(temp->data, path.data) != NGX_FILE_ERROR) {
@@ -539,7 +541,7 @@ ngx_http_dav_access(ngx_conf_t *cf, ngx_
 
     value = cf->args->elts;
 
-    lcf->access = 0700;
+    lcf->access = 0600;
 
     for (i = 1; i < cf->args->nelts; i++) {
 
@@ -562,16 +564,16 @@ ngx_http_dav_access(ngx_conf_t *cf, ngx_
         }
 
         if (ngx_strcmp(p, "rw") == 0) {
-            right = 7;
+            right = 6;
 
         } else if (ngx_strcmp(p, "r") == 0) {
-            right = 5;
+            right = 4;
 
         } else {
             goto invalid;
         }
 
-        lcf->access += right << shift;
+        lcf->access |= right << shift;
     }
 
     return NGX_CONF_OK;
--- a/src/http/modules/ngx_http_memcached_module.c
+++ b/src/http/modules/ngx_http_memcached_module.c
@@ -242,7 +242,7 @@ ngx_http_memcached_create_request(ngx_ht
         return NGX_ERROR;
     }
 
-    len = sizeof("get ") - 1 + vv->len + sizeof(" " CRLF) - 1;
+    len = sizeof("get ") - 1 + vv->len + sizeof(CRLF) - 1;
     if (vv->len) {
         len += 1 + vv->len;
     }
@@ -275,7 +275,7 @@ ngx_http_memcached_create_request(ngx_ht
     ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
                    "http memcached request: \"%V\"", &ctx->key);
 
-    *b->last++ = ' '; *b->last++ = CR; *b->last++ = LF;
+    *b->last++ = CR; *b->last++ = LF;
 
     return NGX_OK;
 }
--- a/src/http/modules/ngx_http_range_filter_module.c
+++ b/src/http/modules/ngx_http_range_filter_module.c
@@ -596,13 +596,13 @@ ngx_http_range_body_filter(ngx_http_requ
         b->file = buf->file;
 
         if (buf->in_file) {
-            buf->file_pos = range[i].start;
-            buf->file_last = range[i].end;
+            b->file_pos = range[i].start;
+            b->file_last = range[i].end;
         }
 
         if (ngx_buf_in_memory(buf)) {
-            buf->pos = buf->start + (size_t) range[i].start;
-            buf->last = buf->start + (size_t) range[i].end;
+            b->pos = buf->start + (size_t) range[i].start;
+            b->last = buf->start + (size_t) range[i].end;
         }
 
         dcl = ngx_alloc_chain_link(r->pool);
--- 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.5.10';
+our $VERSION = '0.5.11';
 
 require XSLoader;
 XSLoader::load('nginx', $VERSION);
--- a/src/http/ngx_http_request.c
+++ b/src/http/ngx_http_request.c
@@ -1496,10 +1496,8 @@ ngx_http_finalize_request(ngx_http_reque
         || rc == NGX_HTTP_REQUEST_TIME_OUT
         || r->connection->error)
     {
-        if (rc == NGX_HTTP_CLIENT_CLOSED_REQUEST
-            && r->headers_out.status == 0)
-        {
-            r->headers_out.status = NGX_HTTP_CLIENT_CLOSED_REQUEST;
+        if (rc > 0 && r->headers_out.status == 0) {
+            r->headers_out.status = rc;
         }
 
         if (ngx_http_post_action(r) == NGX_OK) {
--- a/src/os/unix/ngx_files.h
+++ b/src/os/unix/ngx_files.h
@@ -122,6 +122,9 @@ ngx_int_t ngx_open_dir(ngx_str_t *name, 
 #define ngx_delete_dir_n         "rmdir()"
 
 
+#define ngx_dir_access(a)        (a | (a & 0444) >> 2)
+
+
 #define ngx_de_name(dir)         ((u_char *) (dir)->de->d_name)
 #if (NGX_FREEBSD)
 #define ngx_de_namelen(dir)      (dir)->de->d_namlen