[nginx] svn commit: r4849 - in branches/stable-1.2: . src/core src/http

mdounin at mdounin.ru mdounin at mdounin.ru
Mon Sep 24 18:34:04 UTC 2012


Author: mdounin
Date: 2012-09-24 18:34:04 +0000 (Mon, 24 Sep 2012)
New Revision: 4849
URL: http://trac.nginx.org/nginx/changeset/4849/nginx

Log:
Merge of r4778, r4782, r4783, r4824, r4830, r4834: minor fixes.
 
*) Reorder checks in ngx_shared_memory_add() for more consistent
   error messages.

*) Added "const" to ngx_memcpy() with NGX_MEMCPY_LIMIT defined.  This   
   fixes warning produced during compilation of the ngx_http_geoip_module
   due to const qualifier being discarded.

*) Fixed possible use of old cached times if runtime went backwards.

   If ngx_time_sigsafe_update() updated only ngx_cached_err_log_time, and
   then clock was adjusted backwards, the cached_time[slot].sec might
   accidentally match current seconds on next ngx_time_update() call,
   resulting in various cached times not being updated.

   Fix is to clear the cached_time[slot].sec to explicitly mark cached times
   are stale and need updating.

*) Radix tree preallocation fix.  The preallocation size was calculated
   incorrectly and was always 8 due to sizeof(ngx_radix_tree_t) accidentally
   used instead of sizeof(ngx_radix_node_t).

*) Fixed overflow if ngx_slab_alloc() is called with very big "size"
   argument.

*) Write filter: replaced unneeded loop with one to free chains.
   Noted by Gabor Lekeny.


Modified:
   branches/stable-1.2/
   branches/stable-1.2/src/core/ngx_cycle.c
   branches/stable-1.2/src/core/ngx_radix_tree.c
   branches/stable-1.2/src/core/ngx_slab.c
   branches/stable-1.2/src/core/ngx_string.c
   branches/stable-1.2/src/core/ngx_string.h
   branches/stable-1.2/src/core/ngx_times.c
   branches/stable-1.2/src/http/ngx_http_write_filter_module.c

Index: branches/stable-1.2
===================================================================
--- branches/stable-1.2	2012-09-24 18:30:26 UTC (rev 4848)
+++ branches/stable-1.2	2012-09-24 18:34:04 UTC (rev 4849)

Property changes on: branches/stable-1.2
___________________________________________________________________
Modified: svn:mergeinfo
## -1 +1 ##
-/trunk:4611-4632,4636-4657,4671-4672,4674-4676,4682,4684-4699,4704-4706,4713,4736-4741,4754,4756-4771,4775,4777,4780,4831-4832
+/trunk:4611-4632,4636-4657,4671-4672,4674-4676,4682,4684-4699,4704-4706,4713,4736-4741,4754,4756-4771,4775,4777-4778,4780,4782-4783,4824,4830-4832,4834
\ No newline at end of property
Modified: branches/stable-1.2/src/core/ngx_cycle.c
===================================================================
--- branches/stable-1.2/src/core/ngx_cycle.c	2012-09-24 18:30:26 UTC (rev 4848)
+++ branches/stable-1.2/src/core/ngx_cycle.c	2012-09-24 18:34:04 UTC (rev 4849)
@@ -1285,6 +1285,14 @@
             continue;
         }
 
+        if (tag != shm_zone[i].tag) {
+            ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
+                            "the shared memory zone \"%V\" is "
+                            "already declared for a different use",
+                            &shm_zone[i].shm.name);
+            return NULL;
+        }
+
         if (size && size != shm_zone[i].shm.size) {
             ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
                             "the size %uz of shared memory zone \"%V\" "
@@ -1293,14 +1301,6 @@
             return NULL;
         }
 
-        if (tag != shm_zone[i].tag) {
-            ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
-                            "the shared memory zone \"%V\" is "
-                            "already declared for a different use",
-                            &shm_zone[i].shm.name);
-            return NULL;
-        }
-
         return &shm_zone[i];
     }
 

