<div dir="ltr">Hello,<div> thank you for your comments. I'm sending their incorporation.</div><div><br></div><div>Best regards</div><div>Míra</div><div><br></div><div><div>diff -r 70c6b08973a0 src/http/ngx_http_core_module.c</div><div>--- a/src/http/ngx_http_core_module.c<span style="white-space:pre"> </span>Fri Aug 10 21:54:46 2018 +0300</div><div>+++ b/src/http/ngx_http_core_module.c<span style="white-space:pre"> </span>Mon Aug 27 13:31:45 2018 +0000</div><div>@@ -487,7 +487,7 @@</div><div> { ngx_string("limit_rate_after"),</div><div> NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF</div><div> |NGX_CONF_TAKE1,</div><div>- ngx_conf_set_size_slot,</div><div>+ ngx_http_set_complex_value_slot,</div><div> NGX_HTTP_LOC_CONF_OFFSET,</div><div> offsetof(ngx_http_core_loc_conf_t, limit_rate_after),</div><div> NULL },</div><div>@@ -3364,6 +3364,7 @@</div><div> * clcf->alias = 0;</div><div> * clcf->gzip_proxied = 0;</div><div> * clcf->keepalive_disable = 0;</div><div>+ * clcf->limit_rate_after = NULL;</div><div> */</div><div> </div><div> clcf->client_max_body_size = NGX_CONF_UNSET;</div><div>@@ -3393,7 +3394,6 @@</div><div> clcf->send_lowat = NGX_CONF_UNSET_SIZE;</div><div> clcf->postpone_output = NGX_CONF_UNSET_SIZE;</div><div> clcf->limit_rate = NGX_CONF_UNSET_SIZE;</div><div>- clcf->limit_rate_after = NGX_CONF_UNSET_SIZE;</div><div> clcf->keepalive_timeout = NGX_CONF_UNSET_MSEC;</div><div> clcf->keepalive_header = NGX_CONF_UNSET;</div><div> clcf->keepalive_requests = NGX_CONF_UNSET_UINT;</div><div>@@ -3623,8 +3623,11 @@</div><div> ngx_conf_merge_size_value(conf->postpone_output, prev->postpone_output,</div><div> 1460);</div><div> ngx_conf_merge_size_value(conf->limit_rate, prev->limit_rate, 0);</div><div>- ngx_conf_merge_size_value(conf->limit_rate_after, prev->limit_rate_after,</div><div>- 0);</div><div>+</div><div>+ if (conf->limit_rate_after == NULL) {</div><div>+ conf->limit_rate_after = prev->limit_rate_after;</div><div>+ }</div><div>+</div><div> ngx_conf_merge_msec_value(conf->keepalive_timeout,</div><div> prev->keepalive_timeout, 75000);</div><div> ngx_conf_merge_sec_value(conf->keepalive_header,</div><div>diff -r 70c6b08973a0 src/http/ngx_http_core_module.h</div><div>--- a/src/http/ngx_http_core_module.h<span style="white-space:pre"> </span>Fri Aug 10 21:54:46 2018 +0300</div><div>+++ b/src/http/ngx_http_core_module.h<span style="white-space:pre"> </span>Mon Aug 27 13:31:45 2018 +0000</div><div>@@ -351,7 +351,7 @@</div><div> size_t send_lowat; /* send_lowat */</div><div> size_t postpone_output; /* postpone_output */</div><div> size_t limit_rate; /* limit_rate */</div><div>- size_t limit_rate_after; /* limit_rate_after */</div><div>+ ngx_http_complex_value_t *limit_rate_after; /* limit_rate_after */</div><div> size_t sendfile_max_chunk; /* sendfile_max_chunk */</div><div> size_t read_ahead; /* read_ahead */</div><div> size_t subrequest_output_buffer_size;</div><div>diff -r 70c6b08973a0 src/http/ngx_http_write_filter_module.c</div><div>--- a/src/http/ngx_http_write_filter_module.c<span style="white-space:pre"> </span>Fri Aug 10 21:54:46 2018 +0300</div><div>+++ b/src/http/ngx_http_write_filter_module.c<span style="white-space:pre"> </span>Mon Aug 27 13:31:45 2018 +0000</div><div>@@ -220,7 +220,24 @@</div><div> </div><div> if (r->limit_rate) {</div><div> if (r->limit_rate_after == 0) {</div><div>- r->limit_rate_after = clcf->limit_rate_after;</div><div>+ if (clcf->limit_rate_after) {</div><div>+ ngx_str_t res;</div><div>+ ssize_t s;</div><div>+</div><div>+ if (ngx_http_complex_value(r, clcf->limit_rate_after, &res)</div><div>+ != NGX_OK)</div><div>+ {</div><div>+ return NGX_ERROR;</div><div>+ }</div><div>+</div><div>+ s = ngx_parse_size(&res);</div><div>+ if (s == NGX_ERROR) {</div><div>+ ngx_log_error(NGX_LOG_ALERT, c->log, 0, </div><div>+ "limit_rate_after has bad value");</div><div>+ } else {</div><div>+ r->limit_rate_after = s;</div><div>+ }</div><div>+ }</div><div> }</div><div> </div><div> limit = (off_t) r->limit_rate * (ngx_time() - r->start_sec + 1)</div></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr">po 27. 8. 2018 v 13:28 odesílatel Ruslan Ermilov <<a href="mailto:ru@nginx.com">ru@nginx.com</a>> napsal:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
On Tue, Aug 14, 2018 at 10:22:14AM +0200, Miroslav Novy wrote:<br>
> # HG changeset patch<br>
> # User Miroslav Nový <<a href="mailto:miranovy@gmail.com" target="_blank">miranovy@gmail.com</a>><br>
> # Date 1534234559 0<br>
> # Tue Aug 14 08:15:59 2018 +0000<br>
> # Node ID 1a8327b50f7844cbe68226f54de60632189327f4<br>
> # Parent 70c6b08973a02551612da4a4273757dc77c70ae2<br>
> limit_rate_after support variables<br>
> <br>
> Example of use:<br>
> location / {<br>
> root /var/www/default/;<br>
> index index.html index.htm;<br>
> <br>
> set $my_limit_rate_after 2m;<br>
> <br>
> limit_rate_after $my_limit_rate_after;<br>
> limit_rate 2k;<br>
> <br>
> access_by_lua_block {<br>
> ngx.var.my_limit_rate_after = '10m'<br>
> }<br>
> <br>
> }<br>
> <br>
> diff -r 70c6b08973a0 -r 1a8327b50f78 src/http/ngx_http_core_module.c<br>
> --- a/src/http/ngx_http_core_module.c Fri Aug 10 21:54:46 2018 +0300<br>
> +++ b/src/http/ngx_http_core_module.c Tue Aug 14 08:15:59 2018 +0000<br>
> @@ -487,7 +487,7 @@<br>
> { ngx_string("limit_rate_after"),<br>
> <br>
> NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF<br>
> |NGX_CONF_TAKE1,<br>
> - ngx_conf_set_size_slot,<br>
> + ngx_http_set_complex_value_slot,<br>
> NGX_HTTP_LOC_CONF_OFFSET,<br>
> offsetof(ngx_http_core_loc_conf_t, limit_rate_after),<br>
> NULL },<br>
> @@ -3364,6 +3364,7 @@<br>
> * clcf->alias = 0;<br>
> * clcf->gzip_proxied = 0;<br>
> * clcf->keepalive_disable = 0;<br>
> + * clcf->limit_rate_after = NULL;<br>
> */<br>
> <br>
> clcf->client_max_body_size = NGX_CONF_UNSET;<br>
> @@ -3393,7 +3394,6 @@<br>
> clcf->send_lowat = NGX_CONF_UNSET_SIZE;<br>
> clcf->postpone_output = NGX_CONF_UNSET_SIZE;<br>
> clcf->limit_rate = NGX_CONF_UNSET_SIZE;<br>
> - clcf->limit_rate_after = NGX_CONF_UNSET_SIZE;<br>
> clcf->keepalive_timeout = NGX_CONF_UNSET_MSEC;<br>
> clcf->keepalive_header = NGX_CONF_UNSET;<br>
> clcf->keepalive_requests = NGX_CONF_UNSET_UINT;<br>
> @@ -3623,8 +3623,8 @@<br>
> ngx_conf_merge_size_value(conf->postpone_output, prev->postpone_output,<br>
> 1460);<br>
> ngx_conf_merge_size_value(conf->limit_rate, prev->limit_rate, 0);<br>
> - ngx_conf_merge_size_value(conf->limit_rate_after,<br>
> prev->limit_rate_after,<br>
> - 0);<br>
> + ngx_conf_merge_ptr_value(conf->limit_rate_after,<br>
> prev->limit_rate_after,<br>
> + NULL);<br>
<br>
This won't work because create_loc_conf() initialized clcf->limit_rate_after<br>
to NULL instead of NGX_CONF_UNSET_PTR. I suggest using a simple "== NULL"<br>
check here.<br>
<br>
> ngx_conf_merge_msec_value(conf->keepalive_timeout,<br>
> prev->keepalive_timeout, 75000);<br>
> ngx_conf_merge_sec_value(conf->keepalive_header,<br>
> diff -r 70c6b08973a0 -r 1a8327b50f78 src/http/ngx_http_core_module.h<br>
> --- a/src/http/ngx_http_core_module.h Fri Aug 10 21:54:46 2018 +0300<br>
> +++ b/src/http/ngx_http_core_module.h Tue Aug 14 08:15:59 2018 +0000<br>
> @@ -351,7 +351,7 @@<br>
> size_t send_lowat; /* send_lowat */<br>
> size_t postpone_output; /* postpone_output */<br>
> size_t limit_rate; /* limit_rate */<br>
> - size_t limit_rate_after; /* limit_rate_after */<br>
> + ngx_http_complex_value_t *limit_rate_after; /*<br>
> limit_rate_after */<br>
> size_t sendfile_max_chunk; /* sendfile_max_chunk */<br>
> size_t read_ahead; /* read_ahead */<br>
> size_t subrequest_output_buffer_size;<br>
> diff -r 70c6b08973a0 -r 1a8327b50f78 src/http/ngx_http_write_filter_module.c<br>
> --- a/src/http/ngx_http_write_filter_module.c Fri Aug 10 21:54:46 2018 +0300<br>
> +++ b/src/http/ngx_http_write_filter_module.c Tue Aug 14 08:15:59 2018 +0000<br>
> @@ -220,7 +220,26 @@<br>
> <br>
> if (r->limit_rate) {<br>
> if (r->limit_rate_after == 0) {<br>
> - r->limit_rate_after = clcf->limit_rate_after;<br>
> + r->limit_rate_after = 0;<br>
<br>
This assignment is pointless.<br>
<br>
> +<br>
> + if (clcf->limit_rate_after != NULL) {<br>
<br>
You can omit the "!= NULL" part of the check.<br>
<br>
> + ngx_str_t res;<br>
> + size_t st;<br>
<br>
There are style issues here, please see<br>
<a href="http://nginx.org/en/docs/dev/development_guide.html#code_style" rel="noreferrer" target="_blank">http://nginx.org/en/docs/dev/development_guide.html#code_style</a><br>
<br>
Also, I suggest renaming "st" to "s" here, and changing its type to<br>
ssize_t.<br>
<br>
> +<br>
> + if (ngx_http_complex_value(r, clcf->limit_rate_after, &res)<br>
> + != NGX_OK)<br>
> + {<br>
> + return NGX_ERROR;<br>
> + }<br>
> +<br>
> + st = ngx_parse_size(&res);<br>
> + if (st != (size_t) NGX_ERROR) {<br>
> + r->limit_rate_after = st;<br>
> + } else {<br>
> + ngx_log_error(NGX_LOG_ALERT, c->log, 0,<br>
> + "limit_rate_after has bad value");<br>
> + }<br>
> + }<br>
> }<br>
> <br>
> limit = (off_t) r->limit_rate * (ngx_time() - r->start_sec + 1)<br>
<br>
P.S. Please find another MUA that doesn't break text attachments.<br>
<br>
<br>
-- <br>
Ruslan Ermilov<br>
Assume stupidity not malice<br>
_______________________________________________<br>
nginx-devel mailing list<br>
<a href="mailto:nginx-devel@nginx.org" target="_blank">nginx-devel@nginx.org</a><br>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx-devel" rel="noreferrer" target="_blank">http://mailman.nginx.org/mailman/listinfo/nginx-devel</a><br>
</blockquote></div>