Maxim Dounin
December 27, 2023 06:20AM
Hello!

On Wed, Dec 27, 2023 at 10:56:44AM +0800, Jiuzhou Cui wrote:

> Hello!
>
>
> # HG changeset patch
> # User Jiuzhou Cui <cuijiuzhou@alibaba-inc.com>
> # Date 1703645578 -28800
> # Wed Dec 27 10:52:58 2023 +0800
> # Node ID 474ae07e47272e435d81c0ca9e4867aae35c30ab
> # Parent ee40e2b1d0833b46128a357fbc84c6e23be9be07
> Don't delete timer of write event when it's delayed.
>
>
> This will make download speed alway zero when limit_rate in body filter.
>
>
> diff -r ee40e2b1d083 -r 474ae07e4727 src/http/ngx_http_upstream.c
> --- a/src/http/ngx_http_upstream.c Mon Dec 25 21:15:48 2023 +0400
> +++ b/src/http/ngx_http_upstream.c Wed Dec 27 10:52:58 2023 +0800
> @@ -3787,11 +3787,13 @@
> }
> }
>
>
> - if (downstream->write->active && !downstream->write->ready) {
> - ngx_add_timer(downstream->write, clcf->send_timeout);
> -
> - } else if (downstream->write->timer_set) {
> - ngx_del_timer(downstream->write);
> + if (!downstream->write->delayed) {
> + if (downstream->write->active && !downstream->write->ready) {
> + ngx_add_timer(downstream->write, clcf->send_timeout);
> +
> + } else if (downstream->write->timer_set) {
> + ngx_del_timer(downstream->write);
> + }
> }
>
>
> if (upstream->read->eof || upstream->read->error) {

Thank you for the patch.

You are patching the
ngx_http_upstream_process_non_buffered_request() function, which
is, as can be correctly concluded from the function name, is used
for non-buffered proxying. Non-buffered proxying is specifically
designed to return responses as long as they are available, and is
not compatible with limit_rate. Moreover, limit_rate is
explicitly disabled in the ngx_http_upstream_send_response()
function when the relevant handers are set:

u->read_event_handler = ngx_http_upstream_process_non_buffered_upstream;
r->write_event_handler =
ngx_http_upstream_process_non_buffered_downstream;

r->limit_rate = 0;
r->limit_rate_set = 1;

(https://hg.nginx.org/nginx/file/release-1.25.3/src/http/ngx_http_upstream.c#l3092)

As such, the issue you are trying to fix is not expected to
appear.

Could you please clarify the configuration you are seeing the
issue with, and steps to reproduce the issue?

--
Maxim Dounin
http://mdounin.ru/
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
https://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

Don't delete timer of write event when it's delayed.

Jiuzhou Cui 244 December 26, 2023 09:58PM

Re: Don't delete timer of write event when it's delayed.

Maxim Dounin 56 December 27, 2023 06:20AM

Re:Re: Don't delete timer of write event when it's delayed.

Jiuzhou Cui 57 December 27, 2023 07:40AM

Re: Re: Don't delete timer of write event when it's delayed.

Maxim Dounin 52 December 27, 2023 09:00AM

Re:Re: Re: Don't delete timer of write event when it's delayed.

Jiuzhou Cui 78 December 27, 2023 10:04PM



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

Online Users

Guests: 311
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready