diff options
author | nginx <nginx@nginx.org> | 2013-04-02 12:44:13 +0000 |
---|---|---|
committer | Jon Kolb <jon@b0g.us> | 2013-04-02 12:44:13 +0000 |
commit | 3f85d9c48a5764419dcfd4a8903167ba6180c1aa (patch) | |
tree | bea3d4fd9ead91cb7ecda912b83d860895a21557 | |
parent | 8c07e8f9375b3892e6b180d5b8e21a90bd2589bc (diff) | |
download | nginx-3f85d9c48a5764419dcfd4a8903167ba6180c1aa.tar.gz |
Changes with nginx 1.2.8 02 Apr 2013v1.2.8
*) Bugfix: new sessions were not always stored if the "ssl_session_cache
shared" directive was used and there was no free space in shared
memory.
Thanks to Piotr Sikora.
*) Bugfix: responses might hang if subrequests were used and a DNS error
happened during subrequest processing.
Thanks to Lanshun Zhou.
*) Bugfix: in the ngx_http_mp4_module.
Thanks to Gernot Vormayr.
*) Bugfix: in backend usage accounting.
24 files changed, 112 insertions, 56 deletions
@@ -1,4 +1,21 @@ +Changes with nginx 1.2.8 02 Apr 2013 + + *) Bugfix: new sessions were not always stored if the "ssl_session_cache + shared" directive was used and there was no free space in shared + memory. + Thanks to Piotr Sikora. + + *) Bugfix: responses might hang if subrequests were used and a DNS error + happened during subrequest processing. + Thanks to Lanshun Zhou. + + *) Bugfix: in the ngx_http_mp4_module. + Thanks to Gernot Vormayr. + + *) Bugfix: in backend usage accounting. + + Changes with nginx 1.2.7 12 Feb 2013 *) Change: now if the "include" directive with mask is used on Unix diff --git a/CHANGES.ru b/CHANGES.ru index 166632285..9d3187fe2 100644 --- a/CHANGES.ru +++ b/CHANGES.ru @@ -1,4 +1,21 @@ +Изменения в nginx 1.2.8 02.04.2013 + + *) Исправление: при использовании директивы "ssl_session_cache shared" + новые сессии могли не сохраняться, если заканчивалось место в + разделяемой памяти. + Спасибо Piotr Sikora. + + *) Исправление: ответы могли зависать, если использовались подзапросы и + при обработке подзапроса происходила DNS-ошибка. + Спасибо Lanshun Zhou. + + *) Исправление: в модуле ngx_http_mp4_module. + Спасибо Gernot Vormayr. + + *) Исправление: в процедуре учёта использования бэкендов. + + Изменения в nginx 1.2.7 12.02.2013 *) Изменение: теперь при использовании директивы include с маской на diff --git a/auto/lib/perl/make b/auto/lib/perl/make index 6fe95af0e..b40352abf 100644 --- a/auto/lib/perl/make +++ b/auto/lib/perl/make @@ -6,11 +6,12 @@ cat << END >> $NGX_MAKEFILE $NGX_OBJS/src/http/modules/perl/blib/arch/auto/nginx/nginx.so: \ + \$(CORE_DEPS) \$(HTTP_DEPS) \ src/http/modules/perl/nginx.pm \ src/http/modules/perl/nginx.xs \ src/http/modules/perl/ngx_http_perl_module.h \ $NGX_OBJS/src/http/modules/perl/Makefile - cp -p src/http/modules/perl/nginx.* $NGX_OBJS/src/http/modules/perl/ + cp src/http/modules/perl/nginx.* $NGX_OBJS/src/http/modules/perl/ cd $NGX_OBJS/src/http/modules/perl && \$(MAKE) diff --git a/src/core/nginx.c b/src/core/nginx.c index d02f9111d..94df9bf74 100644 --- a/src/core/nginx.c +++ b/src/core/nginx.c @@ -594,6 +594,10 @@ ngx_exec_new_binary(ngx_cycle_t *cycle, char *const *argv) var = ngx_alloc(sizeof(NGINX_VAR) + cycle->listening.nelts * (NGX_INT32_LEN + 1) + 2, cycle->log); + if (var == NULL) { + ngx_free(env); + return NGX_INVALID_PID; + } p = ngx_cpymem(var, NGINX_VAR "=", sizeof(NGINX_VAR)); @@ -633,7 +637,7 @@ ngx_exec_new_binary(ngx_cycle_t *cycle, char *const *argv) ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module); - if (ngx_rename_file(ccf->pid.data, ccf->oldpid.data) != NGX_OK) { + if (ngx_rename_file(ccf->pid.data, ccf->oldpid.data) == NGX_FILE_ERROR) { ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, ngx_rename_file_n " %s to %s failed " "before executing new binary process \"%s\"", @@ -648,7 +652,9 @@ ngx_exec_new_binary(ngx_cycle_t *cycle, char *const *argv) pid = ngx_execute(cycle, &ctx); if (pid == NGX_INVALID_PID) { - if (ngx_rename_file(ccf->oldpid.data, ccf->pid.data) != NGX_OK) { + if (ngx_rename_file(ccf->oldpid.data, ccf->pid.data) + == NGX_FILE_ERROR) + { ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, ngx_rename_file_n " %s back to %s failed after " "an attempt to execute new binary process \"%s\"", diff --git a/src/core/nginx.h b/src/core/nginx.h index 14068e2b5..a14187fe6 100644 --- a/src/core/nginx.h +++ b/src/core/nginx.h @@ -9,8 +9,8 @@ #define _NGINX_H_INCLUDED_ -#define nginx_version 1002007 -#define NGINX_VERSION "1.2.7" +#define nginx_version 1002008 +#define NGINX_VERSION "1.2.8" #define NGINX_VER "nginx/" NGINX_VERSION #define NGINX_VAR "NGINX" diff --git a/src/core/ngx_conf_file.c b/src/core/ngx_conf_file.c index ed7a2ce92..a26267213 100644 --- a/src/core/ngx_conf_file.c +++ b/src/core/ngx_conf_file.c @@ -133,7 +133,7 @@ ngx_conf_parse(ngx_conf_t *cf, ngx_str_t *filename) cf->conf_file = &conf_file; - if (ngx_fd_info(fd, &cf->conf_file->file.info) == -1) { + if (ngx_fd_info(fd, &cf->conf_file->file.info) == NGX_FILE_ERROR) { ngx_log_error(NGX_LOG_EMERG, cf->log, ngx_errno, ngx_fd_info_n " \"%s\" failed", filename->data); } diff --git a/src/core/ngx_connection.c b/src/core/ngx_connection.c index 3ba5e7682..8fae8c122 100644 --- a/src/core/ngx_connection.c +++ b/src/core/ngx_connection.c @@ -412,7 +412,7 @@ ngx_open_listening_sockets(ngx_cycle_t *cycle) } if (ngx_test_config) { - if (ngx_delete_file(name) == -1) { + if (ngx_delete_file(name) == NGX_FILE_ERROR) { ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, ngx_delete_file_n " %s failed", name); } @@ -739,7 +739,7 @@ ngx_close_listening_sockets(ngx_cycle_t *cycle) { u_char *name = ls[i].addr_text.data + sizeof("unix:") - 1; - if (ngx_delete_file(name) == -1) { + if (ngx_delete_file(name) == NGX_FILE_ERROR) { ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_socket_errno, ngx_delete_file_n " %s failed", name); } diff --git a/src/core/ngx_cycle.c b/src/core/ngx_cycle.c index dc4dc8993..87b6d7daa 100644 --- a/src/core/ngx_cycle.c +++ b/src/core/ngx_cycle.c @@ -679,7 +679,7 @@ old_shm_zone_done: ngx_log_error(NGX_LOG_WARN, cycle->log, 0, "deleting socket %s", name); - if (ngx_delete_file(name) == -1) { + if (ngx_delete_file(name) == NGX_FILE_ERROR) { ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_socket_errno, ngx_delete_file_n " %s failed", name); } diff --git a/src/event/ngx_event_openssl.c b/src/event/ngx_event_openssl.c index d3663c4f5..5c88e4ad6 100644 --- a/src/event/ngx_event_openssl.c +++ b/src/event/ngx_event_openssl.c @@ -1716,8 +1716,18 @@ ngx_ssl_new_session(ngx_ssl_conn_t *ssl_conn, ngx_ssl_session_t *sess) } sess_id = ngx_slab_alloc_locked(shpool, sizeof(ngx_ssl_sess_id_t)); + if (sess_id == NULL) { - goto failed; + + /* drop the oldest non-expired session and try once more */ + + ngx_ssl_expire_sessions(cache, shpool, 0); + + sess_id = ngx_slab_alloc_locked(shpool, sizeof(ngx_ssl_sess_id_t)); + + if (sess_id == NULL) { + goto failed; + } } #if (NGX_PTR_SIZE == 8) @@ -1727,8 +1737,18 @@ ngx_ssl_new_session(ngx_ssl_conn_t *ssl_conn, ngx_ssl_session_t *sess) #else id = ngx_slab_alloc_locked(shpool, sess->session_id_length); + if (id == NULL) { - goto failed; + + /* drop the oldest non-expired session and try once more */ + + ngx_ssl_expire_sessions(cache, shpool, 0); + + id = ngx_slab_alloc_locked(shpool, sess->session_id_length); + + if (id == NULL) { + goto failed; + } } #endif diff --git a/src/http/modules/ngx_http_autoindex_module.c b/src/http/modules/ngx_http_autoindex_module.c index 450a48e50..fb46d65d1 100644 --- a/src/http/modules/ngx_http_autoindex_module.c +++ b/src/http/modules/ngx_http_autoindex_module.c @@ -489,8 +489,11 @@ ngx_http_autoindex_handler(ngx_http_request_t *r) } b->last = ngx_cpymem(b->last, "</a>", sizeof("</a>") - 1); - ngx_memset(b->last, ' ', NGX_HTTP_AUTOINDEX_NAME_LEN - len); - b->last += NGX_HTTP_AUTOINDEX_NAME_LEN - len; + + if (NGX_HTTP_AUTOINDEX_NAME_LEN - len > 0) { + ngx_memset(b->last, ' ', NGX_HTTP_AUTOINDEX_NAME_LEN - len); + b->last += NGX_HTTP_AUTOINDEX_NAME_LEN - len; + } } *b->last++ = ' '; diff --git a/src/http/modules/ngx_http_index_module.c b/src/http/modules/ngx_http_index_module.c index cfe4ba6cc..d3544db5b 100644 --- a/src/http/modules/ngx_http_index_module.c +++ b/src/http/modules/ngx_http_index_module.c @@ -85,12 +85,12 @@ ngx_module_t ngx_http_index_module = { /* * Try to open/test the first index file before the test of directory - * existence because valid requests should be much more than invalid ones. - * If the file open()/stat() would fail, then the directory stat() should - * be more quickly because some data is already cached in the kernel. + * existence because valid requests should prevail over invalid ones. + * If open()/stat() of a file will fail then stat() of a directory + * should be faster because kernel may have already cached some data. * Besides, Win32 may return ERROR_PATH_NOT_FOUND (NGX_ENOTDIR) at once. - * Unix has ENOTDIR error, however, it's less helpful than Win32's one: - * it only indicates that path contains an usual file in place of directory. + * Unix has ENOTDIR error; however, it's less helpful than Win32's one: + * it only indicates that path points to a regular file, not a directory. */ static ngx_int_t diff --git a/src/http/modules/ngx_http_mp4_module.c b/src/http/modules/ngx_http_mp4_module.c index d3be23420..e793f77b7 100644 --- a/src/http/modules/ngx_http_mp4_module.c +++ b/src/http/modules/ngx_http_mp4_module.c @@ -750,6 +750,13 @@ ngx_http_mp4_process(ngx_http_mp4_file_t *mp4) *prev = &mp4->mdat_atom; + if (start_offset > mp4->mdat_data.buf->file_last) { + ngx_log_error(NGX_LOG_ERR, mp4->file.log, 0, + "start time is out mp4 mdat atom in \"%s\"", + mp4->file.name.data); + return NGX_ERROR; + } + adjustment = mp4->ftyp_size + mp4->moov_size + ngx_http_mp4_update_mdat_atom(mp4, start_offset) - start_offset; diff --git a/src/http/modules/ngx_http_split_clients_module.c b/src/http/modules/ngx_http_split_clients_module.c index 992f6de7c..2f92c9e1a 100644 --- a/src/http/modules/ngx_http_split_clients_module.c +++ b/src/http/modules/ngx_http_split_clients_module.c @@ -218,7 +218,7 @@ ngx_http_split_clients(ngx_conf_t *cf, ngx_command_t *dummy, void *conf) part->percent = 0; } else { - if (value[0].data[value[0].len - 1] != '%') { + if (value[0].len == 0 || value[0].data[value[0].len - 1] != '%') { goto invalid; } diff --git a/src/http/modules/ngx_http_ssl_module.c b/src/http/modules/ngx_http_ssl_module.c index ea8a0da32..336018236 100644 --- a/src/http/modules/ngx_http_ssl_module.c +++ b/src/http/modules/ngx_http_ssl_module.c @@ -593,7 +593,6 @@ ngx_http_ssl_session_cache(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) for (j = sizeof("shared:") - 1; j < value[i].len; j++) { if (value[i].data[j] == ':') { - value[i].data[j] = '\0'; break; } diff --git a/src/http/modules/ngx_http_upstream_keepalive_module.c b/src/http/modules/ngx_http_upstream_keepalive_module.c index a2ad5aa8d..eed117404 100644 --- a/src/http/modules/ngx_http_upstream_keepalive_module.c +++ b/src/http/modules/ngx_http_upstream_keepalive_module.c @@ -37,8 +37,6 @@ typedef struct { ngx_event_save_peer_session_pt original_save_session; #endif - ngx_uint_t failed; /* unsigned:1 */ - } ngx_http_upstream_keepalive_peer_data_t; @@ -220,8 +218,6 @@ ngx_http_upstream_get_keepalive_peer(ngx_peer_connection_t *pc, void *data) ngx_log_debug0(NGX_LOG_DEBUG_HTTP, pc->log, 0, "get keepalive peer"); - kp->failed = 0; - /* ask balancer */ rc = kp->original_get_peer(pc, kp->data); @@ -282,18 +278,12 @@ ngx_http_upstream_free_keepalive_peer(ngx_peer_connection_t *pc, void *data, ngx_log_debug0(NGX_LOG_DEBUG_HTTP, pc->log, 0, "free keepalive peer"); - /* remember failed state - peer.free() may be called more than once */ - - if (state & NGX_PEER_FAILED) { - kp->failed = 1; - } - /* cache valid connections */ u = kp->upstream; c = pc->connection; - if (kp->failed + if (state & NGX_PEER_FAILED || c == NULL || c->read->eof || c->read->error diff --git a/src/http/modules/ngx_http_upstream_least_conn_module.c b/src/http/modules/ngx_http_upstream_least_conn_module.c index bd2f1bc9e..6066ed2bb 100644 --- a/src/http/modules/ngx_http_upstream_least_conn_module.c +++ b/src/http/modules/ngx_http_upstream_least_conn_module.c @@ -353,10 +353,6 @@ ngx_http_upstream_free_least_conn_peer(ngx_peer_connection_t *pc, return; } - if (state == 0 && pc->tries == 0) { - return; - } - lcp->conns[lcp->rrp.current]--; lcp->free_rr_peer(pc, &lcp->rrp, state); diff --git a/src/http/modules/perl/nginx.pm b/src/http/modules/perl/nginx.pm index 5c7a4c3fc..27a6f55a4 100644 --- a/src/http/modules/perl/nginx.pm +++ b/src/http/modules/perl/nginx.pm @@ -50,7 +50,7 @@ our @EXPORT = qw( HTTP_INSUFFICIENT_STORAGE ); -our $VERSION = '1.2.7'; +our $VERSION = '1.2.8'; require XSLoader; XSLoader::load('nginx', $VERSION); diff --git a/src/http/ngx_http.h b/src/http/ngx_http.h index f152006a0..d278d8346 100644 --- a/src/http/ngx_http.h +++ b/src/http/ngx_http.h @@ -94,7 +94,6 @@ void ngx_http_split_args(ngx_http_request_t *r, ngx_str_t *uri, ngx_str_t *args); -ngx_int_t ngx_http_find_server_conf(ngx_http_request_t *r); void ngx_http_update_location_config(ngx_http_request_t *r); void ngx_http_handler(ngx_http_request_t *r); void ngx_http_run_posted_requests(ngx_connection_t *c); diff --git a/src/http/ngx_http_file_cache.c b/src/http/ngx_http_file_cache.c index bd6cebadd..6d94c5034 100644 --- a/src/http/ngx_http_file_cache.c +++ b/src/http/ngx_http_file_cache.c @@ -1674,8 +1674,6 @@ ngx_http_file_cache_set_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) p = (u_char *) ngx_strchr(name.data, ':'); if (p) { - *p = '\0'; - name.len = p - name.data; p++; diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c index ee00fd3af..bac35fcc9 100644 --- a/src/http/ngx_http_request.c +++ b/src/http/ngx_http_request.c @@ -2743,6 +2743,7 @@ ngx_http_keepalive_handler(ngx_event_t *rev) if (n == NGX_AGAIN) { if (ngx_handle_read_event(rev, 0) != NGX_OK) { ngx_http_close_connection(c); + return; } /* diff --git a/src/http/ngx_http_upstream.c b/src/http/ngx_http_upstream.c index 3436c6b1d..dc1283a20 100644 --- a/src/http/ngx_http_upstream.c +++ b/src/http/ngx_http_upstream.c @@ -865,11 +865,13 @@ ngx_http_upstream_cache_send(ngx_http_request_t *r, ngx_http_upstream_t *u) static void ngx_http_upstream_resolve_handler(ngx_resolver_ctx_t *ctx) { + ngx_connection_t *c; ngx_http_request_t *r; ngx_http_upstream_t *u; ngx_http_upstream_resolved_t *ur; r = ctx->data; + c = r->connection; u = r->upstream; ur = u->resolved; @@ -881,7 +883,7 @@ ngx_http_upstream_resolve_handler(ngx_resolver_ctx_t *ctx) ngx_resolver_strerror(ctx->state)); ngx_http_upstream_finalize_request(r, u, NGX_HTTP_BAD_GATEWAY); - return; + goto failed; } ur->naddrs = ctx->naddrs; @@ -906,13 +908,17 @@ ngx_http_upstream_resolve_handler(ngx_resolver_ctx_t *ctx) if (ngx_http_upstream_create_round_robin_peer(r, ur) != NGX_OK) { ngx_http_upstream_finalize_request(r, u, NGX_HTTP_INTERNAL_SERVER_ERROR); - return; + goto failed; } ngx_resolve_name_done(ctx); ur->ctx = NULL; ngx_http_upstream_connect(r, u); + +failed: + + ngx_http_run_posted_requests(c); } @@ -2840,14 +2846,16 @@ ngx_http_upstream_next(ngx_http_request_t *r, ngx_http_upstream_t *u, ngx_http_busy_unlock(u->conf->busy_lock, &u->busy_lock); #endif - if (ft_type == NGX_HTTP_UPSTREAM_FT_HTTP_404) { - state = NGX_PEER_NEXT; - } else { - state = NGX_PEER_FAILED; - } + if (u->peer.sockaddr) { + + if (ft_type == NGX_HTTP_UPSTREAM_FT_HTTP_404) { + state = NGX_PEER_NEXT; + } else { + state = NGX_PEER_FAILED; + } - if (ft_type != NGX_HTTP_UPSTREAM_FT_NOLIVE) { u->peer.free(&u->peer, u->peer.data, state); + u->peer.sockaddr = NULL; } if (ft_type == NGX_HTTP_UPSTREAM_FT_TIMEOUT) { @@ -3007,8 +3015,9 @@ ngx_http_upstream_finalize_request(ngx_http_request_t *r, u->finalize_request(r, rc); - if (u->peer.free) { + if (u->peer.free && u->peer.sockaddr) { u->peer.free(&u->peer, u->peer.data, 0); + u->peer.sockaddr = NULL; } if (u->peer.connection) { diff --git a/src/http/ngx_http_upstream_round_robin.c b/src/http/ngx_http_upstream_round_robin.c index 61dce69cb..c9ecfb22a 100644 --- a/src/http/ngx_http_upstream_round_robin.c +++ b/src/http/ngx_http_upstream_round_robin.c @@ -584,10 +584,6 @@ ngx_http_upstream_free_round_robin_peer(ngx_peer_connection_t *pc, void *data, ngx_log_debug2(NGX_LOG_DEBUG_HTTP, pc->log, 0, "free rr peer %ui %ui", pc->tries, state); - if (state == 0 && pc->tries == 0) { - return; - } - /* TODO: NGX_PEER_KEEPALIVE */ if (rrp->peers->single) { diff --git a/src/http/ngx_http_variables.h b/src/http/ngx_http_variables.h index d2bb4db88..829fab31e 100644 --- a/src/http/ngx_http_variables.h +++ b/src/http/ngx_http_variables.h @@ -57,9 +57,6 @@ ngx_int_t ngx_http_variable_unknown_header(ngx_http_variable_value_t *v, ngx_str_t *var, ngx_list_part_t *part, size_t prefix); -#define ngx_http_clear_variable(r, index) r->variables0[index].text.data = NULL; - - #if (NGX_PCRE) typedef struct { diff --git a/src/os/unix/ngx_process_cycle.c b/src/os/unix/ngx_process_cycle.c index c9b0266ed..dfdfae081 100644 --- a/src/os/unix/ngx_process_cycle.c +++ b/src/os/unix/ngx_process_cycle.c @@ -647,7 +647,7 @@ ngx_reap_children(ngx_cycle_t *cycle) if (ngx_rename_file((char *) ccf->oldpid.data, (char *) ccf->pid.data) - != NGX_OK) + == NGX_FILE_ERROR) { ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, ngx_rename_file_n " %s back to %s failed " |