diff options
| author | Maxim Dounin <mdounin@mdounin.ru> | 2012-09-24 18:34:04 +0000 |
|---|---|---|
| committer | Maxim Dounin <mdounin@mdounin.ru> | 2012-09-24 18:34:04 +0000 |
| commit | ce750db2339d2971202dbc536d4a36b6f5acc86c (patch) | |
| tree | 214a3130dfabe4cfbbb31f302768f066ae138d37 /src | |
| parent | 649cd3b401d37662d541aaf030fb0d90d1b43203 (diff) | |
| download | nginx-ce750db2339d2971202dbc536d4a36b6f5acc86c.tar.gz nginx-ce750db2339d2971202dbc536d4a36b6f5acc86c.tar.bz2 | |
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/ngx_cycle.c | 16 | ||||
| -rw-r--r-- | src/core/ngx_radix_tree.c | 2 | ||||
| -rw-r--r-- | src/core/ngx_slab.c | 4 | ||||
| -rw-r--r-- | src/core/ngx_string.c | 2 | ||||
| -rw-r--r-- | src/core/ngx_string.h | 2 | ||||
| -rw-r--r-- | src/core/ngx_times.c | 4 | ||||
| -rw-r--r-- | src/http/ngx_http_write_filter_module.c | 18 |
7 files changed, 24 insertions, 24 deletions
diff --git a/src/core/ngx_cycle.c b/src/core/ngx_cycle.c index 2da0bf91a..e5468ae9b 100644 --- a/src/core/ngx_cycle.c +++ b/src/core/ngx_cycle.c @@ -1285,14 +1285,6 @@ ngx_shared_memory_add(ngx_conf_t *cf, ngx_str_t *name, size_t size, void *tag) continue; } - 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\" " - "conflicts with already declared size %uz", - size, &shm_zone[i].shm.name, shm_zone[i].shm.size); - return NULL; - } - if (tag != shm_zone[i].tag) { ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "the shared memory zone \"%V\" is " @@ -1301,6 +1293,14 @@ ngx_shared_memory_add(ngx_conf_t *cf, ngx_str_t *name, size_t size, void *tag) 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\" " + "conflicts with already declared size %uz", + size, &shm_zone[i].shm.name, shm_zone[i].shm.size); + return NULL; + } + return &shm_zone[i]; } diff --git a/src/core/ngx_radix_tree.c b/src/core/ngx_radix_tree.c index b95cbc013..5b35d1e49 100644 --- a/src/core/ngx_radix_tree.c +++ b/src/core/ngx_radix_tree.c @@ -60,7 +60,7 @@ ngx_radix_tree_create(ngx_pool_t *pool, ngx_int_t preallocate) */ if (preallocate == -1) { - switch (ngx_pagesize / sizeof(ngx_radix_tree_t)) { + switch (ngx_pagesize / sizeof(ngx_radix_node_t)) { /* amd64 */ case 128: diff --git a/src/core/ngx_slab.c b/src/core/ngx_slab.c index 782792d79..ae9d6f3fc 100644 --- a/src/core/ngx_slab.c +++ b/src/core/ngx_slab.c @@ -162,8 +162,8 @@ ngx_slab_alloc_locked(ngx_slab_pool_t *pool, size_t size) 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; diff --git a/src/core/ngx_string.c b/src/core/ngx_string.c index 8aaa1d2ed..3b392f7b2 100644 --- a/src/core/ngx_string.c +++ b/src/core/ngx_string.c @@ -1827,7 +1827,7 @@ ngx_sort(void *base, size_t n, size_t size, #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); diff --git a/src/core/ngx_string.h b/src/core/ngx_string.h index fa386ca72..92d246ebc 100644 --- a/src/core/ngx_string.h +++ b/src/core/ngx_string.h @@ -89,7 +89,7 @@ ngx_strlchr(u_char *p, u_char *last, u_char c) #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 diff --git a/src/core/ngx_times.c b/src/core/ngx_times.c index ed1bf64bc..77490faf0 100644 --- a/src/core/ngx_times.c +++ b/src/core/ngx_times.c @@ -211,6 +211,10 @@ ngx_time_sigsafe_update(void) slot++; } + tp = &cached_time[slot]; + + tp->sec = 0; + ngx_gmtime(sec + cached_gmtoff * 60, &tm); p = &cached_err_log_time[slot][0]; diff --git a/src/http/ngx_http_write_filter_module.c b/src/http/ngx_http_write_filter_module.c index 72b1f9b2f..fd44bc659 100644 --- a/src/http/ngx_http_write_filter_module.c +++ b/src/http/ngx_http_write_filter_module.c @@ -185,18 +185,14 @@ ngx_http_write_filter(ngx_http_request_t *r, ngx_chain_t *in) } if (size == 0 && !(c->buffered & NGX_LOWLEVEL_BUFFERED)) { - if (last) { - r->out = NULL; - c->buffered &= ~NGX_HTTP_WRITE_BUFFERED; - - return NGX_OK; - } - - if (flush) { - do { - r->out = r->out->next; - } while (r->out); + 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; |