Modified: branches/stable-1.2/src/core/ngx_radix_tree.c
===================================================================
--- branches/stable-1.2/src/core/ngx_radix_tree.c	2012-09-24 18:30:26 UTC (rev 4848)
+++ branches/stable-1.2/src/core/ngx_radix_tree.c	2012-09-24 18:34:04 UTC (rev 4849)
@@ -60,7 +60,7 @@
      */
 
     if (preallocate == -1) {
-        switch (ngx_pagesize / sizeof(ngx_radix_tree_t)) {
+        switch (ngx_pagesize / sizeof(ngx_radix_node_t)) {
 
         /* amd64 */
         case 128:

Modified: branches/stable-1.2/src/core/ngx_slab.c
===================================================================
--- branches/stable-1.2/src/core/ngx_slab.c	2012-09-24 18:30:26 UTC (rev 4848)
+++ branches/stable-1.2/src/core/ngx_slab.c	2012-09-24 18:34:04 UTC (rev 4849)
@@ -162,8 +162,8 @@
         ngx_log_debug1(NGX_LOG_DEBUG_ALLOC, ngx_cycle->log, 0,
                        "slab alloc: %uz", size);
 
-        page = ngx_slab_alloc_pages(pool, (size + ngx_pagesize - 1)
-                                          >> ngx_pagesize_shift);
+        page = ngx_slab_alloc_pages(pool, (size >> ngx_pagesize_shift)
+                                          + ((size % ngx_pagesize) ? 1 : 0));
         if (page) {
             p = (page - pool->pages) << ngx_pagesize_shift;
             p += (uintptr_t) pool->start;

Modified: branches/stable-1.2/src/core/ngx_string.c
===================================================================
--- branches/stable-1.2/src/core/ngx_string.c	2012-09-24 18:30:26 UTC (rev 4848)
+++ branches/stable-1.2/src/core/ngx_string.c	2012-09-24 18:34:04 UTC (rev 4849)
@@ -1827,7 +1827,7 @@
 #if (NGX_MEMCPY_LIMIT)
 
 void *
-ngx_memcpy(void *dst, void *src, size_t n)
+ngx_memcpy(void *dst, const void *src, size_t n)
 {
     if (n > NGX_MEMCPY_LIMIT) {
         ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, 0, "memcpy %uz bytes", n);

Modified: branches/stable-1.2/src/core/ngx_string.h
===================================================================
--- branches/stable-1.2/src/core/ngx_string.h	2012-09-24 18:30:26 UTC (rev 4848)
+++ branches/stable-1.2/src/core/ngx_string.h	2012-09-24 18:34:04 UTC (rev 4849)
@@ -89,7 +89,7 @@
 
 #if (NGX_MEMCPY_LIMIT)
 
-void *ngx_memcpy(void *dst, void *src, size_t n);
+void *ngx_memcpy(void *dst, const void *src, size_t n);
 #define ngx_cpymem(dst, src, n)   (((u_char *) ngx_memcpy(dst, src, n)) + (n))
 
 #else

Modified: branches/stable-1.2/src/core/ngx_times.c
===================================================================
--- branches/stable-1.2/src/core/ngx_times.c	2012-09-24 18:30:26 UTC (rev 4848)
+++ branches/stable-1.2/src/core/ngx_times.c	2012-09-24 18:34:04 UTC (rev 4849)
@@ -211,6 +211,10 @@
         slot++;
     }
 
+    tp = &cached_time[slot];
+
+    tp->sec = 0;
+
     ngx_gmtime(sec + cached_gmtoff * 60, &tm);
 
     p = &cached_err_log_time[slot][0];

Modified: branches/stable-1.2/src/http/ngx_http_write_filter_module.c
===================================================================
--- branches/stable-1.2/src/http/ngx_http_write_filter_module.c	2012-09-24 18:30:26 UTC (rev 4848)
+++ branches/stable-1.2/src/http/ngx_http_write_filter_module.c	2012-09-24 18:34:04 UTC (rev 4849)
@@ -185,23 +185,19 @@
     }
 
     if (size == 0 && !(c->buffered & NGX_LOWLEVEL_BUFFERED)) {
-        if (last) {
+        if (last || flush) {
+            for (cl = r->out; cl; /* void */) {
+                ln = cl;
+                cl = cl->next;
+                ngx_free_chain(r->pool, ln);
+            }
+
             r->out = NULL;
             c->buffered &= ~NGX_HTTP_WRITE_BUFFERED;
 
             return NGX_OK;
         }
 
-        if (flush) {
-            do {
-                r->out = r->out->next;
-            } while (r->out);
-
-            c->buffered &= ~NGX_HTTP_WRITE_BUFFERED;
-
-            return NGX_OK;
-        }
-
         ngx_log_error(NGX_LOG_ALERT, c->log, 0,
                       "the http output chain is empty");
 



More information about the nginx-devel mailing list