Klaus Demo nginx / 27b3d3d
Variables support in proxy_upload_rate and proxy_download_rate. Ruslan Ermilov 3 years ago
2 changed file(s) with 21 addition(s) and 13 deletion(s). Raw diff Collapse all Expand all
2323 ngx_msec_t timeout;
2424 ngx_msec_t next_upstream_timeout;
2525 size_t buffer_size;
26 size_t upload_rate;
27 size_t download_rate;
26 ngx_stream_complex_value_t *upload_rate;
27 ngx_stream_complex_value_t *download_rate;
2828 ngx_uint_t requests;
2929 ngx_uint_t responses;
3030 ngx_uint_t next_upstream_tries;
183183
184184 { ngx_string("proxy_upload_rate"),
185185 NGX_STREAM_MAIN_CONF|NGX_STREAM_SRV_CONF|NGX_CONF_TAKE1,
186 ngx_conf_set_size_slot,
186 ngx_stream_set_complex_value_size_slot,
187187 NGX_STREAM_SRV_CONF_OFFSET,
188188 offsetof(ngx_stream_proxy_srv_conf_t, upload_rate),
189189 NULL },
190190
191191 { ngx_string("proxy_download_rate"),
192192 NGX_STREAM_MAIN_CONF|NGX_STREAM_SRV_CONF|NGX_CONF_TAKE1,
193 ngx_conf_set_size_slot,
193 ngx_stream_set_complex_value_size_slot,
194194 NGX_STREAM_SRV_CONF_OFFSET,
195195 offsetof(ngx_stream_proxy_srv_conf_t, download_rate),
196196 NULL },
894894 u->proxy_protocol = 0;
895895 }
896896
897 u->upload_rate = ngx_stream_complex_value_size(s, pscf->upload_rate, 0);
898 u->download_rate = ngx_stream_complex_value_size(s, pscf->download_rate, 0);
899
897900 u->connected = 1;
898901
899902 pc->read->handler = ngx_stream_proxy_upstream_handler;
15311534 src = pc;
15321535 dst = c;
15331536 b = &u->upstream_buf;
1534 limit_rate = pscf->download_rate;
1537 limit_rate = u->download_rate;
15351538 received = &u->received;
15361539 packets = &u->responses;
15371540 out = &u->downstream_out;
15431546 src = c;
15441547 dst = pc;
15451548 b = &u->downstream_buf;
1546 limit_rate = pscf->upload_rate;
1549 limit_rate = u->upload_rate;
15471550 received = &s->received;
15481551 packets = &u->requests;
15491552 out = &u->upstream_out;
19541957 * conf->ssl_certificate = { 0, NULL };
19551958 * conf->ssl_certificate_key = { 0, NULL };
19561959 *
1960 * conf->upload_rate = NULL;
1961 * conf->download_rate = NULL;
19571962 * conf->ssl = NULL;
19581963 * conf->upstream = NULL;
19591964 * conf->upstream_value = NULL;
19631968 conf->timeout = NGX_CONF_UNSET_MSEC;
19641969 conf->next_upstream_timeout = NGX_CONF_UNSET_MSEC;
19651970 conf->buffer_size = NGX_CONF_UNSET_SIZE;
1966 conf->upload_rate = NGX_CONF_UNSET_SIZE;
1967 conf->download_rate = NGX_CONF_UNSET_SIZE;
19681971 conf->requests = NGX_CONF_UNSET_UINT;
19691972 conf->responses = NGX_CONF_UNSET_UINT;
19701973 conf->next_upstream_tries = NGX_CONF_UNSET_UINT;
20042007 ngx_conf_merge_size_value(conf->buffer_size,
20052008 prev->buffer_size, 16384);
20062009
2007 ngx_conf_merge_size_value(conf->upload_rate,
2008 prev->upload_rate, 0);
2009
2010 ngx_conf_merge_size_value(conf->download_rate,
2011 prev->download_rate, 0);
2010 if (conf->upload_rate == NULL) {
2011 conf->upload_rate = prev->upload_rate;
2012 }
2013
2014 if (conf->download_rate == NULL) {
2015 conf->download_rate = prev->download_rate;
2016 }
20122017
20132018 ngx_conf_merge_uint_value(conf->requests,
20142019 prev->requests, 0);
131131 ngx_uint_t responses;
132132 ngx_msec_t start_time;
133133
134 size_t upload_rate;
135 size_t download_rate;
136
134137 ngx_str_t ssl_name;
135138
136139 ngx_stream_upstream_srv_conf_t *upstream;