Mercurial > hg > nginx-vendor-0-7
comparison src/core/ngx_hash.c @ 168:3314be145cb9 NGINX_0_3_31
nginx 0.3.31
*) Change: now nginx passes the malformed proxied backend responses.
*) Feature: the "listen" directives support the address in the "*:port"
form.
*) Feature: the EVFILER_TIMER support in MacOSX 10.4.
*) Workaround: for MacOSX 64-bit kernel kqueue millisecond timeout
bug.
Thanks to Andrei Nigmatulin.
*) Bugfix: if there were several "listen" directives listening one
various addresses inside one server, then server names like
"*.domain.tld" worked for first address only; bug appeared in 0.3.18.
*) Bugfix: if the HTTPS protocol was used in the "proxy_pass" directive
and the request body was in temporarily file then the request was
not transferred.
*) Bugfix: perl 5.8.8 compatibility.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Fri, 10 Mar 2006 00:00:00 +0300 |
parents | 36af50a5582d |
children | 4cd3e70c4d60 |
comparison
equal
deleted
inserted
replaced
167:544cb5cba207 | 168:3314be145cb9 |
---|---|
739 ngx_int_t | 739 ngx_int_t |
740 ngx_hash_add_key(ngx_hash_keys_arrays_t *ha, ngx_str_t *key, void *value, | 740 ngx_hash_add_key(ngx_hash_keys_arrays_t *ha, ngx_str_t *key, void *value, |
741 ngx_uint_t flags) | 741 ngx_uint_t flags) |
742 { | 742 { |
743 size_t len; | 743 size_t len; |
744 u_char *reverse; | |
744 ngx_str_t *name; | 745 ngx_str_t *name; |
745 ngx_uint_t i, k, n, skip; | 746 ngx_uint_t i, k, n, skip; |
746 ngx_hash_key_t *hk; | 747 ngx_hash_key_t *hk; |
747 u_char buf[2048]; | |
748 | 748 |
749 if (!(flags & NGX_HASH_WILDCARD_KEY)) { | 749 if (!(flags & NGX_HASH_WILDCARD_KEY)) { |
750 | 750 |
751 /* exact hash */ | 751 /* exact hash */ |
752 | 752 |
861 /* | 861 /* |
862 * convert "*.example.com" to "com.example.\0" | 862 * convert "*.example.com" to "com.example.\0" |
863 * and ".example.com" to "com.example\0" | 863 * and ".example.com" to "com.example\0" |
864 */ | 864 */ |
865 | 865 |
866 reverse = ngx_palloc(ha->temp_pool, key->len); | |
867 if (reverse == NULL) { | |
868 return NGX_ERROR; | |
869 } | |
870 | |
866 len = 0; | 871 len = 0; |
867 n = 0; | 872 n = 0; |
868 | 873 |
869 for (i = key->len - 1; i; i--) { | 874 for (i = key->len - 1; i; i--) { |
870 if (key->data[i] == '.') { | 875 if (key->data[i] == '.') { |
871 ngx_memcpy(&buf[n], &key->data[i + 1], len); | 876 ngx_memcpy(&reverse[n], &key->data[i + 1], len); |
872 n += len; | 877 n += len; |
873 buf[n++] = '.'; | 878 reverse[n++] = '.'; |
874 len = 0; | 879 len = 0; |
875 continue; | 880 continue; |
876 } | 881 } |
877 | 882 |
878 len++; | 883 len++; |
879 } | 884 } |
880 | 885 |
881 if (len) { | 886 if (len) { |
882 ngx_memcpy(&buf[n], &key->data[1], len); | 887 ngx_memcpy(&reverse[n], &key->data[1], len); |
883 n += len; | 888 n += len; |
884 } | 889 } |
885 | 890 |
886 buf[n] = '\0'; | 891 reverse[n] = '\0'; |
892 | |
893 | |
894 hk = ngx_array_push(&ha->dns_wildcards); | |
895 if (hk == NULL) { | |
896 return NGX_ERROR; | |
897 } | |
898 | |
899 hk->key.len = key->len - 1; | |
900 hk->key.data = reverse; | |
901 hk->key_hash = 0; | |
902 hk->value = value; | |
887 | 903 |
888 | 904 |
889 /* check conflicts in wildcard hash */ | 905 /* check conflicts in wildcard hash */ |
890 | 906 |
891 name = ha->dns_wildcards_hash[k].elts; | 907 name = ha->dns_wildcards_hash[k].elts; |
920 name->len = key->len - skip; | 936 name->len = key->len - skip; |
921 name->data = ngx_palloc(ha->temp_pool, name->len); | 937 name->data = ngx_palloc(ha->temp_pool, name->len); |
922 if (name->data == NULL) { | 938 if (name->data == NULL) { |
923 return NGX_ERROR; | 939 return NGX_ERROR; |
924 } | 940 } |
941 | |
925 ngx_memcpy(name->data, key->data + skip, name->len); | 942 ngx_memcpy(name->data, key->data + skip, name->len); |
926 | |
927 | |
928 ngx_memcpy(key->data, buf, key->len); | |
929 key->len--; | |
930 | |
931 hk = ngx_array_push(&ha->dns_wildcards); | |
932 if (hk == NULL) { | |
933 return NGX_ERROR; | |
934 } | |
935 | |
936 hk->key = *key; | |
937 hk->key_hash = 0; | |
938 hk->value = value; | |
939 } | 943 } |
940 | 944 |
941 return NGX_OK; | 945 return NGX_OK; |
942 } | 946 } |