|
4 | 4 | #include "ngx_http_set_hashed_upstream.h" |
5 | 5 |
|
6 | 6 |
|
7 | | -ndk_upstream_list_t * |
8 | | -ngx_http_set_misc_get_upstream_list(u_char *data, size_t len) |
9 | | -{ |
10 | | - ndk_upstream_list_t *ul, *ule; |
11 | | - |
12 | | - if (ndk_upstreams == NULL) { |
13 | | - return NULL; |
14 | | - } |
15 | | - |
16 | | - ul = ndk_upstreams->elts; |
17 | | - ule = ul + ndk_upstreams->nelts; |
18 | | - |
19 | | - for (; ul < ule; ul++) { |
20 | | - if (ul->name.len == len && |
21 | | - ngx_strncasecmp(ul->name.data, data, len) == 0) |
22 | | - { |
23 | | - return ul; |
24 | | - } |
25 | | - } |
26 | | - |
27 | | - return NULL; |
28 | | -} |
29 | | - |
30 | 7 |
|
31 | 8 | ngx_uint_t |
32 | 9 | ngx_http_set_misc_apply_distribution(ngx_log_t *log, ngx_uint_t hash, |
@@ -57,14 +34,15 @@ ngx_http_set_misc_set_hashed_upstream(ngx_http_request_t *r, |
57 | 34 | ngx_str_t ulname; |
58 | 35 | ngx_uint_t hash, index; |
59 | 36 | ngx_http_variable_value_t *key; |
60 | | - |
| 37 | + |
61 | 38 | if (ul == NULL) { |
62 | 39 | ulname.data = v->data; |
63 | 40 | ulname.len = v->len; |
64 | 41 |
|
65 | 42 | dd("ulname: %.*s", ulname.len, ulname.data); |
66 | | - |
67 | | - ul = ngx_http_set_misc_get_upstream_list(ulname.data, ulname.len); |
| 43 | + |
| 44 | + ul = ndk_get_upstream_list(ndk_http_get_main_conf(r), |
| 45 | + ulname.data, ulname.len); |
68 | 46 |
|
69 | 47 | if (ul == NULL) { |
70 | 48 | ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, |
@@ -142,7 +120,8 @@ ngx_http_set_hashed_upstream(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) |
142 | 120 | return ndk_set_var_multi_value_core(cf, var, v, &filter); |
143 | 121 | } |
144 | 122 |
|
145 | | - ul = ngx_http_set_misc_get_upstream_list(ulname->data, ulname->len); |
| 123 | + ul = ndk_get_upstream_list(ndk_http_conf_get_main_conf(cf), |
| 124 | + ulname->data, ulname->len); |
146 | 125 | if (ul == NULL) { |
147 | 126 | ngx_log_error(NGX_LOG_ERR, cf->log, 0, |
148 | 127 | "set_hashed_upstream: upstream list \"%V\" " |
|
0 commit comments