Mercurial > hg > nginx-ranges
diff src/core/ngx_hash.c @ 397:05981f639d21 NGINX_0_7_9
nginx 0.7.9
*) Change: now ngx_http_charset_module works by default with following
MIME types: text/html, text/css, text/xml, text/plain,
text/vnd.wap.wml, application/x-javascript, and application/rss+xml.
*) Feature: the "charset_types" and "addition_types" directives.
*) Feature: now the "gzip_types", "ssi_types", and "sub_filter_types"
directives use hash.
*) Feature: the ngx_cpp_test_module.
*) Feature: the "expires" directive supports daily time.
*) Feature: the ngx_http_xslt_module improvements and bug fixing.
Thanks to Denis F. Latypoff and Maxim Dounin.
*) Bugfix: the "log_not_found" directive did not work for index files
tests.
*) Bugfix: HTTPS connections might hang, if kqueue, epoll, rtsig, or
eventport methods were used; the bug had appeared in 0.7.7.
*) Bugfix: if the "server_name", "valid_referers", and "map" directives
used an "*.domain.tld" wildcard and exact name "domain.tld" was not
set, then the exact name was matched by the wildcard; the bugs had
appeared in 0.3.18.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Tue, 12 Aug 2008 00:00:00 +0400 |
parents | 34fb3a573548 |
children | 6ebbca3d5ed7 |
line wrap: on
line diff
--- a/src/core/ngx_hash.c +++ b/src/core/ngx_hash.c @@ -15,11 +15,7 @@ ngx_hash_find(ngx_hash_t *hash, ngx_uint ngx_hash_elt_t *elt; #if 0 - ngx_str_t line; - - line.len = len; - line.data = name; - ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, 0, "hf:\"%V\"", &line); + ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, 0, "hf:\"%*s\"", len, name); #endif elt = hash->buckets[key % hash->size]; @@ -59,11 +55,7 @@ ngx_hash_find_wc_head(ngx_hash_wildcard_ ngx_uint_t i, n, key; #if 0 - ngx_str_t line; - - line.len = len; - line.data = name; - ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, 0, "wch:\"%V\"", &line); + ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, 0, "wch:\"%*s\"", len, name); #endif n = len; @@ -88,30 +80,40 @@ ngx_hash_find_wc_head(ngx_hash_wildcard_ value = ngx_hash_find(&hwc->hash, key, &name[n], len - n); +#if 0 + ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, 0, "value:\"%p\"", value); +#endif + if (value) { /* * the 2 low bits of value have the special meaning: - * 00 - value is data pointer, - * 01 - value is pointer to wildcard hash allowing - * "*.example.com" only, + * 00 - value is data pointer for both "example.com" + * and "*.example.com"; + * 01 - value is data pointer for "*.example.com" only; + * 10 - value is pointer to wildcard hash allowing + * both "example.com" and "*.example.com"; * 11 - value is pointer to wildcard hash allowing - * both "example.com" and "*.example.com". + * "*.example.com" only. */ - if ((uintptr_t) value & 1) { + if ((uintptr_t) value & 2) { + + if (n == 0) { + + /* "example.com" */ + + if ((uintptr_t) value & 1) { + return NULL; + } + + hwc = (ngx_hash_wildcard_t *) + ((uintptr_t) value & (uintptr_t) ~3); + return hwc->value; + } hwc = (ngx_hash_wildcard_t *) ((uintptr_t) value & (uintptr_t) ~3); - if (n == 0) { - if ((uintptr_t) value & 2) { - return hwc->value; - - } else { - return NULL; - } - } - value = ngx_hash_find_wc_head(hwc, name, n - 1); if (value) { @@ -121,6 +123,18 @@ ngx_hash_find_wc_head(ngx_hash_wildcard_ return hwc->value; } + if ((uintptr_t) value & 1) { + + if (n == 0) { + + /* "example.com" */ + + return NULL; + } + + return (void *) ((uintptr_t) value & (uintptr_t) ~3); + } + return value; } @@ -135,11 +149,7 @@ ngx_hash_find_wc_tail(ngx_hash_wildcard_ ngx_uint_t i, key; #if 0 - ngx_str_t line; - - line.len = len; - line.data = name; - ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, 0, "wct:\"%V\"", &line); + ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, 0, "wct:\"%*s\"", len, name); #endif key = 0; @@ -162,15 +172,19 @@ ngx_hash_find_wc_tail(ngx_hash_wildcard_ value = ngx_hash_find(&hwc->hash, key, name, i); +#if 0 + ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, 0, "value:\"%p\"", value); +#endif + if (value) { /* * the 2 low bits of value have the special meaning: - * 00 - value is data pointer, - * 01 - value is pointer to wildcard hash allowing "example.*". + * 00 - value is data pointer; + * 11 - value is pointer to wildcard hash allowing "example.*". */ - if ((uintptr_t) value & 1) { + if ((uintptr_t) value & 2) { i++; @@ -569,13 +583,12 @@ ngx_hash_wildcard_init(ngx_hash_init_t * if (names[n].key.len == len) { wdc->value = names[n].value; -#if 0 - ngx_log_error(NGX_LOG_ALERT, hinit->pool->log, 0, - "wdc: \"%V\"", wdc->value); -#endif } - name->value = (void *) ((uintptr_t) wdc | (dot ? 1 : 3)); + name->value = (void *) ((uintptr_t) wdc | (dot ? 3 : 1)); + + } else if (dot) { + name->value = (void *) ((uintptr_t) name->value | 1); } }