Mercurial > hg > nginx
changeset 4848:a0f1d53546d4 stable-1.2
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.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Mon, 24 Sep 2012 18:34:04 +0000 |
parents | 0275f587e00b |
children | 026ff0eb3062 |
files | src/core/ngx_cycle.c src/core/ngx_radix_tree.c src/core/ngx_slab.c src/core/ngx_string.c src/core/ngx_string.h src/core/ngx_times.c src/http/ngx_http_write_filter_module.c |
diffstat | 7 files changed, 24 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- a/src/core/ngx_cycle.c Mon Sep 24 18:30:26 2012 +0000 +++ b/src/core/ngx_cycle.c Mon Sep 24 18:34:04 2012 +0000 @@ -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]; }
--- a/src/core/ngx_radix_tree.c Mon Sep 24 18:30:26 2012 +0000 +++ b/src/core/ngx_radix_tree.c Mon Sep 24 18:34:04 2012 +0000 @@ -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:
--- a/src/core/ngx_slab.c Mon Sep 24 18:30:26 2012 +0000 +++ b/src/core/ngx_slab.c Mon Sep 24 18:34:04 2012 +0000 @@ -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;
--- a/src/core/ngx_string.c Mon Sep 24 18:30:26 2012 +0000 +++ b/src/core/ngx_string.c Mon Sep 24 18:34:04 2012 +0000 @@ -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);
--- a/src/core/ngx_string.h Mon Sep 24 18:30:26 2012 +0000 +++ b/src/core/ngx_string.h Mon Sep 24 18:34:04 2012 +0000 @@ -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
--- a/src/core/ngx_times.c Mon Sep 24 18:30:26 2012 +0000 +++ b/src/core/ngx_times.c Mon Sep 24 18:34:04 2012 +0000 @@ -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];
--- a/src/http/ngx_http_write_filter_module.c Mon Sep 24 18:30:26 2012 +0000 +++ b/src/http/ngx_http_write_filter_module.c Mon Sep 24 18:34:04 2012 +0000 @@ -185,18 +185,14 @@ } if (size == 0 && !(c->buffered & NGX_LOWLEVEL_BUFFERED)) { - if (last) { - r->out = NULL; - c->buffered &= ~NGX_HTTP_WRITE_BUFFERED; + if (last || flush) { + for (cl = r->out; cl; /* void */) { + ln = cl; + cl = cl->next; + ngx_free_chain(r->pool, ln); + } - return NGX_OK; - } - - if (flush) { - do { - r->out = r->out->next; - } while (r->out); - + r->out = NULL; c->buffered &= ~NGX_HTTP_WRITE_BUFFERED; return NGX_OK;