2005-04-08 23:18:55 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (C) Igor Sysoev
|
2012-01-18 23:07:43 +08:00
|
|
|
* Copyright (C) Nginx, Inc.
|
2005-04-08 23:18:55 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include <ngx_config.h>
|
|
|
|
#include <ngx_core.h>
|
|
|
|
|
|
|
|
|
2005-12-16 23:07:08 +08:00
|
|
|
void *
|
|
|
|
ngx_hash_find(ngx_hash_t *hash, ngx_uint_t key, u_char *name, size_t len)
|
|
|
|
{
|
|
|
|
ngx_uint_t i;
|
|
|
|
ngx_hash_elt_t *elt;
|
|
|
|
|
|
|
|
#if 0
|
2008-08-05 23:19:21 +08:00
|
|
|
ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, 0, "hf:\"%*s\"", len, name);
|
2005-12-16 23:07:08 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
elt = hash->buckets[key % hash->size];
|
|
|
|
|
|
|
|
if (elt == NULL) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (elt->value) {
|
|
|
|
if (len != (size_t) elt->len) {
|
|
|
|
goto next;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < len; i++) {
|
|
|
|
if (name[i] != elt->name[i]) {
|
|
|
|
goto next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return elt->value;
|
|
|
|
|
|
|
|
next:
|
|
|
|
|
|
|
|
elt = (ngx_hash_elt_t *) ngx_align_ptr(&elt->name[0] + elt->len,
|
|
|
|
sizeof(void *));
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void *
|
2007-06-12 03:49:22 +08:00
|
|
|
ngx_hash_find_wc_head(ngx_hash_wildcard_t *hwc, u_char *name, size_t len)
|
2005-12-16 23:07:08 +08:00
|
|
|
{
|
|
|
|
void *value;
|
|
|
|
ngx_uint_t i, n, key;
|
|
|
|
|
|
|
|
#if 0
|
2008-08-05 23:19:21 +08:00
|
|
|
ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, 0, "wch:\"%*s\"", len, name);
|
2005-12-16 23:07:08 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
n = len;
|
|
|
|
|
|
|
|
while (n) {
|
|
|
|
if (name[n - 1] == '.') {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
n--;
|
|
|
|
}
|
|
|
|
|
|
|
|
key = 0;
|
|
|
|
|
|
|
|
for (i = n; i < len; i++) {
|
|
|
|
key = ngx_hash(key, name[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, 0, "key:\"%ui\"", key);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
value = ngx_hash_find(&hwc->hash, key, &name[n], len - n);
|
|
|
|
|
2008-08-05 05:51:36 +08:00
|
|
|
#if 0
|
|
|
|
ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, 0, "value:\"%p\"", value);
|
|
|
|
#endif
|
|
|
|
|
2005-12-16 23:07:08 +08:00
|
|
|
if (value) {
|
2005-12-19 00:02:44 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* the 2 low bits of value have the special meaning:
|
2008-08-12 23:28:19 +08:00
|
|
|
* 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";
|
2005-12-19 00:02:44 +08:00
|
|
|
* 11 - value is pointer to wildcard hash allowing
|
2008-08-12 23:28:19 +08:00
|
|
|
* "*.example.com" only.
|
2005-12-19 00:02:44 +08:00
|
|
|
*/
|
|
|
|
|
2008-08-12 23:28:19 +08:00
|
|
|
if ((uintptr_t) value & 2) {
|
2005-12-19 00:02:44 +08:00
|
|
|
|
|
|
|
if (n == 0) {
|
|
|
|
|
2008-08-12 23:28:19 +08:00
|
|
|
/* "example.com" */
|
|
|
|
|
|
|
|
if ((uintptr_t) value & 1) {
|
2005-12-19 00:02:44 +08:00
|
|
|
return NULL;
|
|
|
|
}
|
2008-08-12 23:28:19 +08:00
|
|
|
|
|
|
|
hwc = (ngx_hash_wildcard_t *)
|
|
|
|
((uintptr_t) value & (uintptr_t) ~3);
|
|
|
|
return hwc->value;
|
2005-12-19 00:02:44 +08:00
|
|
|
}
|
2005-12-16 23:07:08 +08:00
|
|
|
|
2008-08-12 23:28:19 +08:00
|
|
|
hwc = (ngx_hash_wildcard_t *) ((uintptr_t) value & (uintptr_t) ~3);
|
|
|
|
|
2007-06-12 03:49:22 +08:00
|
|
|
value = ngx_hash_find_wc_head(hwc, name, n - 1);
|
2005-12-16 23:07:08 +08:00
|
|
|
|
|
|
|
if (value) {
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
return hwc->value;
|
|
|
|
}
|
|
|
|
|
2008-08-12 23:28:19 +08:00
|
|
|
if ((uintptr_t) value & 1) {
|
|
|
|
|
|
|
|
if (n == 0) {
|
|
|
|
|
|
|
|
/* "example.com" */
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (void *) ((uintptr_t) value & (uintptr_t) ~3);
|
|
|
|
}
|
|
|
|
|
2005-12-16 23:07:08 +08:00
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
return hwc->value;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-06-12 03:49:22 +08:00
|
|
|
void *
|
|
|
|
ngx_hash_find_wc_tail(ngx_hash_wildcard_t *hwc, u_char *name, size_t len)
|
|
|
|
{
|
|
|
|
void *value;
|
|
|
|
ngx_uint_t i, key;
|
|
|
|
|
|
|
|
#if 0
|
2008-08-05 23:19:21 +08:00
|
|
|
ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, 0, "wct:\"%*s\"", len, name);
|
2007-06-12 03:49:22 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
key = 0;
|
|
|
|
|
|
|
|
for (i = 0; i < len; i++) {
|
|
|
|
if (name[i] == '.') {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
key = ngx_hash(key, name[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (i == len) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, 0, "key:\"%ui\"", key);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
value = ngx_hash_find(&hwc->hash, key, name, i);
|
|
|
|
|
2008-08-05 23:19:21 +08:00
|
|
|
#if 0
|
|
|
|
ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, 0, "value:\"%p\"", value);
|
|
|
|
#endif
|
|
|
|
|
2007-06-12 03:49:22 +08:00
|
|
|
if (value) {
|
|
|
|
|
|
|
|
/*
|
|
|
|
* the 2 low bits of value have the special meaning:
|
2008-08-12 23:28:19 +08:00
|
|
|
* 00 - value is data pointer;
|
|
|
|
* 11 - value is pointer to wildcard hash allowing "example.*".
|
2007-06-12 03:49:22 +08:00
|
|
|
*/
|
|
|
|
|
2008-08-12 23:28:19 +08:00
|
|
|
if ((uintptr_t) value & 2) {
|
2007-06-12 03:49:22 +08:00
|
|
|
|
|
|
|
i++;
|
|
|
|
|
|
|
|
hwc = (ngx_hash_wildcard_t *) ((uintptr_t) value & (uintptr_t) ~3);
|
|
|
|
|
|
|
|
value = ngx_hash_find_wc_tail(hwc, &name[i], len - i);
|
|
|
|
|
|
|
|
if (value) {
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
return hwc->value;
|
|
|
|
}
|
|
|
|
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
return hwc->value;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void *
|
|
|
|
ngx_hash_find_combined(ngx_hash_combined_t *hash, ngx_uint_t key, u_char *name,
|
|
|
|
size_t len)
|
|
|
|
{
|
|
|
|
void *value;
|
|
|
|
|
|
|
|
if (hash->hash.buckets) {
|
|
|
|
value = ngx_hash_find(&hash->hash, key, name, len);
|
|
|
|
|
|
|
|
if (value) {
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-08-21 20:56:10 +08:00
|
|
|
if (len == 0) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2007-06-12 03:49:22 +08:00
|
|
|
if (hash->wc_head && hash->wc_head->hash.buckets) {
|
|
|
|
value = ngx_hash_find_wc_head(hash->wc_head, name, len);
|
|
|
|
|
|
|
|
if (value) {
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (hash->wc_tail && hash->wc_tail->hash.buckets) {
|
|
|
|
value = ngx_hash_find_wc_tail(hash->wc_tail, name, len);
|
|
|
|
|
|
|
|
if (value) {
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-12-16 23:07:08 +08:00
|
|
|
#define NGX_HASH_ELT_SIZE(name) \
|
2010-05-13 20:52:45 +08:00
|
|
|
(sizeof(void *) + ngx_align((name)->key.len + 2, sizeof(void *)))
|
2005-12-16 23:07:08 +08:00
|
|
|
|
|
|
|
ngx_int_t
|
|
|
|
ngx_hash_init(ngx_hash_init_t *hinit, ngx_hash_key_t *names, ngx_uint_t nelts)
|
|
|
|
{
|
|
|
|
u_char *elts;
|
2005-12-28 22:23:52 +08:00
|
|
|
size_t len;
|
|
|
|
u_short *test;
|
2005-12-16 23:07:08 +08:00
|
|
|
ngx_uint_t i, n, key, size, start, bucket_size;
|
|
|
|
ngx_hash_elt_t *elt, **buckets;
|
|
|
|
|
|
|
|
for (n = 0; n < nelts; n++) {
|
|
|
|
if (hinit->bucket_size < NGX_HASH_ELT_SIZE(&names[n]) + sizeof(void *))
|
|
|
|
{
|
|
|
|
ngx_log_error(NGX_LOG_EMERG, hinit->pool->log, 0,
|
2005-12-28 22:23:52 +08:00
|
|
|
"could not build the %s, you should "
|
2005-12-16 23:07:08 +08:00
|
|
|
"increase %s_bucket_size: %i",
|
|
|
|
hinit->name, hinit->name, hinit->bucket_size);
|
|
|
|
return NGX_ERROR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-12-28 22:23:52 +08:00
|
|
|
test = ngx_alloc(hinit->max_size * sizeof(u_short), hinit->pool->log);
|
2005-12-16 23:07:08 +08:00
|
|
|
if (test == NULL) {
|
|
|
|
return NGX_ERROR;
|
|
|
|
}
|
|
|
|
|
2006-04-07 22:08:04 +08:00
|
|
|
bucket_size = hinit->bucket_size - sizeof(void *);
|
|
|
|
|
2006-10-06 21:28:19 +08:00
|
|
|
start = nelts / (bucket_size / (2 * sizeof(void *)));
|
2005-12-16 23:07:08 +08:00
|
|
|
start = start ? start : 1;
|
|
|
|
|
2012-01-16 20:42:07 +08:00
|
|
|
if (hinit->max_size > 10000 && nelts && hinit->max_size / nelts < 100) {
|
2006-04-07 22:08:04 +08:00
|
|
|
start = hinit->max_size - 1000;
|
|
|
|
}
|
2005-12-16 23:07:08 +08:00
|
|
|
|
2014-04-01 01:40:35 +08:00
|
|
|
for (size = start; size <= hinit->max_size; size++) {
|
2005-12-16 23:07:08 +08:00
|
|
|
|
2005-12-28 22:23:52 +08:00
|
|
|
ngx_memzero(test, size * sizeof(u_short));
|
2005-12-16 23:07:08 +08:00
|
|
|
|
|
|
|
for (n = 0; n < nelts; n++) {
|
|
|
|
if (names[n].key.data == NULL) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
key = names[n].key_hash % size;
|
2005-12-28 22:23:52 +08:00
|
|
|
test[key] = (u_short) (test[key] + NGX_HASH_ELT_SIZE(&names[n]));
|
2005-12-16 23:07:08 +08:00
|
|
|
|
|
|
|
#if 0
|
|
|
|
ngx_log_error(NGX_LOG_ALERT, hinit->pool->log, 0,
|
|
|
|
"%ui: %ui %ui \"%V\"",
|
|
|
|
size, key, test[key], &names[n].key);
|
|
|
|
#endif
|
|
|
|
|
2005-12-28 22:23:52 +08:00
|
|
|
if (test[key] > (u_short) bucket_size) {
|
2005-12-16 23:07:08 +08:00
|
|
|
goto next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
goto found;
|
|
|
|
|
|
|
|
next:
|
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2014-10-03 03:00:17 +08:00
|
|
|
size--;
|
|
|
|
|
2014-04-01 01:40:31 +08:00
|
|
|
ngx_log_error(NGX_LOG_WARN, hinit->pool->log, 0,
|
|
|
|
"could not build optimal %s, you should increase "
|
|
|
|
"either %s_max_size: %i or %s_bucket_size: %i; "
|
|
|
|
"ignoring %s_bucket_size",
|
2005-12-16 23:07:08 +08:00
|
|
|
hinit->name, hinit->name, hinit->max_size,
|
2014-04-01 01:40:31 +08:00
|
|
|
hinit->name, hinit->bucket_size, hinit->name);
|
2005-12-16 23:07:08 +08:00
|
|
|
|
|
|
|
found:
|
|
|
|
|
|
|
|
for (i = 0; i < size; i++) {
|
|
|
|
test[i] = sizeof(void *);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (n = 0; n < nelts; n++) {
|
|
|
|
if (names[n].key.data == NULL) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
key = names[n].key_hash % size;
|
2005-12-28 22:23:52 +08:00
|
|
|
test[key] = (u_short) (test[key] + NGX_HASH_ELT_SIZE(&names[n]));
|
2005-12-16 23:07:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
len = 0;
|
|
|
|
|
|
|
|
for (i = 0; i < size; i++) {
|
|
|
|
if (test[i] == sizeof(void *)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2005-12-28 22:23:52 +08:00
|
|
|
test[i] = (u_short) (ngx_align(test[i], ngx_cacheline_size));
|
2005-12-16 23:07:08 +08:00
|
|
|
|
|
|
|
len += test[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (hinit->hash == NULL) {
|
|
|
|
hinit->hash = ngx_pcalloc(hinit->pool, sizeof(ngx_hash_wildcard_t)
|
|
|
|
+ size * sizeof(ngx_hash_elt_t *));
|
|
|
|
if (hinit->hash == NULL) {
|
|
|
|
ngx_free(test);
|
|
|
|
return NGX_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
buckets = (ngx_hash_elt_t **)
|
|
|
|
((u_char *) hinit->hash + sizeof(ngx_hash_wildcard_t));
|
|
|
|
|
|
|
|
} else {
|
|
|
|
buckets = ngx_pcalloc(hinit->pool, size * sizeof(ngx_hash_elt_t *));
|
|
|
|
if (buckets == NULL) {
|
|
|
|
ngx_free(test);
|
|
|
|
return NGX_ERROR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
elts = ngx_palloc(hinit->pool, len + ngx_cacheline_size);
|
|
|
|
if (elts == NULL) {
|
|
|
|
ngx_free(test);
|
|
|
|
return NGX_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
elts = ngx_align_ptr(elts, ngx_cacheline_size);
|
|
|
|
|
|
|
|
for (i = 0; i < size; i++) {
|
|
|
|
if (test[i] == sizeof(void *)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
buckets[i] = (ngx_hash_elt_t *) elts;
|
|
|
|
elts += test[i];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < size; i++) {
|
|
|
|
test[i] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (n = 0; n < nelts; n++) {
|
|
|
|
if (names[n].key.data == NULL) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
key = names[n].key_hash % size;
|
|
|
|
elt = (ngx_hash_elt_t *) ((u_char *) buckets[key] + test[key]);
|
|
|
|
|
|
|
|
elt->value = names[n].value;
|
2010-05-13 20:52:45 +08:00
|
|
|
elt->len = (u_short) names[n].key.len;
|
2005-12-16 23:07:08 +08:00
|
|
|
|
2008-08-04 18:07:00 +08:00
|
|
|
ngx_strlow(elt->name, names[n].key.data, names[n].key.len);
|
2005-12-16 23:07:08 +08:00
|
|
|
|
2005-12-28 22:23:52 +08:00
|
|
|
test[key] = (u_short) (test[key] + NGX_HASH_ELT_SIZE(&names[n]));
|
2005-12-16 23:07:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < size; i++) {
|
|
|
|
if (buckets[i] == NULL) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
elt = (ngx_hash_elt_t *) ((u_char *) buckets[i] + test[i]);
|
|
|
|
|
|
|
|
elt->value = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
ngx_free(test);
|
|
|
|
|
|
|
|
hinit->hash->buckets = buckets;
|
|
|
|
hinit->hash->size = size;
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
|
|
|
|
for (i = 0; i < size; i++) {
|
|
|
|
ngx_str_t val;
|
|
|
|
ngx_uint_t key;
|
|
|
|
|
|
|
|
elt = buckets[i];
|
|
|
|
|
|
|
|
if (elt == NULL) {
|
|
|
|
ngx_log_error(NGX_LOG_ALERT, hinit->pool->log, 0,
|
|
|
|
"%ui: NULL", i);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (elt->value) {
|
|
|
|
val.len = elt->len;
|
|
|
|
val.data = &elt->name[0];
|
|
|
|
|
|
|
|
key = hinit->key(val.data, val.len);
|
|
|
|
|
|
|
|
ngx_log_error(NGX_LOG_ALERT, hinit->pool->log, 0,
|
|
|
|
"%ui: %p \"%V\" %ui", i, elt, &val, key);
|
|
|
|
|
|
|
|
elt = (ngx_hash_elt_t *) ngx_align_ptr(&elt->name[0] + elt->len,
|
|
|
|
sizeof(void *));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return NGX_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ngx_int_t
|
|
|
|
ngx_hash_wildcard_init(ngx_hash_init_t *hinit, ngx_hash_key_t *names,
|
|
|
|
ngx_uint_t nelts)
|
|
|
|
{
|
2005-12-27 01:07:48 +08:00
|
|
|
size_t len, dot_len;
|
2005-12-19 00:02:44 +08:00
|
|
|
ngx_uint_t i, n, dot;
|
2005-12-16 23:07:08 +08:00
|
|
|
ngx_array_t curr_names, next_names;
|
|
|
|
ngx_hash_key_t *name, *next_name;
|
|
|
|
ngx_hash_init_t h;
|
|
|
|
ngx_hash_wildcard_t *wdc;
|
|
|
|
|
|
|
|
if (ngx_array_init(&curr_names, hinit->temp_pool, nelts,
|
|
|
|
sizeof(ngx_hash_key_t))
|
|
|
|
!= NGX_OK)
|
|
|
|
{
|
|
|
|
return NGX_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ngx_array_init(&next_names, hinit->temp_pool, nelts,
|
|
|
|
sizeof(ngx_hash_key_t))
|
|
|
|
!= NGX_OK)
|
|
|
|
{
|
|
|
|
return NGX_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (n = 0; n < nelts; n = i) {
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
ngx_log_error(NGX_LOG_ALERT, hinit->pool->log, 0,
|
|
|
|
"wc0: \"%V\"", &names[n].key);
|
|
|
|
#endif
|
|
|
|
|
2005-12-19 00:02:44 +08:00
|
|
|
dot = 0;
|
|
|
|
|
2005-12-16 23:07:08 +08:00
|
|
|
for (len = 0; len < names[n].key.len; len++) {
|
|
|
|
if (names[n].key.data[len] == '.') {
|
2005-12-19 00:02:44 +08:00
|
|
|
dot = 1;
|
2005-12-16 23:07:08 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
name = ngx_array_push(&curr_names);
|
|
|
|
if (name == NULL) {
|
|
|
|
return NGX_ERROR;
|
|
|
|
}
|
|
|
|
|
2005-12-19 00:02:44 +08:00
|
|
|
name->key.len = len;
|
2005-12-16 23:07:08 +08:00
|
|
|
name->key.data = names[n].key.data;
|
|
|
|
name->key_hash = hinit->key(name->key.data, name->key.len);
|
|
|
|
name->value = names[n].value;
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
ngx_log_error(NGX_LOG_ALERT, hinit->pool->log, 0,
|
2005-12-27 01:07:48 +08:00
|
|
|
"wc1: \"%V\" %ui", &name->key, dot);
|
2005-12-16 23:07:08 +08:00
|
|
|
#endif
|
|
|
|
|
2005-12-27 01:07:48 +08:00
|
|
|
dot_len = len + 1;
|
|
|
|
|
2005-12-19 00:02:44 +08:00
|
|
|
if (dot) {
|
|
|
|
len++;
|
|
|
|
}
|
|
|
|
|
2005-12-16 23:07:08 +08:00
|
|
|
next_names.nelts = 0;
|
|
|
|
|
|
|
|
if (names[n].key.len != len) {
|
|
|
|
next_name = ngx_array_push(&next_names);
|
|
|
|
if (next_name == NULL) {
|
|
|
|
return NGX_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
next_name->key.len = names[n].key.len - len;
|
|
|
|
next_name->key.data = names[n].key.data + len;
|
2009-09-13 14:25:54 +08:00
|
|
|
next_name->key_hash = 0;
|
2005-12-16 23:07:08 +08:00
|
|
|
next_name->value = names[n].value;
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
ngx_log_error(NGX_LOG_ALERT, hinit->pool->log, 0,
|
|
|
|
"wc2: \"%V\"", &next_name->key);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = n + 1; i < nelts; i++) {
|
|
|
|
if (ngx_strncmp(names[n].key.data, names[i].key.data, len) != 0) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2005-12-27 01:07:48 +08:00
|
|
|
if (!dot
|
|
|
|
&& names[i].key.len > len
|
|
|
|
&& names[i].key.data[len] != '.')
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2005-12-16 23:07:08 +08:00
|
|
|
next_name = ngx_array_push(&next_names);
|
|
|
|
if (next_name == NULL) {
|
|
|
|
return NGX_ERROR;
|
|
|
|
}
|
|
|
|
|
2005-12-27 01:07:48 +08:00
|
|
|
next_name->key.len = names[i].key.len - dot_len;
|
|
|
|
next_name->key.data = names[i].key.data + dot_len;
|
2009-09-13 14:25:54 +08:00
|
|
|
next_name->key_hash = 0;
|
2005-12-16 23:07:08 +08:00
|
|
|
next_name->value = names[i].value;
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
ngx_log_error(NGX_LOG_ALERT, hinit->pool->log, 0,
|
2005-12-19 00:02:44 +08:00
|
|
|
"wc3: \"%V\"", &next_name->key);
|
2005-12-16 23:07:08 +08:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
if (next_names.nelts) {
|
2005-12-27 01:07:48 +08:00
|
|
|
|
2005-12-16 23:07:08 +08:00
|
|
|
h = *hinit;
|
|
|
|
h.hash = NULL;
|
|
|
|
|
|
|
|
if (ngx_hash_wildcard_init(&h, (ngx_hash_key_t *) next_names.elts,
|
|
|
|
next_names.nelts)
|
|
|
|
!= NGX_OK)
|
|
|
|
{
|
|
|
|
return NGX_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
wdc = (ngx_hash_wildcard_t *) h.hash;
|
|
|
|
|
|
|
|
if (names[n].key.len == len) {
|
|
|
|
wdc->value = names[n].value;
|
|
|
|
}
|
|
|
|
|
2009-02-11 20:33:13 +08:00
|
|
|
name->value = (void *) ((uintptr_t) wdc | (dot ? 3 : 2));
|
2008-08-12 23:28:19 +08:00
|
|
|
|
|
|
|
} else if (dot) {
|
|
|
|
name->value = (void *) ((uintptr_t) name->value | 1);
|
2005-12-16 23:07:08 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ngx_hash_init(hinit, (ngx_hash_key_t *) curr_names.elts,
|
|
|
|
curr_names.nelts)
|
|
|
|
!= NGX_OK)
|
|
|
|
{
|
|
|
|
return NGX_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NGX_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ngx_uint_t
|
|
|
|
ngx_hash_key(u_char *data, size_t len)
|
|
|
|
{
|
|
|
|
ngx_uint_t i, key;
|
|
|
|
|
|
|
|
key = 0;
|
|
|
|
|
|
|
|
for (i = 0; i < len; i++) {
|
|
|
|
key = ngx_hash(key, data[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
return key;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ngx_uint_t
|
|
|
|
ngx_hash_key_lc(u_char *data, size_t len)
|
|
|
|
{
|
|
|
|
ngx_uint_t i, key;
|
|
|
|
|
|
|
|
key = 0;
|
|
|
|
|
|
|
|
for (i = 0; i < len; i++) {
|
|
|
|
key = ngx_hash(key, ngx_tolower(data[i]));
|
|
|
|
}
|
|
|
|
|
|
|
|
return key;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-08-04 18:18:36 +08:00
|
|
|
ngx_uint_t
|
|
|
|
ngx_hash_strlow(u_char *dst, u_char *src, size_t n)
|
|
|
|
{
|
|
|
|
ngx_uint_t key;
|
|
|
|
|
|
|
|
key = 0;
|
|
|
|
|
|
|
|
while (n--) {
|
|
|
|
*dst = ngx_tolower(*src);
|
|
|
|
key = ngx_hash(key, *dst);
|
|
|
|
dst++;
|
|
|
|
src++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return key;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-12-27 01:07:48 +08:00
|
|
|
ngx_int_t
|
|
|
|
ngx_hash_keys_array_init(ngx_hash_keys_arrays_t *ha, ngx_uint_t type)
|
|
|
|
{
|
|
|
|
ngx_uint_t asize;
|
|
|
|
|
|
|
|
if (type == NGX_HASH_SMALL) {
|
|
|
|
asize = 4;
|
|
|
|
ha->hsize = 107;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
asize = NGX_HASH_LARGE_ASIZE;
|
|
|
|
ha->hsize = NGX_HASH_LARGE_HSIZE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ngx_array_init(&ha->keys, ha->temp_pool, asize, sizeof(ngx_hash_key_t))
|
|
|
|
!= NGX_OK)
|
|
|
|
{
|
|
|
|
return NGX_ERROR;
|
|
|
|
}
|
|
|
|
|
2007-06-12 03:49:22 +08:00
|
|
|
if (ngx_array_init(&ha->dns_wc_head, ha->temp_pool, asize,
|
|
|
|
sizeof(ngx_hash_key_t))
|
|
|
|
!= NGX_OK)
|
|
|
|
{
|
|
|
|
return NGX_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ngx_array_init(&ha->dns_wc_tail, ha->temp_pool, asize,
|
2005-12-27 01:07:48 +08:00
|
|
|
sizeof(ngx_hash_key_t))
|
|
|
|
!= NGX_OK)
|
|
|
|
{
|
|
|
|
return NGX_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
ha->keys_hash = ngx_pcalloc(ha->temp_pool, sizeof(ngx_array_t) * ha->hsize);
|
|
|
|
if (ha->keys_hash == NULL) {
|
|
|
|
return NGX_ERROR;
|
|
|
|
}
|
|
|
|
|
2007-06-12 03:49:22 +08:00
|
|
|
ha->dns_wc_head_hash = ngx_pcalloc(ha->temp_pool,
|
|
|
|
sizeof(ngx_array_t) * ha->hsize);
|
|
|
|
if (ha->dns_wc_head_hash == NULL) {
|
|
|
|
return NGX_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
ha->dns_wc_tail_hash = ngx_pcalloc(ha->temp_pool,
|
|
|
|
sizeof(ngx_array_t) * ha->hsize);
|
|
|
|
if (ha->dns_wc_tail_hash == NULL) {
|
2005-12-27 01:07:48 +08:00
|
|
|
return NGX_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NGX_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ngx_int_t
|
|
|
|
ngx_hash_add_key(ngx_hash_keys_arrays_t *ha, ngx_str_t *key, void *value,
|
|
|
|
ngx_uint_t flags)
|
|
|
|
{
|
|
|
|
size_t len;
|
2007-06-12 03:49:22 +08:00
|
|
|
u_char *p;
|
2005-12-27 01:07:48 +08:00
|
|
|
ngx_str_t *name;
|
2007-06-12 03:49:22 +08:00
|
|
|
ngx_uint_t i, k, n, skip, last;
|
|
|
|
ngx_array_t *keys, *hwc;
|
2005-12-27 01:07:48 +08:00
|
|
|
ngx_hash_key_t *hk;
|
|
|
|
|
2007-06-12 03:49:22 +08:00
|
|
|
last = key->len;
|
|
|
|
|
|
|
|
if (flags & NGX_HASH_WILDCARD_KEY) {
|
2005-12-27 01:07:48 +08:00
|
|
|
|
2007-06-12 03:49:22 +08:00
|
|
|
/*
|
|
|
|
* supported wildcards:
|
|
|
|
* "*.example.com", ".example.com", and "www.example.*"
|
|
|
|
*/
|
2005-12-27 01:07:48 +08:00
|
|
|
|
2007-06-12 03:49:22 +08:00
|
|
|
n = 0;
|
2005-12-27 01:07:48 +08:00
|
|
|
|
|
|
|
for (i = 0; i < key->len; i++) {
|
2007-06-12 03:49:22 +08:00
|
|
|
|
|
|
|
if (key->data[i] == '*') {
|
|
|
|
if (++n > 1) {
|
|
|
|
return NGX_DECLINED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (key->data[i] == '.' && key->data[i + 1] == '.') {
|
|
|
|
return NGX_DECLINED;
|
2006-01-11 23:26:57 +08:00
|
|
|
}
|
2005-12-27 01:07:48 +08:00
|
|
|
}
|
|
|
|
|
2007-06-12 03:49:22 +08:00
|
|
|
if (key->len > 1 && key->data[0] == '.') {
|
|
|
|
skip = 1;
|
|
|
|
goto wildcard;
|
|
|
|
}
|
2005-12-27 01:07:48 +08:00
|
|
|
|
2007-06-12 03:49:22 +08:00
|
|
|
if (key->len > 2) {
|
2005-12-27 01:07:48 +08:00
|
|
|
|
2007-06-12 03:49:22 +08:00
|
|
|
if (key->data[0] == '*' && key->data[1] == '.') {
|
|
|
|
skip = 2;
|
|
|
|
goto wildcard;
|
|
|
|
}
|
2005-12-27 01:07:48 +08:00
|
|
|
|
2007-06-12 03:49:22 +08:00
|
|
|
if (key->data[i - 2] == '.' && key->data[i - 1] == '*') {
|
|
|
|
skip = 0;
|
|
|
|
last -= 2;
|
|
|
|
goto wildcard;
|
|
|
|
}
|
|
|
|
}
|
2005-12-27 01:07:48 +08:00
|
|
|
|
2007-06-12 03:49:22 +08:00
|
|
|
if (n) {
|
|
|
|
return NGX_DECLINED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* exact hash */
|
|
|
|
|
|
|
|
k = 0;
|
|
|
|
|
|
|
|
for (i = 0; i < last; i++) {
|
|
|
|
if (!(flags & NGX_HASH_READONLY_KEY)) {
|
|
|
|
key->data[i] = ngx_tolower(key->data[i]);
|
|
|
|
}
|
|
|
|
k = ngx_hash(k, key->data[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
k %= ha->hsize;
|
|
|
|
|
|
|
|
/* check conflicts in exact hash */
|
|
|
|
|
|
|
|
name = ha->keys_hash[k].elts;
|
|
|
|
|
|
|
|
if (name) {
|
|
|
|
for (i = 0; i < ha->keys_hash[k].nelts; i++) {
|
|
|
|
if (last != name[i].len) {
|
|
|
|
continue;
|
2005-12-27 01:07:48 +08:00
|
|
|
}
|
|
|
|
|
2007-06-12 03:49:22 +08:00
|
|
|
if (ngx_strncmp(key->data, name[i].data, last) == 0) {
|
|
|
|
return NGX_BUSY;
|
2005-12-27 01:07:48 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-06-12 03:49:22 +08:00
|
|
|
} else {
|
|
|
|
if (ngx_array_init(&ha->keys_hash[k], ha->temp_pool, 4,
|
|
|
|
sizeof(ngx_str_t))
|
|
|
|
!= NGX_OK)
|
|
|
|
{
|
2005-12-27 01:07:48 +08:00
|
|
|
return NGX_ERROR;
|
|
|
|
}
|
2007-06-12 03:49:22 +08:00
|
|
|
}
|
2005-12-27 01:07:48 +08:00
|
|
|
|
2007-06-12 03:49:22 +08:00
|
|
|
name = ngx_array_push(&ha->keys_hash[k]);
|
|
|
|
if (name == NULL) {
|
|
|
|
return NGX_ERROR;
|
|
|
|
}
|
2005-12-27 01:07:48 +08:00
|
|
|
|
2007-06-12 03:49:22 +08:00
|
|
|
*name = *key;
|
2005-12-27 01:07:48 +08:00
|
|
|
|
2007-06-12 03:49:22 +08:00
|
|
|
hk = ngx_array_push(&ha->keys);
|
|
|
|
if (hk == NULL) {
|
|
|
|
return NGX_ERROR;
|
|
|
|
}
|
2005-12-27 01:07:48 +08:00
|
|
|
|
2007-06-12 03:49:22 +08:00
|
|
|
hk->key = *key;
|
|
|
|
hk->key_hash = ngx_hash_key(key->data, last);
|
|
|
|
hk->value = value;
|
2005-12-27 01:07:48 +08:00
|
|
|
|
2007-06-12 03:49:22 +08:00
|
|
|
return NGX_OK;
|
2005-12-27 01:07:48 +08:00
|
|
|
|
|
|
|
|
2007-06-12 03:49:22 +08:00
|
|
|
wildcard:
|
2005-12-27 01:07:48 +08:00
|
|
|
|
2007-06-12 03:49:22 +08:00
|
|
|
/* wildcard hash */
|
2005-12-27 01:07:48 +08:00
|
|
|
|
2008-08-04 18:18:36 +08:00
|
|
|
k = ngx_hash_strlow(&key->data[skip], &key->data[skip], last - skip);
|
2007-06-12 03:49:22 +08:00
|
|
|
|
|
|
|
k %= ha->hsize;
|
|
|
|
|
|
|
|
if (skip == 1) {
|
2005-12-27 01:07:48 +08:00
|
|
|
|
2007-06-12 03:49:22 +08:00
|
|
|
/* check conflicts in exact hash for ".example.com" */
|
2005-12-27 01:07:48 +08:00
|
|
|
|
2007-06-12 03:49:22 +08:00
|
|
|
name = ha->keys_hash[k].elts;
|
2005-12-27 01:07:48 +08:00
|
|
|
|
2007-06-12 03:49:22 +08:00
|
|
|
if (name) {
|
|
|
|
len = last - skip;
|
2005-12-27 01:07:48 +08:00
|
|
|
|
2007-06-12 03:49:22 +08:00
|
|
|
for (i = 0; i < ha->keys_hash[k].nelts; i++) {
|
|
|
|
if (len != name[i].len) {
|
|
|
|
continue;
|
2005-12-27 01:07:48 +08:00
|
|
|
}
|
|
|
|
|
2007-06-12 03:49:22 +08:00
|
|
|
if (ngx_strncmp(&key->data[1], name[i].data, len) == 0) {
|
|
|
|
return NGX_BUSY;
|
2005-12-27 01:07:48 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-06-12 03:49:22 +08:00
|
|
|
} else {
|
|
|
|
if (ngx_array_init(&ha->keys_hash[k], ha->temp_pool, 4,
|
|
|
|
sizeof(ngx_str_t))
|
|
|
|
!= NGX_OK)
|
|
|
|
{
|
2005-12-27 01:07:48 +08:00
|
|
|
return NGX_ERROR;
|
|
|
|
}
|
2007-06-12 03:49:22 +08:00
|
|
|
}
|
2005-12-27 01:07:48 +08:00
|
|
|
|
2007-06-12 03:49:22 +08:00
|
|
|
name = ngx_array_push(&ha->keys_hash[k]);
|
|
|
|
if (name == NULL) {
|
|
|
|
return NGX_ERROR;
|
|
|
|
}
|
2005-12-27 01:07:48 +08:00
|
|
|
|
2007-06-12 03:49:22 +08:00
|
|
|
name->len = last - 1;
|
2008-06-17 23:00:30 +08:00
|
|
|
name->data = ngx_pnalloc(ha->temp_pool, name->len);
|
2007-06-12 03:49:22 +08:00
|
|
|
if (name->data == NULL) {
|
|
|
|
return NGX_ERROR;
|
2005-12-27 01:07:48 +08:00
|
|
|
}
|
|
|
|
|
2007-06-12 03:49:22 +08:00
|
|
|
ngx_memcpy(name->data, &key->data[1], name->len);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (skip) {
|
2005-12-27 01:07:48 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* convert "*.example.com" to "com.example.\0"
|
|
|
|
* and ".example.com" to "com.example\0"
|
|
|
|
*/
|
|
|
|
|
2008-06-17 23:00:30 +08:00
|
|
|
p = ngx_pnalloc(ha->temp_pool, last);
|
2007-06-12 03:49:22 +08:00
|
|
|
if (p == NULL) {
|
2006-03-10 20:51:52 +08:00
|
|
|
return NGX_ERROR;
|
|
|
|
}
|
|
|
|
|
2005-12-27 01:07:48 +08:00
|
|
|
len = 0;
|
|
|
|
n = 0;
|
|
|
|
|
2007-06-12 03:49:22 +08:00
|
|
|
for (i = last - 1; i; i--) {
|
2005-12-27 01:07:48 +08:00
|
|
|
if (key->data[i] == '.') {
|
2007-06-12 03:49:22 +08:00
|
|
|
ngx_memcpy(&p[n], &key->data[i + 1], len);
|
2005-12-27 01:07:48 +08:00
|
|
|
n += len;
|
2007-06-12 03:49:22 +08:00
|
|
|
p[n++] = '.';
|
2005-12-27 01:07:48 +08:00
|
|
|
len = 0;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
len++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (len) {
|
2007-06-12 03:49:22 +08:00
|
|
|
ngx_memcpy(&p[n], &key->data[1], len);
|
2005-12-27 01:07:48 +08:00
|
|
|
n += len;
|
|
|
|
}
|
|
|
|
|
2007-06-12 03:49:22 +08:00
|
|
|
p[n] = '\0';
|
2006-03-10 20:51:52 +08:00
|
|
|
|
2007-06-12 03:49:22 +08:00
|
|
|
hwc = &ha->dns_wc_head;
|
|
|
|
keys = &ha->dns_wc_head_hash[k];
|
2006-03-10 20:51:52 +08:00
|
|
|
|
2007-06-12 03:49:22 +08:00
|
|
|
} else {
|
2006-03-10 20:51:52 +08:00
|
|
|
|
2007-06-12 03:49:22 +08:00
|
|
|
/* convert "www.example.*" to "www.example\0" */
|
2005-12-27 01:07:48 +08:00
|
|
|
|
2007-06-12 03:49:22 +08:00
|
|
|
last++;
|
2005-12-27 01:07:48 +08:00
|
|
|
|
2008-06-17 23:00:30 +08:00
|
|
|
p = ngx_pnalloc(ha->temp_pool, last);
|
2007-08-24 19:05:47 +08:00
|
|
|
if (p == NULL) {
|
|
|
|
return NGX_ERROR;
|
|
|
|
}
|
|
|
|
|
2007-09-21 21:43:53 +08:00
|
|
|
ngx_cpystrn(p, key->data, last);
|
2007-08-24 19:05:47 +08:00
|
|
|
|
2007-06-12 03:49:22 +08:00
|
|
|
hwc = &ha->dns_wc_tail;
|
|
|
|
keys = &ha->dns_wc_tail_hash[k];
|
|
|
|
}
|
2005-12-27 01:07:48 +08:00
|
|
|
|
|
|
|
|
2007-06-12 03:49:22 +08:00
|
|
|
/* check conflicts in wildcard hash */
|
|
|
|
|
|
|
|
name = keys->elts;
|
|
|
|
|
|
|
|
if (name) {
|
|
|
|
len = last - skip;
|
|
|
|
|
|
|
|
for (i = 0; i < keys->nelts; i++) {
|
|
|
|
if (len != name[i].len) {
|
|
|
|
continue;
|
2005-12-27 01:07:48 +08:00
|
|
|
}
|
|
|
|
|
2007-06-12 03:49:22 +08:00
|
|
|
if (ngx_strncmp(key->data + skip, name[i].data, len) == 0) {
|
|
|
|
return NGX_BUSY;
|
2005-12-27 01:07:48 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-06-12 03:49:22 +08:00
|
|
|
} else {
|
|
|
|
if (ngx_array_init(keys, ha->temp_pool, 4, sizeof(ngx_str_t)) != NGX_OK)
|
|
|
|
{
|
2005-12-27 01:07:48 +08:00
|
|
|
return NGX_ERROR;
|
|
|
|
}
|
2007-06-12 03:49:22 +08:00
|
|
|
}
|
2005-12-27 01:07:48 +08:00
|
|
|
|
2007-06-12 03:49:22 +08:00
|
|
|
name = ngx_array_push(keys);
|
|
|
|
if (name == NULL) {
|
|
|
|
return NGX_ERROR;
|
|
|
|
}
|
2005-12-27 01:07:48 +08:00
|
|
|
|
2007-06-12 03:49:22 +08:00
|
|
|
name->len = last - skip;
|
2008-06-17 23:00:30 +08:00
|
|
|
name->data = ngx_pnalloc(ha->temp_pool, name->len);
|
2007-06-12 03:49:22 +08:00
|
|
|
if (name->data == NULL) {
|
|
|
|
return NGX_ERROR;
|
2005-12-27 01:07:48 +08:00
|
|
|
}
|
|
|
|
|
2007-06-12 03:49:22 +08:00
|
|
|
ngx_memcpy(name->data, key->data + skip, name->len);
|
|
|
|
|
2012-06-18 22:06:00 +08:00
|
|
|
|
|
|
|
/* add to wildcard hash */
|
|
|
|
|
|
|
|
hk = ngx_array_push(hwc);
|
|
|
|
if (hk == NULL) {
|
|
|
|
return NGX_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
hk->key.len = last - 1;
|
|
|
|
hk->key.data = p;
|
|
|
|
hk->key_hash = 0;
|
|
|
|
hk->value = value;
|
|
|
|
|
2005-12-27 01:07:48 +08:00
|
|
|
return NGX_OK;
|
|
|
|
}
|