Mercurial > hg > nginx
comparison src/core/ngx_hash.c @ 2168:80924319ba05
fix the case when unset domain.tld was matched by *.domain.tld
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Tue, 12 Aug 2008 15:28:19 +0000 |
parents | febb71974a35 |
children | a953f73273ee |
comparison
equal
deleted
inserted
replaced
2167:2cdefc40cabd | 2168:80924319ba05 |
---|---|
86 | 86 |
87 if (value) { | 87 if (value) { |
88 | 88 |
89 /* | 89 /* |
90 * the 2 low bits of value have the special meaning: | 90 * the 2 low bits of value have the special meaning: |
91 * 00 - value is data pointer, | 91 * 00 - value is data pointer for both "example.com" |
92 * 01 - value is pointer to wildcard hash allowing | 92 * and "*.example.com"; |
93 * "*.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"; | |
94 * 11 - value is pointer to wildcard hash allowing | 96 * 11 - value is pointer to wildcard hash allowing |
95 * both "example.com" and "*.example.com". | 97 * "*.example.com" only. |
96 */ | 98 */ |
97 | 99 |
98 if ((uintptr_t) value & 1) { | 100 if ((uintptr_t) value & 2) { |
99 | |
100 hwc = (ngx_hash_wildcard_t *) ((uintptr_t) value & (uintptr_t) ~3); | |
101 | 101 |
102 if (n == 0) { | 102 if (n == 0) { |
103 if ((uintptr_t) value & 2) { | 103 |
104 return hwc->value; | 104 /* "example.com" */ |
105 | 105 |
106 } else { | 106 if ((uintptr_t) value & 1) { |
107 return NULL; | 107 return NULL; |
108 } | 108 } |
109 } | 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); | |
110 | 116 |
111 value = ngx_hash_find_wc_head(hwc, name, n - 1); | 117 value = ngx_hash_find_wc_head(hwc, name, n - 1); |
112 | 118 |
113 if (value) { | 119 if (value) { |
114 return value; | 120 return value; |
115 } | 121 } |
116 | 122 |
117 return hwc->value; | 123 return hwc->value; |
124 } | |
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); | |
118 } | 136 } |
119 | 137 |
120 return value; | 138 return value; |
121 } | 139 } |
122 | 140 |
160 | 178 |
161 if (value) { | 179 if (value) { |
162 | 180 |
163 /* | 181 /* |
164 * the 2 low bits of value have the special meaning: | 182 * the 2 low bits of value have the special meaning: |
165 * 00 - value is data pointer, | 183 * 00 - value is data pointer; |
166 * 01 - value is pointer to wildcard hash allowing "example.*". | 184 * 11 - value is pointer to wildcard hash allowing "example.*". |
167 */ | 185 */ |
168 | 186 |
169 if ((uintptr_t) value & 1) { | 187 if ((uintptr_t) value & 2) { |
170 | 188 |
171 i++; | 189 i++; |
172 | 190 |
173 hwc = (ngx_hash_wildcard_t *) ((uintptr_t) value & (uintptr_t) ~3); | 191 hwc = (ngx_hash_wildcard_t *) ((uintptr_t) value & (uintptr_t) ~3); |
174 | 192 |
565 | 583 |
566 if (names[n].key.len == len) { | 584 if (names[n].key.len == len) { |
567 wdc->value = names[n].value; | 585 wdc->value = names[n].value; |
568 } | 586 } |
569 | 587 |
570 name->value = (void *) ((uintptr_t) wdc | (dot ? 1 : 3)); | 588 name->value = (void *) ((uintptr_t) wdc | (dot ? 3 : 1)); |
589 | |
590 } else if (dot) { | |
591 name->value = (void *) ((uintptr_t) name->value | 1); | |
571 } | 592 } |
572 } | 593 } |
573 | 594 |
574 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, |
575 curr_names.nelts) | 596 curr_names.nelts) |