Mercurial > hg > nginx-ranges
comparison 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 |
comparison
equal
deleted
inserted
replaced
395:040b8c84d040 | 397:05981f639d21 |
---|---|
13 { | 13 { |
14 ngx_uint_t i; | 14 ngx_uint_t i; |
15 ngx_hash_elt_t *elt; | 15 ngx_hash_elt_t *elt; |
16 | 16 |
17 #if 0 | 17 #if 0 |
18 ngx_str_t line; | 18 ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, 0, "hf:\"%*s\"", len, name); |
19 | |
20 line.len = len; | |
21 line.data = name; | |
22 ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, 0, "hf:\"%V\"", &line); | |
23 #endif | 19 #endif |
24 | 20 |
25 elt = hash->buckets[key % hash->size]; | 21 elt = hash->buckets[key % hash->size]; |
26 | 22 |
27 if (elt == NULL) { | 23 if (elt == NULL) { |
57 { | 53 { |
58 void *value; | 54 void *value; |
59 ngx_uint_t i, n, key; | 55 ngx_uint_t i, n, key; |
60 | 56 |
61 #if 0 | 57 #if 0 |
62 ngx_str_t line; | 58 ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, 0, "wch:\"%*s\"", len, name); |
63 | |
64 line.len = len; | |
65 line.data = name; | |
66 ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, 0, "wch:\"%V\"", &line); | |
67 #endif | 59 #endif |
68 | 60 |
69 n = len; | 61 n = len; |
70 | 62 |
71 while (n) { | 63 while (n) { |
86 ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, 0, "key:\"%ui\"", key); | 78 ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, 0, "key:\"%ui\"", key); |
87 #endif | 79 #endif |
88 | 80 |
89 value = ngx_hash_find(&hwc->hash, key, &name[n], len - n); | 81 value = ngx_hash_find(&hwc->hash, key, &name[n], len - n); |
90 | 82 |
83 #if 0 | |
84 ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, 0, "value:\"%p\"", value); | |
85 #endif | |
86 | |
91 if (value) { | 87 if (value) { |
92 | 88 |
93 /* | 89 /* |
94 * the 2 low bits of value have the special meaning: | 90 * the 2 low bits of value have the special meaning: |
95 * 00 - value is data pointer, | 91 * 00 - value is data pointer for both "example.com" |
96 * 01 - value is pointer to wildcard hash allowing | 92 * and "*.example.com"; |
97 * "*.example.com" only, | 93 * 01 - value is data pointer for "*.example.com" only; |
94 * 10 - value is pointer to wildcard hash allowing | |
95 * both "example.com" and "*.example.com"; | |
98 * 11 - value is pointer to wildcard hash allowing | 96 * 11 - value is pointer to wildcard hash allowing |
99 * both "example.com" and "*.example.com". | 97 * "*.example.com" only. |
100 */ | 98 */ |
101 | 99 |
102 if ((uintptr_t) value & 1) { | 100 if ((uintptr_t) value & 2) { |
103 | |
104 hwc = (ngx_hash_wildcard_t *) ((uintptr_t) value & (uintptr_t) ~3); | |
105 | 101 |
106 if (n == 0) { | 102 if (n == 0) { |
107 if ((uintptr_t) value & 2) { | 103 |
108 return hwc->value; | 104 /* "example.com" */ |
109 | 105 |
110 } else { | 106 if ((uintptr_t) value & 1) { |
111 return NULL; | 107 return NULL; |
112 } | 108 } |
113 } | 109 |
110 hwc = (ngx_hash_wildcard_t *) | |
111 ((uintptr_t) value & (uintptr_t) ~3); | |
112 return hwc->value; | |
113 } | |
114 | |
115 hwc = (ngx_hash_wildcard_t *) ((uintptr_t) value & (uintptr_t) ~3); | |
114 | 116 |
115 value = ngx_hash_find_wc_head(hwc, name, n - 1); | 117 value = ngx_hash_find_wc_head(hwc, name, n - 1); |
116 | 118 |
117 if (value) { | 119 if (value) { |
118 return value; | 120 return value; |
119 } | 121 } |
120 | 122 |
121 return hwc->value; | 123 return hwc->value; |
122 } | 124 } |
123 | 125 |
126 if ((uintptr_t) value & 1) { | |
127 | |
128 if (n == 0) { | |
129 | |
130 /* "example.com" */ | |
131 | |
132 return NULL; | |
133 } | |
134 | |
135 return (void *) ((uintptr_t) value & (uintptr_t) ~3); | |
136 } | |
137 | |
124 return value; | 138 return value; |
125 } | 139 } |
126 | 140 |
127 return hwc->value; | 141 return hwc->value; |
128 } | 142 } |
133 { | 147 { |
134 void *value; | 148 void *value; |
135 ngx_uint_t i, key; | 149 ngx_uint_t i, key; |
136 | 150 |
137 #if 0 | 151 #if 0 |
138 ngx_str_t line; | 152 ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, 0, "wct:\"%*s\"", len, name); |
139 | |
140 line.len = len; | |
141 line.data = name; | |
142 ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, 0, "wct:\"%V\"", &line); | |
143 #endif | 153 #endif |
144 | 154 |
145 key = 0; | 155 key = 0; |
146 | 156 |
147 for (i = 0; i < len; i++) { | 157 for (i = 0; i < len; i++) { |
160 ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, 0, "key:\"%ui\"", key); | 170 ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, 0, "key:\"%ui\"", key); |
161 #endif | 171 #endif |
162 | 172 |
163 value = ngx_hash_find(&hwc->hash, key, name, i); | 173 value = ngx_hash_find(&hwc->hash, key, name, i); |
164 | 174 |
175 #if 0 | |
176 ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, 0, "value:\"%p\"", value); | |
177 #endif | |
178 | |
165 if (value) { | 179 if (value) { |
166 | 180 |
167 /* | 181 /* |
168 * the 2 low bits of value have the special meaning: | 182 * the 2 low bits of value have the special meaning: |
169 * 00 - value is data pointer, | 183 * 00 - value is data pointer; |
170 * 01 - value is pointer to wildcard hash allowing "example.*". | 184 * 11 - value is pointer to wildcard hash allowing "example.*". |
171 */ | 185 */ |
172 | 186 |
173 if ((uintptr_t) value & 1) { | 187 if ((uintptr_t) value & 2) { |
174 | 188 |
175 i++; | 189 i++; |
176 | 190 |
177 hwc = (ngx_hash_wildcard_t *) ((uintptr_t) value & (uintptr_t) ~3); | 191 hwc = (ngx_hash_wildcard_t *) ((uintptr_t) value & (uintptr_t) ~3); |
178 | 192 |
567 | 581 |
568 wdc = (ngx_hash_wildcard_t *) h.hash; | 582 wdc = (ngx_hash_wildcard_t *) h.hash; |
569 | 583 |
570 if (names[n].key.len == len) { | 584 if (names[n].key.len == len) { |
571 wdc->value = names[n].value; | 585 wdc->value = names[n].value; |
572 #if 0 | 586 } |
573 ngx_log_error(NGX_LOG_ALERT, hinit->pool->log, 0, | 587 |
574 "wdc: \"%V\"", wdc->value); | 588 name->value = (void *) ((uintptr_t) wdc | (dot ? 3 : 1)); |
575 #endif | 589 |
576 } | 590 } else if (dot) { |
577 | 591 name->value = (void *) ((uintptr_t) name->value | 1); |
578 name->value = (void *) ((uintptr_t) wdc | (dot ? 1 : 3)); | |
579 } | 592 } |
580 } | 593 } |
581 | 594 |
582 if (ngx_hash_init(hinit, (ngx_hash_key_t *) curr_names.elts, | 595 if (ngx_hash_init(hinit, (ngx_hash_key_t *) curr_names.elts, |
583 curr_names.nelts) | 596 curr_names.nelts) |