Welcome! Log In Create A New Profile

Advanced

Re: limit_rate_after support variables

Miroslav Novy
November 21, 2018 09:52AM
Hi Ruslan,
there is my fix to remove warning "using uninitialized variable".

I have moved the reading value of limit_rate variable from function
ngx_http_update_location_config to function ngx_http_write_filter
because value is initialized later.

Best regards
Miroslav Nový

# HG changeset patch
# User Miroslav Nový <miranovy@gmail.com>
# Date 1542811768 0
# Wed Nov 21 14:49:28 2018 +0000
# Node ID e2139cd62c7263dc182b11a847a6eaf2d9560a0d
# Parent 82eed7650622fd780dcd4a86661de7b80b44199c
Variables support in limit_rate and limit_rate_after fix

Reading value of limit_rate variable moved to function
ngx_http_write_filter because in function
ngx_http_update_location_config is not inicialized yet.

diff -r 82eed7650622 -r e2139cd62c72 src/http/ngx_http_core_module.c
--- a/src/http/ngx_http_core_module.c Wed Nov 21 10:40:01 2018 +0000
+++ b/src/http/ngx_http_core_module.c Wed Nov 21 14:49:28 2018 +0000
@@ -1212,8 +1212,6 @@
void
ngx_http_update_location_config(ngx_http_request_t *r)
{
- size_t limit_rate;
- ngx_str_t val;
ngx_http_core_loc_conf_t *clcf;

clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
@@ -1283,20 +1281,6 @@
r->connection->tcp_nopush = NGX_TCP_NOPUSH_DISABLED;
}

- if (r->limit_rate == 0
- && clcf->limit_rate
- && ngx_http_complex_value_size(r, clcf->limit_rate, &val, &limit_rate)
- == NGX_OK)
- {
- if (limit_rate != (size_t) NGX_ERROR) {
- r->limit_rate = limit_rate;
-
- } else if (val.len) {
- ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
- "invalid \"limit_rate\" value \"%V\"", &val);
- }
- }
-
if (clcf->handler) {
r->content_handler = clcf->handler;
}
diff -r 82eed7650622 -r e2139cd62c72 src/http/ngx_http_write_filter_module.c
--- a/src/http/ngx_http_write_filter_module.c Wed Nov 21 10:40:01 2018 +0000
+++ b/src/http/ngx_http_write_filter_module.c Wed Nov 21 14:49:28 2018 +0000
@@ -48,7 +48,7 @@
ngx_http_write_filter(ngx_http_request_t *r, ngx_chain_t *in)
{
off_t size, sent, nsent, limit;
- size_t limit_rate_after;
+ ssize_t limit_rate, limit_rate_after;
ngx_str_t val;
ngx_uint_t last, flush, sync;
ngx_msec_t delay;
@@ -220,6 +220,25 @@
return NGX_ERROR;
}

+ if (r->limit_rate == 0
+ && clcf->limit_rate
+ && ngx_http_complex_value_size(r, clcf->limit_rate, &val,
+ &limit_rate)
+ == NGX_OK)
+ {
+ if (limit_rate_after != NGX_ERROR) {
+ r->limit_rate = limit_rate;
+
+ } else if (val.len) {
+ ngx_log_error(NGX_LOG_ERR, c->log, 0,
+ "invalid \"limit_rate\" value \"%V\"",
+ &val);
+ }
+ }
+
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, "http limit rate \"%z\"",
+ r->limit_rate);
+
if (r->limit_rate) {
if (r->limit_rate_after == 0
&& clcf->limit_rate_after
@@ -227,7 +246,7 @@
&limit_rate_after)
== NGX_OK)
{
- if (limit_rate_after != (size_t) NGX_ERROR) {
+ if (limit_rate_after != NGX_ERROR) {
r->limit_rate_after = limit_rate_after;

} else if (val.len) {
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

limit_rate_after support variables

Miroslav Novy 374 August 14, 2018 04:24AM

Re: limit_rate_after support variables

ru@nginx.com 94 August 27, 2018 07:30AM

Re: limit_rate_after support variables

Miroslav Novy 126 August 27, 2018 09:38AM

Re: limit_rate_after support variables

ru@nginx.com 99 August 27, 2018 12:02PM

Re: limit_rate_after support variables

Miroslav Novy 87 August 28, 2018 03:24AM

Re: limit_rate_after support variables

ru@nginx.com 86 August 29, 2018 07:44AM

Re: limit_rate_after support variables

Miroslav Novy 109 August 30, 2018 03:02AM

Re: limit_rate_after support variables

Miroslav Novy 83 October 17, 2018 06:50AM

Re: limit_rate_after support variables

ru@nginx.com 56 November 20, 2018 09:12AM

Re: limit_rate_after support variables

Miroslav Novy 52 November 21, 2018 06:12AM

Re: limit_rate_after support variables

Miroslav Novy 64 November 21, 2018 09:52AM

Re: limit_rate_after support variables

ru@nginx.com 59 December 06, 2018 09:46AM

Re: limit_rate_after support variables

Miroslav Novy 61 December 10, 2018 08:32AM

Re: limit_rate_after support variables

Miroslav Nový 32 February 25, 2019 06:08AM

Re: limit_rate_after support variables

ru@nginx.com 44 February 26, 2019 03:00AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 76
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready