# HG changeset patch # User Igor Sysoev # Date 1180296000 -14400 # Node ID 9b7db0df50f0ed6abbc2c8fcb681a007808148c0 # Parent a025840de07d7f6ee49f4d9e3a40c4d7b9ef0cbc nginx 0.5.21 *) Bugfix: if server has more than about ten locations, then regex locations might be choosen not in that order as they were specified. *) Bugfix: a worker process may got caught in an endless loop on 64-bit platform, if the 33-rd or next in succession backend has failed. Thanks to Anton Povarov. *) Bugfix: a bus error might occur on Solaris/sparc64 if the PCRE library was used. Thanks to Andrei Nigmatulin. *) Bugfix: in the HTTPS protocol in the "proxy_pass" directive. diff --git a/CHANGES b/CHANGES --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,20 @@ +Changes with nginx 0.5.21 28 May 2007 + + *) Bugfix: if server has more than about ten locations, then regex + locations may be choosen not in that order as they were specified. + + *) Bugfix: a worker process may got caught in an endless loop on 64-bit + platform, if the 33-rd or next in succession backend has failed. + Thanks to Anton Povarov. + + *) Bugfix: a bus error might occur on Solaris/sparc64 if the PCRE + library was used. + Thanks to Andrei Nigmatulin. + + *) Bugfix: in the HTTPS protocol in the "proxy_pass" directive. + + Changes with nginx 0.5.20 07 May 2007 *) Feature: the "sendfile_max_chunk" directive. diff --git a/CHANGES.ru b/CHANGES.ru --- a/CHANGES.ru +++ b/CHANGES.ru @@ -1,4 +1,21 @@ +Изменения в nginx 0.5.21 28.05.2007 + + *) Исправление: если внутри сервера описано больше примерно десяти + location'ов, то location'ы, заданные с помощью регулярного + выражения, могут выполняться не в том, порядке, в каком они описаны. + + *) Исправление: на 64-битной платформе рабочий процесс мог зациклиться, + если 33-тий по счёту или последующий бэкенд упал. + Спасибо Антону Поварову. + + *) Исправление: при использовании библиотеки PCRE на Solaris/sparc64 + мог произойти bus error. + Спасибо Андрею Нигматулину. + + *) Исправление: в использовании протокола HTTPS в директиве proxy_pass. + + Изменения в nginx 0.5.20 07.05.2007 *) Добавление: директива sendfile_max_chunk. diff --git a/src/core/nginx.h b/src/core/nginx.h --- a/src/core/nginx.h +++ b/src/core/nginx.h @@ -8,7 +8,7 @@ #define _NGINX_H_INCLUDED_ -#define NGINX_VERSION "0.5.20" +#define NGINX_VERSION "0.5.21" #define NGINX_VER "nginx/" NGINX_VERSION #define NGINX_VAR "NGINX" diff --git a/src/core/ngx_output_chain.c b/src/core/ngx_output_chain.c --- a/src/core/ngx_output_chain.c +++ b/src/core/ngx_output_chain.c @@ -473,7 +473,7 @@ ngx_chain_writer(void *data, ngx_chain_t size += ngx_buf_size(cl->buf); } - if (size == 0) { + if (size == 0 && !ctx->connection->buffered) { return NGX_OK; } @@ -489,6 +489,9 @@ ngx_chain_writer(void *data, ngx_chain_t if (ctx->out == NULL) { ctx->last = &ctx->out; + } + + if (!ctx->connection->buffered) { return NGX_OK; } diff --git a/src/core/ngx_palloc.c b/src/core/ngx_palloc.c --- a/src/core/ngx_palloc.c +++ b/src/core/ngx_palloc.c @@ -97,10 +97,21 @@ ngx_palloc(ngx_pool_t *pool, size_t size for ( ;; ) { +#if (NGX_HAVE_NONALIGNED) + + /* + * allow non-aligned memory blocks for small allocations (1, 2, + * or 3 bytes) and for odd length strings (struct's have aligned + * size) + */ + if (size < sizeof(int) || (size & 1)) { m = p->last; - } else { + } else +#endif + + { m = ngx_align_ptr(p->last, NGX_ALIGNMENT); } diff --git a/src/core/ngx_string.c b/src/core/ngx_string.c --- a/src/core/ngx_string.c +++ b/src/core/ngx_string.c @@ -1202,6 +1202,33 @@ done: } +/* ngx_sort() is implemented as insertion sort because we need stable sort */ + +void +ngx_sort(void *base, size_t n, size_t size, + int (*cmp)(const void *, const void *)) +{ + u_char *p1, *p2; + u_char buf[256]; + + for (p1 = (u_char *) base + size; + p1 < (u_char *) base + n * size; + p1 += size) + { + ngx_memcpy(buf, p1, size); + + for (p2 = p1; + p2 > (u_char *) base && cmp(p2 - size, buf) > 0; + p2 -= size) + { + ngx_memcpy(p2, p2 - size, size); + } + + ngx_memcpy(p2, buf, size); + } +} + + #if (NGX_MEMCPY_LIMIT) void * diff --git a/src/core/ngx_string.h b/src/core/ngx_string.h --- a/src/core/ngx_string.h +++ b/src/core/ngx_string.h @@ -136,25 +136,27 @@ ngx_int_t ngx_decode_base64(ngx_str_t *d uint32_t ngx_utf_decode(u_char **p, size_t n); size_t ngx_utf_length(u_char *p, size_t n); -u_char * ngx_utf_cpystrn(u_char *dst, u_char *src, size_t n); +u_char *ngx_utf_cpystrn(u_char *dst, u_char *src, size_t n); -#define NGX_ESCAPE_URI 0 -#define NGX_ESCAPE_ARGS 1 -#define NGX_ESCAPE_HTML 2 +#define NGX_ESCAPE_URI 0 +#define NGX_ESCAPE_ARGS 1 +#define NGX_ESCAPE_HTML 2 -#define NGX_UNESCAPE_URI 1 +#define NGX_UNESCAPE_URI 1 uintptr_t ngx_escape_uri(u_char *dst, u_char *src, size_t size, ngx_uint_t type); void ngx_unescape_uri(u_char **dst, u_char **src, size_t size, ngx_uint_t type); -#define ngx_qsort qsort +void ngx_sort(void *base, size_t n, size_t size, + int (*cmp)(const void *, const void *)); +#define ngx_qsort qsort -#define ngx_value_helper(n) #n -#define ngx_value(n) ngx_value_helper(n) +#define ngx_value_helper(n) #n +#define ngx_value(n) ngx_value_helper(n) #endif /* _NGX_STRING_H_INCLUDED_ */ diff --git a/src/event/ngx_event_openssl.c b/src/event/ngx_event_openssl.c --- a/src/event/ngx_event_openssl.c +++ b/src/event/ngx_event_openssl.c @@ -748,7 +748,6 @@ ngx_ssl_send_chain(ngx_connection_t *c, if (!c->ssl->buffer || (in && in->next == NULL && !(c->buffered & NGX_SSL_BUFFERED))) { - /* * we avoid a buffer copy if * we do not need to buffer the output diff --git a/src/http/modules/perl/nginx.pm b/src/http/modules/perl/nginx.pm --- a/src/http/modules/perl/nginx.pm +++ b/src/http/modules/perl/nginx.pm @@ -47,7 +47,7 @@ our @EXPORT = qw( HTTP_INSUFFICIENT_STORAGE ); -our $VERSION = '0.5.20'; +our $VERSION = '0.5.21'; require XSLoader; XSLoader::load('nginx', $VERSION); diff --git a/src/http/ngx_http.c b/src/http/ngx_http.c --- a/src/http/ngx_http.c +++ b/src/http/ngx_http.c @@ -19,8 +19,7 @@ static ngx_int_t ngx_http_add_names(ngx_ static char *ngx_http_merge_locations(ngx_conf_t *cf, ngx_array_t *locations, void **loc_conf, ngx_http_module_t *module, ngx_uint_t ctx_index); -static int ngx_libc_cdecl ngx_http_cmp_conf_in_addrs(const void *one, - const void *two); +static int ngx_http_cmp_conf_in_addrs(const void *one, const void *two); static int ngx_libc_cdecl ngx_http_cmp_dns_wildcards(const void *one, const void *two); @@ -599,8 +598,8 @@ ngx_http_block(ngx_conf_t *cf, ngx_comma in_port = in_ports.elts; for (p = 0; p < in_ports.nelts; p++) { - ngx_qsort(in_port[p].addrs.elts, (size_t) in_port[p].addrs.nelts, - sizeof(ngx_http_conf_in_addr_t), ngx_http_cmp_conf_in_addrs); + ngx_sort(in_port[p].addrs.elts, (size_t) in_port[p].addrs.nelts, + sizeof(ngx_http_conf_in_addr_t), ngx_http_cmp_conf_in_addrs); /* * check whether all name-based servers have the same configuraiton @@ -1027,7 +1026,7 @@ ngx_http_merge_locations(ngx_conf_t *cf, } -static int ngx_libc_cdecl +static int ngx_http_cmp_conf_in_addrs(const void *one, const void *two) { ngx_http_conf_in_addr_t *first, *second; diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c --- a/src/http/ngx_http_core_module.c +++ b/src/http/ngx_http_core_module.c @@ -45,8 +45,7 @@ static char *ngx_http_core_server(ngx_co void *dummy); static char *ngx_http_core_location(ngx_conf_t *cf, ngx_command_t *cmd, void *dummy); -static int ngx_libc_cdecl ngx_http_core_cmp_locations(const void *first, - const void *second); +static int ngx_http_core_cmp_locations(const void *first, const void *second); static char *ngx_http_core_types(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); @@ -1642,8 +1641,8 @@ ngx_http_core_server(ngx_conf_t *cf, ngx return rv; } - ngx_qsort(cscf->locations.elts, (size_t) cscf->locations.nelts, - sizeof(ngx_http_core_loc_conf_t *), ngx_http_core_cmp_locations); + ngx_sort(cscf->locations.elts, (size_t) cscf->locations.nelts, + sizeof(ngx_http_core_loc_conf_t *), ngx_http_core_cmp_locations); return rv; } @@ -1774,10 +1773,10 @@ ngx_http_core_location(ngx_conf_t *cf, n #if (NGX_PCRE) if (clcf->regex == NULL && ngx_strncmp(clcf->name.data, pclcf->name.data, pclcf->name.len) - != 0) + != 0) #else if (ngx_strncmp(clcf->name.data, pclcf->name.data, pclcf->name.len) - != 0) + != 0) #endif { ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, @@ -1814,14 +1813,14 @@ ngx_http_core_location(ngx_conf_t *cf, n return rv; } - ngx_qsort(clcf->locations.elts, (size_t) clcf->locations.nelts, - sizeof(ngx_http_core_loc_conf_t *), ngx_http_core_cmp_locations); + ngx_sort(clcf->locations.elts, (size_t) clcf->locations.nelts, + sizeof(ngx_http_core_loc_conf_t *), ngx_http_core_cmp_locations); return rv; } -static int ngx_libc_cdecl +static int ngx_http_core_cmp_locations(const void *one, const void *two) { ngx_int_t rc; diff --git a/src/http/ngx_http_upstream_round_robin.c b/src/http/ngx_http_upstream_round_robin.c --- a/src/http/ngx_http_upstream_round_robin.c +++ b/src/http/ngx_http_upstream_round_robin.c @@ -215,7 +215,7 @@ ngx_http_upstream_get_round_robin_peer(n rrp->current = rrp->peers->current; n = rrp->current / (8 * sizeof(uintptr_t)); - m = 1 << rrp->current % (8 * sizeof(uintptr_t)); + m = (uintptr_t) 1 << rrp->current % (8 * sizeof(uintptr_t)); if (!(rrp->tried[n] & m)) { peer = &rrp->peers->peer[rrp->current]; @@ -268,7 +268,7 @@ ngx_http_upstream_get_round_robin_peer(n } else { for ( ;; ) { n = rrp->current / (8 * sizeof(uintptr_t)); - m = 1 << rrp->current % (8 * sizeof(uintptr_t)); + m = (uintptr_t) 1 << rrp->current % (8 * sizeof(uintptr_t)); if (!(rrp->tried[n] & m)) { diff --git a/src/mail/ngx_mail.c b/src/mail/ngx_mail.c --- a/src/mail/ngx_mail.c +++ b/src/mail/ngx_mail.c @@ -11,8 +11,7 @@ static char *ngx_mail_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); -static int ngx_libc_cdecl ngx_mail_cmp_conf_in_addrs(const void *one, - const void *two); +static int ngx_mail_cmp_conf_in_addrs(const void *one, const void *two); ngx_uint_t ngx_mail_max_module; @@ -269,8 +268,8 @@ ngx_mail_block(ngx_conf_t *cf, ngx_comma in_port = in_ports.elts; for (p = 0; p < in_ports.nelts; p++) { - ngx_qsort(in_port[p].addrs.elts, (size_t) in_port[p].addrs.nelts, - sizeof(ngx_mail_conf_in_addr_t), ngx_mail_cmp_conf_in_addrs); + ngx_sort(in_port[p].addrs.elts, (size_t) in_port[p].addrs.nelts, + sizeof(ngx_mail_conf_in_addr_t), ngx_mail_cmp_conf_in_addrs); in_addr = in_port[p].addrs.elts; last = in_port[p].addrs.nelts; @@ -387,7 +386,7 @@ ngx_mail_block(ngx_conf_t *cf, ngx_comma } -static int ngx_libc_cdecl +static int ngx_mail_cmp_conf_in_addrs(const void *one, const void *two) { ngx_mail_conf_in_addr_t *first, *second;