diff options
| author | Igor Sysoev <igor@sysoev.ru> | 2011-11-28 16:01:26 +0000 |
|---|---|---|
| committer | Jonathan Kolb <jon@b0g.us> | 2011-11-28 16:01:26 +0000 |
| commit | 7989e17482b6bd13b83a9e63a9c4f58f3432945a (patch) | |
| tree | 1cdcc09ac8773fe4b03e110b296db210d6d22265 /src/core | |
| parent | fe0ffd542b079021418c77ba3281df919ed1bf71 (diff) | |
| download | nginx-7989e17482b6bd13b83a9e63a9c4f58f3432945a.tar.gz | |
Changes with nginx 1.1.9 28 Nov 2011v1.1.9
*) Change: now double quotes are encoded in an "echo" SSI-command
output.
Thanks to Zaur Abasmirzoev.
*) Feature: the "valid" parameter of the "resolver" directive. By
default TTL returned by a DNS server is used.
Thanks to Kirill A. Korinskiy.
*) Bugfix: nginx might hang after a worker process abnormal termination.
*) Bugfix: a segmentation fault might occur in a worker process if SNI
was used; the bug had appeared in 1.1.2.
*) Bugfix: in the "keepalive_disable" directive; the bug had appeared in
1.1.8.
Thanks to Alexander Usov.
*) Bugfix: SIGWINCH signal did not work after first binary upgrade; the
bug had appeared in 1.1.1.
*) Bugfix: backend responses with length not matching "Content-Length"
header line are no longer cached.
*) Bugfix: in the "scgi_param" directive, if complex parameters were
used.
*) Bugfix: in the "epoll" event method.
Thanks to Yichun Zhang.
*) Bugfix: in the ngx_http_flv_module.
Thanks to Piotr Sikora.
*) Bugfix: in the ngx_http_mp4_module.
*) Bugfix: IPv6 addresses are now handled properly in a request line and
in a "Host" request header line.
*) Bugfix: "add_header" and "expires" directives did not work if a
request was proxied and response status code was 206.
*) Bugfix: nginx could not be built on FreeBSD 10.
*) Bugfix: nginx could not be built on AIX.
Maxim Dounin
_______________________________________________
nginx-announce mailing list
nginx-announce@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-announce
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/nginx.c | 4 | ||||
| -rw-r--r-- | src/core/nginx.h | 4 | ||||
| -rw-r--r-- | src/core/ngx_cycle.c | 2 | ||||
| -rw-r--r-- | src/core/ngx_resolver.c | 45 | ||||
| -rw-r--r-- | src/core/ngx_shmtx.c | 113 | ||||
| -rw-r--r-- | src/core/ngx_shmtx.h | 13 | ||||
| -rw-r--r-- | src/core/ngx_slab.h | 2 | ||||
| -rw-r--r-- | src/core/ngx_string.c | 9 |
8 files changed, 137 insertions, 55 deletions
diff --git a/src/core/nginx.c b/src/core/nginx.c index 9e00a2d86..5de48351a 100644 --- a/src/core/nginx.c +++ b/src/core/nginx.c @@ -374,6 +374,10 @@ main(int argc, char *const *argv) ngx_daemonized = 1; } + if (ngx_inherited) { + ngx_daemonized = 1; + } + #endif if (ngx_create_pidfile(&ccf->pid, cycle->log) != NGX_OK) { diff --git a/src/core/nginx.h b/src/core/nginx.h index 4b8badc02..4bde2c713 100644 --- a/src/core/nginx.h +++ b/src/core/nginx.h @@ -8,8 +8,8 @@ #define _NGINX_H_INCLUDED_ -#define nginx_version 1001008 -#define NGINX_VERSION "1.1.8" +#define nginx_version 1001009 +#define NGINX_VERSION "1.1.9" #define NGINX_VER "nginx/" NGINX_VERSION #define NGINX_VAR "NGINX" diff --git a/src/core/ngx_cycle.c b/src/core/ngx_cycle.c index db473571f..525ef41d7 100644 --- a/src/core/ngx_cycle.c +++ b/src/core/ngx_cycle.c @@ -952,7 +952,7 @@ ngx_init_zone_pool(ngx_cycle_t *cycle, ngx_shm_zone_t *zn) #endif - if (ngx_shmtx_create(&sp->mutex, (void *) &sp->lock, file) != NGX_OK) { + if (ngx_shmtx_create(&sp->mutex, &sp->lock, file) != NGX_OK) { return NGX_ERROR; } diff --git a/src/core/ngx_resolver.c b/src/core/ngx_resolver.c index 35818a7ae..d4af2f016 100644 --- a/src/core/ngx_resolver.c +++ b/src/core/ngx_resolver.c @@ -93,6 +93,7 @@ static u_char *ngx_resolver_log_error(ngx_log_t *log, u_char *buf, size_t len); ngx_resolver_t * ngx_resolver_create(ngx_conf_t *cf, ngx_str_t *names, ngx_uint_t n) { + ngx_str_t s; ngx_url_t u; ngx_uint_t i; ngx_resolver_t *r; @@ -146,12 +147,27 @@ ngx_resolver_create(ngx_conf_t *cf, ngx_str_t *names, ngx_uint_t n) r->resend_timeout = 5; r->expire = 30; - r->valid = 300; + r->valid = 0; r->log = &cf->cycle->new_log; r->log_level = NGX_LOG_ERR; for (i = 0; i < n; i++) { + if (ngx_strncmp(names[i].data, "valid=", 6) == 0) { + s.len = names[i].len - 6; + s.data = names[i].data + 6; + + r->valid = ngx_parse_time(&s, 1); + + if (r->valid == NGX_ERROR) { + ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, + "invalid parameter: %V", &names[i]); + return NULL; + } + + continue; + } + ngx_memzero(&u, sizeof(ngx_url_t)); u.host = names[i]; @@ -1149,6 +1165,7 @@ ngx_resolver_process_a(ngx_resolver_t *r, u_char *buf, size_t last, char *err; u_char *cname; size_t len; + int32_t ttl; uint32_t hash; in_addr_t addr, *addrs; ngx_str_t name; @@ -1219,6 +1236,7 @@ ngx_resolver_process_a(ngx_resolver_t *r, u_char *buf, size_t last, addrs = NULL; cname = NULL; qtype = 0; + ttl = 0; for (a = 0; a < nan; a++) { @@ -1258,6 +1276,12 @@ ngx_resolver_process_a(ngx_resolver_t *r, u_char *buf, size_t last, qtype = (an->type_hi << 8) + an->type_lo; len = (an->len_hi << 8) + an->len_lo; + ttl = (an->ttl[0] << 24) + (an->ttl[1] << 16) + + (an->ttl[2] << 8) + (an->ttl[3]); + + if (ttl < 0) { + ttl = 0; + } if (qtype == NGX_RESOLVE_A) { @@ -1287,8 +1311,9 @@ ngx_resolver_process_a(ngx_resolver_t *r, u_char *buf, size_t last, } } - ngx_log_debug2(NGX_LOG_DEBUG_CORE, r->log, 0, - "resolver naddrs:%ui cname:%p", naddrs, cname); + ngx_log_debug3(NGX_LOG_DEBUG_CORE, r->log, 0, + "resolver naddrs:%ui cname:%p ttl:%d", + naddrs, cname, ttl); if (naddrs) { @@ -1357,7 +1382,7 @@ ngx_resolver_process_a(ngx_resolver_t *r, u_char *buf, size_t last, ngx_queue_remove(&rn->queue); - rn->valid = ngx_time() + r->valid; + rn->valid = ngx_time() + (r->valid ? r->valid : ttl); rn->expire = ngx_time() + r->expire; ngx_queue_insert_head(&r->name_expire_queue, &rn->queue); @@ -1399,7 +1424,8 @@ ngx_resolver_process_a(ngx_resolver_t *r, u_char *buf, size_t last, rn->cnlen = (u_short) name.len; rn->u.cname = name.data; - rn->valid = ngx_time() + r->valid; + + rn->valid = ngx_time() + (r->valid ? r->valid : ttl); rn->expire = ngx_time() + r->expire; ngx_queue_insert_head(&r->name_expire_queue, &rn->queue); @@ -1450,6 +1476,7 @@ ngx_resolver_process_ptr(ngx_resolver_t *r, u_char *buf, size_t n, char *err; size_t len; in_addr_t addr; + int32_t ttl; ngx_int_t digit; ngx_str_t name; ngx_uint_t i, mask, qident; @@ -1545,6 +1572,12 @@ ngx_resolver_process_ptr(ngx_resolver_t *r, u_char *buf, size_t n, an = (ngx_resolver_an_t *) &buf[i + 2]; len = (an->len_hi << 8) + an->len_lo; + ttl = (an->ttl[0] << 24) + (an->ttl[1] << 16) + + (an->ttl[2] << 8) + (an->ttl[3]); + + if (ttl < 0) { + ttl = 0; + } ngx_log_debug3(NGX_LOG_DEBUG_CORE, r->log, 0, "resolver qt:%ui cl:%ui len:%uz", @@ -1581,7 +1614,7 @@ ngx_resolver_process_ptr(ngx_resolver_t *r, u_char *buf, size_t n, ngx_queue_remove(&rn->queue); - rn->valid = ngx_time() + r->valid; + rn->valid = ngx_time() + (r->valid ? r->valid : ttl); rn->expire = ngx_time() + r->expire; ngx_queue_insert_head(&r->addr_expire_queue, &rn->queue); diff --git a/src/core/ngx_shmtx.c b/src/core/ngx_shmtx.c index 3b429c4f9..8a3178e61 100644 --- a/src/core/ngx_shmtx.c +++ b/src/core/ngx_shmtx.c @@ -11,10 +11,13 @@ #if (NGX_HAVE_ATOMIC_OPS) +static void ngx_shmtx_wakeup(ngx_shmtx_t *mtx); + + ngx_int_t -ngx_shmtx_create(ngx_shmtx_t *mtx, void *addr, u_char *name) +ngx_shmtx_create(ngx_shmtx_t *mtx, ngx_shmtx_sh_t *addr, u_char *name) { - mtx->lock = addr; + mtx->lock = &addr->lock; if (mtx->spin == (ngx_uint_t) -1) { return NGX_OK; @@ -24,6 +27,8 @@ ngx_shmtx_create(ngx_shmtx_t *mtx, void *addr, u_char *name) #if (NGX_HAVE_POSIX_SEM) + mtx->wait = &addr->wait; + if (sem_init(&mtx->sem, 1, 0) == -1) { ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, ngx_errno, "sem_init() failed"); @@ -56,12 +61,7 @@ ngx_shmtx_destory(ngx_shmtx_t *mtx) ngx_uint_t ngx_shmtx_trylock(ngx_shmtx_t *mtx) { - ngx_atomic_uint_t val; - - val = *mtx->lock; - - return ((val & 0x80000000) == 0 - && ngx_atomic_cmp_set(mtx->lock, val, val | 0x80000000)); + return (*mtx->lock == 0 && ngx_atomic_cmp_set(mtx->lock, 0, ngx_pid)); } @@ -69,17 +69,12 @@ void ngx_shmtx_lock(ngx_shmtx_t *mtx) { ngx_uint_t i, n; - ngx_atomic_uint_t val; ngx_log_debug0(NGX_LOG_DEBUG_CORE, ngx_cycle->log, 0, "shmtx lock"); for ( ;; ) { - val = *mtx->lock; - - if ((val & 0x80000000) == 0 - && ngx_atomic_cmp_set(mtx->lock, val, val | 0x80000000)) - { + if (*mtx->lock == 0 && ngx_atomic_cmp_set(mtx->lock, 0, ngx_pid)) { return; } @@ -91,10 +86,8 @@ ngx_shmtx_lock(ngx_shmtx_t *mtx) ngx_cpu_pause(); } - val = *mtx->lock; - - if ((val & 0x80000000) == 0 - && ngx_atomic_cmp_set(mtx->lock, val, val | 0x80000000)) + if (*mtx->lock == 0 + && ngx_atomic_cmp_set(mtx->lock, 0, ngx_pid)) { return; } @@ -104,24 +97,24 @@ ngx_shmtx_lock(ngx_shmtx_t *mtx) #if (NGX_HAVE_POSIX_SEM) if (mtx->semaphore) { - val = *mtx->lock; + (void) ngx_atomic_fetch_add(mtx->wait, 1); - if ((val & 0x80000000) - && ngx_atomic_cmp_set(mtx->lock, val, val + 1)) - { - ngx_log_debug1(NGX_LOG_DEBUG_CORE, ngx_cycle->log, 0, - "shmtx wait %XA", val); + if (*mtx->lock == 0 && ngx_atomic_cmp_set(mtx->lock, 0, ngx_pid)) { + return; + } - while (sem_wait(&mtx->sem) == -1) { - ngx_err_t err; + ngx_log_debug1(NGX_LOG_DEBUG_CORE, ngx_cycle->log, 0, + "shmtx wait %uA", *mtx->wait); - err = ngx_errno; + while (sem_wait(&mtx->sem) == -1) { + ngx_err_t err; - if (err != NGX_EINTR) { - ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, err, - "sem_wait() failed while waiting on shmtx"); - break; - } + err = ngx_errno; + + if (err != NGX_EINTR) { + ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, err, + "sem_wait() failed while waiting on shmtx"); + break; } ngx_log_debug0(NGX_LOG_DEBUG_CORE, ngx_cycle->log, 0, @@ -141,31 +134,56 @@ ngx_shmtx_lock(ngx_shmtx_t *mtx) void ngx_shmtx_unlock(ngx_shmtx_t *mtx) { - ngx_atomic_uint_t val, old, wait; - if (mtx->spin != (ngx_uint_t) -1) { ngx_log_debug0(NGX_LOG_DEBUG_CORE, ngx_cycle->log, 0, "shmtx unlock"); } - for ( ;; ) { + if (ngx_atomic_cmp_set(mtx->lock, ngx_pid, 0)) { + ngx_shmtx_wakeup(mtx); + } +} - old = *mtx->lock; - wait = old & 0x7fffffff; - val = wait ? wait - 1 : 0; - if (ngx_atomic_cmp_set(mtx->lock, old, val)) { - break; - } +ngx_uint_t +ngx_shmtx_force_unlock(ngx_shmtx_t *mtx, ngx_pid_t pid) +{ + ngx_log_debug0(NGX_LOG_DEBUG_CORE, ngx_cycle->log, 0, + "shmtx forced unlock"); + + if (ngx_atomic_cmp_set(mtx->lock, pid, 0)) { + ngx_shmtx_wakeup(mtx); + return 1; } + return 0; +} + + +static void +ngx_shmtx_wakeup(ngx_shmtx_t *mtx) +{ #if (NGX_HAVE_POSIX_SEM) + ngx_atomic_uint_t wait; - if (wait == 0 || !mtx->semaphore) { + if (!mtx->semaphore) { return; } + for ( ;; ) { + + wait = *mtx->wait; + + if (wait == 0) { + return; + } + + if (ngx_atomic_cmp_set(mtx->wait, wait, wait - 1)) { + break; + } + } + ngx_log_debug1(NGX_LOG_DEBUG_CORE, ngx_cycle->log, 0, - "shmtx wake %XA", old); + "shmtx wake %uA", wait); if (sem_post(&mtx->sem) == -1) { ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, ngx_errno, @@ -180,7 +198,7 @@ ngx_shmtx_unlock(ngx_shmtx_t *mtx) ngx_int_t -ngx_shmtx_create(ngx_shmtx_t *mtx, void *addr, u_char *name) +ngx_shmtx_create(ngx_shmtx_t *mtx, ngx_shmtx_sh_t *addr, u_char *name) { if (mtx->name) { @@ -280,4 +298,11 @@ ngx_shmtx_unlock(ngx_shmtx_t *mtx) ngx_log_abort(err, ngx_unlock_fd_n " %s failed", mtx->name); } + +ngx_uint_t +ngx_shmtx_force_unlock(ngx_shmtx_t *mtx, ngx_pid_t pid) +{ + return 0; +} + #endif diff --git a/src/core/ngx_shmtx.h b/src/core/ngx_shmtx.h index 714f73aa6..3ee7d3a79 100644 --- a/src/core/ngx_shmtx.h +++ b/src/core/ngx_shmtx.h @@ -13,9 +13,18 @@ typedef struct { + ngx_atomic_t lock; +#if (NGX_HAVE_POSIX_SEM) + ngx_atomic_t wait; +#endif +} ngx_shmtx_sh_t; + + +typedef struct { #if (NGX_HAVE_ATOMIC_OPS) ngx_atomic_t *lock; #if (NGX_HAVE_POSIX_SEM) + ngx_atomic_t *wait; ngx_uint_t semaphore; sem_t sem; #endif @@ -27,11 +36,13 @@ typedef struct { } ngx_shmtx_t; -ngx_int_t ngx_shmtx_create(ngx_shmtx_t *mtx, void *addr, u_char *name); +ngx_int_t ngx_shmtx_create(ngx_shmtx_t *mtx, ngx_shmtx_sh_t *addr, + u_char *name); void ngx_shmtx_destory(ngx_shmtx_t *mtx); ngx_uint_t ngx_shmtx_trylock(ngx_shmtx_t *mtx); void ngx_shmtx_lock(ngx_shmtx_t *mtx); void ngx_shmtx_unlock(ngx_shmtx_t *mtx); +ngx_uint_t ngx_shmtx_force_unlock(ngx_shmtx_t *mtx, ngx_pid_t pid); #endif /* _NGX_SHMTX_H_INCLUDED_ */ diff --git a/src/core/ngx_slab.h b/src/core/ngx_slab.h index 291e1b51e..202fd9380 100644 --- a/src/core/ngx_slab.h +++ b/src/core/ngx_slab.h @@ -22,7 +22,7 @@ struct ngx_slab_page_s { typedef struct { - ngx_atomic_t lock; + ngx_shmtx_sh_t lock; size_t min_size; size_t min_shift; diff --git a/src/core/ngx_string.c b/src/core/ngx_string.c index 29f8e0d67..f5e1d4bf3 100644 --- a/src/core/ngx_string.c +++ b/src/core/ngx_string.c @@ -1657,6 +1657,10 @@ ngx_escape_html(u_char *dst, u_char *src, size_t size) len += sizeof("&") - 2; break; + case '"': + len += sizeof(""") - 2; + break; + default: break; } @@ -1684,6 +1688,11 @@ ngx_escape_html(u_char *dst, u_char *src, size_t size) *dst++ = ';'; break; + case '"': + *dst++ = '&'; *dst++ = 'q'; *dst++ = 'u'; *dst++ = 'o'; + *dst++ = 't'; *dst++ = ';'; + break; + default: *dst++ = ch; break; |
