diff options
author | Valentin Bartenev <vbart@nginx.com> | 2017-04-25 16:57:14 +0300 |
---|---|---|
committer | Valentin Bartenev <vbart@nginx.com> | 2017-04-25 16:57:14 +0300 |
commit | 558d1f8687c2e736947971e7900e1b040103b53b (patch) | |
tree | c73bc3a76b7ab891f880876a8f95823f5fb58ed7 /src/nxt_http_parse.c | |
parent | cfed068c1d81d0ad0fe58885a0120529aa49630a (diff) | |
download | unit-558d1f8687c2e736947971e7900e1b040103b53b.tar.gz unit-558d1f8687c2e736947971e7900e1b040103b53b.tar.bz2 |
HTTP parser: fixed minimum length optimization in headers hash.
Diffstat (limited to 'src/nxt_http_parse.c')
-rw-r--r-- | src/nxt_http_parse.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/nxt_http_parse.c b/src/nxt_http_parse.c index d0e22a77..95745ad4 100644 --- a/src/nxt_http_parse.c +++ b/src/nxt_http_parse.c @@ -771,7 +771,7 @@ nxt_http_fields_hash(nxt_http_fields_t *fields, nxt_mem_pool_t *mp) nxt_http_fields_hash_t *hash; nxt_http_fields_hash_entry_t *entry; - min_length = 0; + min_length = 32 + 1; max_length = 0; for (i = 0; fields[i].handler != NULL; i++) { @@ -786,11 +786,14 @@ nxt_http_fields_hash(nxt_http_fields_t *fields, nxt_mem_pool_t *mp) max_length = nxt_max(length, max_length); } - size = (max_length - min_length + 1) - * sizeof(nxt_http_fields_hash_entry_t *); + size = sizeof(nxt_http_fields_hash_t); - hash = nxt_mem_zalloc(mp, sizeof(nxt_http_fields_hash_t) + size); + if (min_length <= 32) { + size += (max_length - min_length + 1) + * sizeof(nxt_http_fields_hash_entry_t *); + } + hash = nxt_mem_zalloc(mp, size); if (nxt_slow_path(hash == NULL)) { return NULL; } |