mirror of
https://github.com/nginx/nginx.git
synced 2025-07-23 13:46:20 +08:00
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.
This commit is contained in:
parent
649cd3b401
commit
ce750db233
@ -1285,14 +1285,6 @@ ngx_shared_memory_add(ngx_conf_t *cf, ngx_str_t *name, size_t size, void *tag)
|
|||||||
continue;
|
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) {
|
if (tag != shm_zone[i].tag) {
|
||||||
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
||||||
"the shared memory zone \"%V\" is "
|
"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;
|
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];
|
return &shm_zone[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ ngx_radix_tree_create(ngx_pool_t *pool, ngx_int_t preallocate)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
if (preallocate == -1) {
|
if (preallocate == -1) {
|
||||||
switch (ngx_pagesize / sizeof(ngx_radix_tree_t)) {
|
switch (ngx_pagesize / sizeof(ngx_radix_node_t)) {
|
||||||
|
|
||||||
/* amd64 */
|
/* amd64 */
|
||||||
case 128:
|
case 128:
|
||||||
|
@ -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,
|
ngx_log_debug1(NGX_LOG_DEBUG_ALLOC, ngx_cycle->log, 0,
|
||||||
"slab alloc: %uz", size);
|
"slab alloc: %uz", size);
|
||||||
|
|
||||||
page = ngx_slab_alloc_pages(pool, (size + ngx_pagesize - 1)
|
page = ngx_slab_alloc_pages(pool, (size >> ngx_pagesize_shift)
|
||||||
>> ngx_pagesize_shift);
|
+ ((size % ngx_pagesize) ? 1 : 0));
|
||||||
if (page) {
|
if (page) {
|
||||||
p = (page - pool->pages) << ngx_pagesize_shift;
|
p = (page - pool->pages) << ngx_pagesize_shift;
|
||||||
p += (uintptr_t) pool->start;
|
p += (uintptr_t) pool->start;
|
||||||
|
@ -1827,7 +1827,7 @@ ngx_sort(void *base, size_t n, size_t size,
|
|||||||
#if (NGX_MEMCPY_LIMIT)
|
#if (NGX_MEMCPY_LIMIT)
|
||||||
|
|
||||||
void *
|
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) {
|
if (n > NGX_MEMCPY_LIMIT) {
|
||||||
ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, 0, "memcpy %uz bytes", n);
|
ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, 0, "memcpy %uz bytes", n);
|
||||||
|
@ -89,7 +89,7 @@ ngx_strlchr(u_char *p, u_char *last, u_char c)
|
|||||||
|
|
||||||
#if (NGX_MEMCPY_LIMIT)
|
#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))
|
#define ngx_cpymem(dst, src, n) (((u_char *) ngx_memcpy(dst, src, n)) + (n))
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
@ -211,6 +211,10 @@ ngx_time_sigsafe_update(void)
|
|||||||
slot++;
|
slot++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tp = &cached_time[slot];
|
||||||
|
|
||||||
|
tp->sec = 0;
|
||||||
|
|
||||||
ngx_gmtime(sec + cached_gmtoff * 60, &tm);
|
ngx_gmtime(sec + cached_gmtoff * 60, &tm);
|
||||||
|
|
||||||
p = &cached_err_log_time[slot][0];
|
p = &cached_err_log_time[slot][0];
|
||||||
|
@ -185,23 +185,19 @@ ngx_http_write_filter(ngx_http_request_t *r, ngx_chain_t *in)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (size == 0 && !(c->buffered & NGX_LOWLEVEL_BUFFERED)) {
|
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;
|
r->out = NULL;
|
||||||
c->buffered &= ~NGX_HTTP_WRITE_BUFFERED;
|
c->buffered &= ~NGX_HTTP_WRITE_BUFFERED;
|
||||||
|
|
||||||
return NGX_OK;
|
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,
|
ngx_log_error(NGX_LOG_ALERT, c->log, 0,
|
||||||
"the http output chain is empty");
|
"the http output chain is empty");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user