Mercurial > hg > nginx
comparison src/stream/ngx_stream_proxy_module.c @ 7505:16a1adadf437
Variables support in proxy_upload_rate and proxy_download_rate.
author | Ruslan Ermilov <ru@nginx.com> |
---|---|
date | Wed, 24 Apr 2019 16:38:56 +0300 |
parents | 8981dbb12254 |
children | d127837c714f |
comparison
equal
deleted
inserted
replaced
7504:c19ca381b2e6 | 7505:16a1adadf437 |
---|---|
22 typedef struct { | 22 typedef struct { |
23 ngx_msec_t connect_timeout; | 23 ngx_msec_t connect_timeout; |
24 ngx_msec_t timeout; | 24 ngx_msec_t timeout; |
25 ngx_msec_t next_upstream_timeout; | 25 ngx_msec_t next_upstream_timeout; |
26 size_t buffer_size; | 26 size_t buffer_size; |
27 size_t upload_rate; | 27 ngx_stream_complex_value_t *upload_rate; |
28 size_t download_rate; | 28 ngx_stream_complex_value_t *download_rate; |
29 ngx_uint_t requests; | 29 ngx_uint_t requests; |
30 ngx_uint_t responses; | 30 ngx_uint_t responses; |
31 ngx_uint_t next_upstream_tries; | 31 ngx_uint_t next_upstream_tries; |
32 ngx_flag_t next_upstream; | 32 ngx_flag_t next_upstream; |
33 ngx_flag_t proxy_protocol; | 33 ngx_flag_t proxy_protocol; |
182 offsetof(ngx_stream_proxy_srv_conf_t, buffer_size), | 182 offsetof(ngx_stream_proxy_srv_conf_t, buffer_size), |
183 &ngx_conf_deprecated_proxy_upstream_buffer }, | 183 &ngx_conf_deprecated_proxy_upstream_buffer }, |
184 | 184 |
185 { ngx_string("proxy_upload_rate"), | 185 { ngx_string("proxy_upload_rate"), |
186 NGX_STREAM_MAIN_CONF|NGX_STREAM_SRV_CONF|NGX_CONF_TAKE1, | 186 NGX_STREAM_MAIN_CONF|NGX_STREAM_SRV_CONF|NGX_CONF_TAKE1, |
187 ngx_conf_set_size_slot, | 187 ngx_stream_set_complex_value_size_slot, |
188 NGX_STREAM_SRV_CONF_OFFSET, | 188 NGX_STREAM_SRV_CONF_OFFSET, |
189 offsetof(ngx_stream_proxy_srv_conf_t, upload_rate), | 189 offsetof(ngx_stream_proxy_srv_conf_t, upload_rate), |
190 NULL }, | 190 NULL }, |
191 | 191 |
192 { ngx_string("proxy_download_rate"), | 192 { ngx_string("proxy_download_rate"), |
193 NGX_STREAM_MAIN_CONF|NGX_STREAM_SRV_CONF|NGX_CONF_TAKE1, | 193 NGX_STREAM_MAIN_CONF|NGX_STREAM_SRV_CONF|NGX_CONF_TAKE1, |
194 ngx_conf_set_size_slot, | 194 ngx_stream_set_complex_value_size_slot, |
195 NGX_STREAM_SRV_CONF_OFFSET, | 195 NGX_STREAM_SRV_CONF_OFFSET, |
196 offsetof(ngx_stream_proxy_srv_conf_t, download_rate), | 196 offsetof(ngx_stream_proxy_srv_conf_t, download_rate), |
197 NULL }, | 197 NULL }, |
198 | 198 |
199 { ngx_string("proxy_requests"), | 199 { ngx_string("proxy_requests"), |
893 u->upstream_out = cl; | 893 u->upstream_out = cl; |
894 | 894 |
895 u->proxy_protocol = 0; | 895 u->proxy_protocol = 0; |
896 } | 896 } |
897 | 897 |
898 u->upload_rate = ngx_stream_complex_value_size(s, pscf->upload_rate, 0); | |
899 u->download_rate = ngx_stream_complex_value_size(s, pscf->download_rate, 0); | |
900 | |
898 u->connected = 1; | 901 u->connected = 1; |
899 | 902 |
900 pc->read->handler = ngx_stream_proxy_upstream_handler; | 903 pc->read->handler = ngx_stream_proxy_upstream_handler; |
901 pc->write->handler = ngx_stream_proxy_upstream_handler; | 904 pc->write->handler = ngx_stream_proxy_upstream_handler; |
902 | 905 |
1530 | 1533 |
1531 if (from_upstream) { | 1534 if (from_upstream) { |
1532 src = pc; | 1535 src = pc; |
1533 dst = c; | 1536 dst = c; |
1534 b = &u->upstream_buf; | 1537 b = &u->upstream_buf; |
1535 limit_rate = pscf->download_rate; | 1538 limit_rate = u->download_rate; |
1536 received = &u->received; | 1539 received = &u->received; |
1537 packets = &u->responses; | 1540 packets = &u->responses; |
1538 out = &u->downstream_out; | 1541 out = &u->downstream_out; |
1539 busy = &u->downstream_busy; | 1542 busy = &u->downstream_busy; |
1540 recv_action = "proxying and reading from upstream"; | 1543 recv_action = "proxying and reading from upstream"; |
1542 | 1545 |
1543 } else { | 1546 } else { |
1544 src = c; | 1547 src = c; |
1545 dst = pc; | 1548 dst = pc; |
1546 b = &u->downstream_buf; | 1549 b = &u->downstream_buf; |
1547 limit_rate = pscf->upload_rate; | 1550 limit_rate = u->upload_rate; |
1548 received = &s->received; | 1551 received = &s->received; |
1549 packets = &u->requests; | 1552 packets = &u->requests; |
1550 out = &u->upstream_out; | 1553 out = &u->upstream_out; |
1551 busy = &u->upstream_busy; | 1554 busy = &u->upstream_busy; |
1552 recv_action = "proxying and reading from client"; | 1555 recv_action = "proxying and reading from client"; |
1953 * conf->ssl_trusted_certificate = { 0, NULL }; | 1956 * conf->ssl_trusted_certificate = { 0, NULL }; |
1954 * conf->ssl_crl = { 0, NULL }; | 1957 * conf->ssl_crl = { 0, NULL }; |
1955 * conf->ssl_certificate = { 0, NULL }; | 1958 * conf->ssl_certificate = { 0, NULL }; |
1956 * conf->ssl_certificate_key = { 0, NULL }; | 1959 * conf->ssl_certificate_key = { 0, NULL }; |
1957 * | 1960 * |
1961 * conf->upload_rate = NULL; | |
1962 * conf->download_rate = NULL; | |
1958 * conf->ssl = NULL; | 1963 * conf->ssl = NULL; |
1959 * conf->upstream = NULL; | 1964 * conf->upstream = NULL; |
1960 * conf->upstream_value = NULL; | 1965 * conf->upstream_value = NULL; |
1961 */ | 1966 */ |
1962 | 1967 |
1963 conf->connect_timeout = NGX_CONF_UNSET_MSEC; | 1968 conf->connect_timeout = NGX_CONF_UNSET_MSEC; |
1964 conf->timeout = NGX_CONF_UNSET_MSEC; | 1969 conf->timeout = NGX_CONF_UNSET_MSEC; |
1965 conf->next_upstream_timeout = NGX_CONF_UNSET_MSEC; | 1970 conf->next_upstream_timeout = NGX_CONF_UNSET_MSEC; |
1966 conf->buffer_size = NGX_CONF_UNSET_SIZE; | 1971 conf->buffer_size = NGX_CONF_UNSET_SIZE; |
1967 conf->upload_rate = NGX_CONF_UNSET_SIZE; | |
1968 conf->download_rate = NGX_CONF_UNSET_SIZE; | |
1969 conf->requests = NGX_CONF_UNSET_UINT; | 1972 conf->requests = NGX_CONF_UNSET_UINT; |
1970 conf->responses = NGX_CONF_UNSET_UINT; | 1973 conf->responses = NGX_CONF_UNSET_UINT; |
1971 conf->next_upstream_tries = NGX_CONF_UNSET_UINT; | 1974 conf->next_upstream_tries = NGX_CONF_UNSET_UINT; |
1972 conf->next_upstream = NGX_CONF_UNSET; | 1975 conf->next_upstream = NGX_CONF_UNSET; |
1973 conf->proxy_protocol = NGX_CONF_UNSET; | 1976 conf->proxy_protocol = NGX_CONF_UNSET; |
2003 prev->next_upstream_timeout, 0); | 2006 prev->next_upstream_timeout, 0); |
2004 | 2007 |
2005 ngx_conf_merge_size_value(conf->buffer_size, | 2008 ngx_conf_merge_size_value(conf->buffer_size, |
2006 prev->buffer_size, 16384); | 2009 prev->buffer_size, 16384); |
2007 | 2010 |
2008 ngx_conf_merge_size_value(conf->upload_rate, | 2011 if (conf->upload_rate == NULL) { |
2009 prev->upload_rate, 0); | 2012 conf->upload_rate = prev->upload_rate; |
2010 | 2013 } |
2011 ngx_conf_merge_size_value(conf->download_rate, | 2014 |
2012 prev->download_rate, 0); | 2015 if (conf->download_rate == NULL) { |
2016 conf->download_rate = prev->download_rate; | |
2017 } | |
2013 | 2018 |
2014 ngx_conf_merge_uint_value(conf->requests, | 2019 ngx_conf_merge_uint_value(conf->requests, |
2015 prev->requests, 0); | 2020 prev->requests, 0); |
2016 | 2021 |
2017 ngx_conf_merge_uint_value(conf->responses, | 2022 ngx_conf_merge_uint_value(conf->responses, |