aboutsummaryrefslogtreecommitdiff
path: root/src/stream/ngx_stream_upstream_hash_module.c
diff options
context:
space:
mode:
authorVladimir Homutov <vl@nginx.com>2016-06-29 12:46:12 +0300
committerVladimir Homutov <vl@nginx.com>2016-06-29 12:46:12 +0300
commitcb635b7879a762909282db545116c2598a0cc59a (patch)
tree5a90da6c4a7877a518b9f7ceb1a714af7d2006d5 /src/stream/ngx_stream_upstream_hash_module.c
parent05db6ddfa1ca120c1c348cc750acded2a01b090a (diff)
downloadnginx-cb635b7879a762909282db545116c2598a0cc59a.tar.gz
nginx-cb635b7879a762909282db545116c2598a0cc59a.zip
Stream: got rid of pseudo variables.
Stream limit_conn, upstream_hash and proxy modules now use complex values.
Diffstat (limited to 'src/stream/ngx_stream_upstream_hash_module.c')
-rw-r--r--src/stream/ngx_stream_upstream_hash_module.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/src/stream/ngx_stream_upstream_hash_module.c b/src/stream/ngx_stream_upstream_hash_module.c
index f200f47a7..41433dcd4 100644
--- a/src/stream/ngx_stream_upstream_hash_module.c
+++ b/src/stream/ngx_stream_upstream_hash_module.c
@@ -23,6 +23,7 @@ typedef struct {
typedef struct {
+ ngx_stream_complex_value_t key;
ngx_stream_upstream_chash_points_t *points;
} ngx_stream_upstream_hash_srv_conf_t;
@@ -141,7 +142,9 @@ ngx_stream_upstream_init_hash_peer(ngx_stream_session_t *s,
hcf = ngx_stream_conf_upstream_srv_conf(us,
ngx_stream_upstream_hash_module);
- hp->key = s->connection->addr_text;
+ if (ngx_stream_complex_value(s, &hcf->key, &hp->key) != NGX_OK) {
+ return NGX_ERROR;
+ }
ngx_log_debug1(NGX_LOG_DEBUG_STREAM, s->connection->log, 0,
"upstream hash key:\"%V\"", &hp->key);
@@ -616,15 +619,21 @@ ngx_stream_upstream_hash_create_conf(ngx_conf_t *cf)
static char *
ngx_stream_upstream_hash(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
{
- ngx_str_t *value;
- ngx_stream_upstream_srv_conf_t *uscf;
+ ngx_stream_upstream_hash_srv_conf_t *hcf = conf;
+
+ ngx_str_t *value;
+ ngx_stream_upstream_srv_conf_t *uscf;
+ ngx_stream_compile_complex_value_t ccv;
value = cf->args->elts;
- if (ngx_strcmp(value[1].data, "$remote_addr")) {
- ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
- "unsupported hash key \"%V\", use $remote_addr",
- &value[1]);
+ ngx_memzero(&ccv, sizeof(ngx_stream_compile_complex_value_t));
+
+ ccv.cf = cf;
+ ccv.value = &value[1];
+ ccv.complex_value = &hcf->key;
+
+ if (ngx_stream_compile_complex_value(&ccv) != NGX_OK) {
return NGX_CONF_ERROR;
}