comparison src/stream/ngx_stream_upstream_hash_module.c @ 6610:d5b5866c06c4

Stream: got rid of pseudo variables. Stream limit_conn, upstream_hash and proxy modules now use complex values.
author Vladimir Homutov <vl@nginx.com>
date Wed, 29 Jun 2016 12:46:12 +0300
parents 2f41d383c9c7
children 8ed51b02f655
comparison
equal deleted inserted replaced
6609:73543af69f14 6610:d5b5866c06c4
21 ngx_stream_upstream_chash_point_t point[1]; 21 ngx_stream_upstream_chash_point_t point[1];
22 } ngx_stream_upstream_chash_points_t; 22 } ngx_stream_upstream_chash_points_t;
23 23
24 24
25 typedef struct { 25 typedef struct {
26 ngx_stream_complex_value_t key;
26 ngx_stream_upstream_chash_points_t *points; 27 ngx_stream_upstream_chash_points_t *points;
27 } ngx_stream_upstream_hash_srv_conf_t; 28 } ngx_stream_upstream_hash_srv_conf_t;
28 29
29 30
30 typedef struct { 31 typedef struct {
139 s->upstream->peer.get = ngx_stream_upstream_get_hash_peer; 140 s->upstream->peer.get = ngx_stream_upstream_get_hash_peer;
140 141
141 hcf = ngx_stream_conf_upstream_srv_conf(us, 142 hcf = ngx_stream_conf_upstream_srv_conf(us,
142 ngx_stream_upstream_hash_module); 143 ngx_stream_upstream_hash_module);
143 144
144 hp->key = s->connection->addr_text; 145 if (ngx_stream_complex_value(s, &hcf->key, &hp->key) != NGX_OK) {
146 return NGX_ERROR;
147 }
145 148
146 ngx_log_debug1(NGX_LOG_DEBUG_STREAM, s->connection->log, 0, 149 ngx_log_debug1(NGX_LOG_DEBUG_STREAM, s->connection->log, 0,
147 "upstream hash key:\"%V\"", &hp->key); 150 "upstream hash key:\"%V\"", &hp->key);
148 151
149 hp->conf = hcf; 152 hp->conf = hcf;
614 617
615 618
616 static char * 619 static char *
617 ngx_stream_upstream_hash(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) 620 ngx_stream_upstream_hash(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
618 { 621 {
619 ngx_str_t *value; 622 ngx_stream_upstream_hash_srv_conf_t *hcf = conf;
620 ngx_stream_upstream_srv_conf_t *uscf; 623
624 ngx_str_t *value;
625 ngx_stream_upstream_srv_conf_t *uscf;
626 ngx_stream_compile_complex_value_t ccv;
621 627
622 value = cf->args->elts; 628 value = cf->args->elts;
623 629
624 if (ngx_strcmp(value[1].data, "$remote_addr")) { 630 ngx_memzero(&ccv, sizeof(ngx_stream_compile_complex_value_t));
625 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, 631
626 "unsupported hash key \"%V\", use $remote_addr", 632 ccv.cf = cf;
627 &value[1]); 633 ccv.value = &value[1];
634 ccv.complex_value = &hcf->key;
635
636 if (ngx_stream_compile_complex_value(&ccv) != NGX_OK) {
628 return NGX_CONF_ERROR; 637 return NGX_CONF_ERROR;
629 } 638 }
630 639
631 uscf = ngx_stream_conf_get_module_srv_conf(cf, ngx_stream_upstream_module); 640 uscf = ngx_stream_conf_get_module_srv_conf(cf, ngx_stream_upstream_module);
632 641