aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2010-05-13 12:52:45 +0000
committerIgor Sysoev <igor@sysoev.ru>2010-05-13 12:52:45 +0000
commit6884183ad9dc40bca5c07cff3d400ff1a9025449 (patch)
tree0c19fb049426af27ee0cff1892afadd1cf025e77 /src
parent980220ffafe7b6ef1274ce07994a77f3d0bb16f5 (diff)
downloadnginx-6884183ad9dc40bca5c07cff3d400ff1a9025449.tar.gz
nginx-6884183ad9dc40bca5c07cff3d400ff1a9025449.zip
allow hash key values more than 255 bytes, it does not actually increase mean
hash element size, because due to aligning a byte after key is not used anyway in 3/4 cases on 32-bit platforms and in 7/8 cases on 64-bit platforms
Diffstat (limited to 'src')
-rw-r--r--src/core/ngx_hash.c12
-rw-r--r--src/core/ngx_hash.h2
2 files changed, 3 insertions, 11 deletions
diff --git a/src/core/ngx_hash.c b/src/core/ngx_hash.c
index 2a5b0adc7..0c7285202 100644
--- a/src/core/ngx_hash.c
+++ b/src/core/ngx_hash.c
@@ -245,7 +245,7 @@ ngx_hash_find_combined(ngx_hash_combined_t *hash, ngx_uint_t key, u_char *name,
#define NGX_HASH_ELT_SIZE(name) \
- (sizeof(void *) + ngx_align((name)->key.len + 1, sizeof(void *)))
+ (sizeof(void *) + ngx_align((name)->key.len + 2, sizeof(void *)))
ngx_int_t
ngx_hash_init(ngx_hash_init_t *hinit, ngx_hash_key_t *names, ngx_uint_t nelts)
@@ -257,14 +257,6 @@ ngx_hash_init(ngx_hash_init_t *hinit, ngx_hash_key_t *names, ngx_uint_t nelts)
ngx_hash_elt_t *elt, **buckets;
for (n = 0; n < nelts; n++) {
- if (names[n].key.len >= 255) {
- ngx_log_error(NGX_LOG_EMERG, hinit->pool->log, 0,
- "the \"%V\" value to hash is to long: %uz bytes, "
- "the maximum length can be 255 bytes only",
- &names[n].key, names[n].key.len);
- return NGX_ERROR;
- }
-
if (hinit->bucket_size < NGX_HASH_ELT_SIZE(&names[n]) + sizeof(void *))
{
ngx_log_error(NGX_LOG_EMERG, hinit->pool->log, 0,
@@ -406,7 +398,7 @@ found:
elt = (ngx_hash_elt_t *) ((u_char *) buckets[key] + test[key]);
elt->value = names[n].value;
- elt->len = (u_char) names[n].key.len;
+ elt->len = (u_short) names[n].key.len;
ngx_strlow(elt->name, names[n].key.data, names[n].key.len);
diff --git a/src/core/ngx_hash.h b/src/core/ngx_hash.h
index 76e3c774e..beabcb7c3 100644
--- a/src/core/ngx_hash.h
+++ b/src/core/ngx_hash.h
@@ -14,7 +14,7 @@
typedef struct {
void *value;
- u_char len;
+ u_short len;
u_char name[1];
} ngx_hash_elt_t;