Welcome! Log In Create A New Profile

Advanced

Re: [PATCH 1 of 3] QUIC: set stream error flag on reset

Sergey Kandaurov
January 06, 2023 06:18AM
> On 5 Jan 2023, at 19:31, Roman Arutyunyan <arut@nginx.com> wrote:
>
> src/event/quic/ngx_event_quic_streams.c | 14 ++++++++++++--
> 1 files changed, 12 insertions(+), 2 deletions(-)
>
>
> # HG changeset patch
> # User Roman Arutyunyan <arut@nginx.com>
> # Date 1672932528 -14400
> # Thu Jan 05 19:28:48 2023 +0400
> # Branch quic
> # Node ID 480300240a4ea0e03e656039b9498c78b5adc21e
> # Parent 987bee4363d10895f4bd1a40fc4347c49763e90f
> QUIC: set stream error flag on reset.
>
> Now, when RESET_STREAM is sent or received, or when streams are closed, stream
> connection error flag is set. Previously, only stream state was changed, which
> resulted in setting the error flag only after calling
> recv()/send()/send_chain(). However, there are cases when none of these
> functions is called, but it's still important to know if the stream is being
> closed. For example, when an HTTP/3 request stream is blocked on insert count,
> receiving RESET_STREAM should trigger stream closure, which was not the case.

To make stream closure work when receiving RESET_STREAM, for a stream that
blocks on insert count, the read event should be active, so it is posted.
It could be made active with ngx_handle_read_event(), but since rev->ready
remains set, this prevents from setting rev->active = 1.

>
> The change also fixes ngx_http_test_reading() and
> ngx_http_upstream_check_broken_connection() with QUIC streams.
>
> diff --git a/src/event/quic/ngx_event_quic_streams.c b/src/event/quic/ngx_event_quic_streams.c
> --- a/src/event/quic/ngx_event_quic_streams.c
> +++ b/src/event/quic/ngx_event_quic_streams.c
> @@ -203,6 +203,9 @@ ngx_quic_close_streams(ngx_connection_t
> continue;
> }
>
> + sc->read->error = 1;
> + sc->write->error = 1;
> +
> ngx_quic_set_event(sc->read);
> ngx_quic_set_event(sc->write);
>
> @@ -245,6 +248,10 @@ ngx_quic_do_reset_stream(ngx_quic_stream
> qs->send_state = NGX_QUIC_STREAM_SEND_RESET_SENT;
> qs->send_final_size = qs->send_offset;
>
> + if (qs->connection) {
> + qs->connection->write->error = 1;
> + }
> +
> pc = qs->parent;
> qc = ngx_quic_get_connection(pc);
>
> @@ -797,7 +804,6 @@ ngx_quic_stream_recv(ngx_connection_t *c
> || qs->recv_state == NGX_QUIC_STREAM_RECV_RESET_READ)
> {
> qs->recv_state = NGX_QUIC_STREAM_RECV_RESET_READ;
> - rev->error = 1;
> return NGX_ERROR;
> }
>
> @@ -1375,6 +1381,7 @@ ngx_int_t
> ngx_quic_handle_reset_stream_frame(ngx_connection_t *c,
> ngx_quic_header_t *pkt, ngx_quic_reset_stream_frame_t *f)
> {
> + ngx_event_t *rev;
> ngx_quic_stream_t *qs;
> ngx_quic_connection_t *qc;
>
> @@ -1431,7 +1438,10 @@ ngx_quic_handle_reset_stream_frame(ngx_c
> return ngx_quic_close_stream(qs);
> }
>
> - ngx_quic_set_event(qs->connection->read);
> + rev = qs->connection->read;
> + rev->error = 1;
> +
> + ngx_quic_set_event(rev);
>
> return NGX_OK;
> }

--
Sergey Kandaurov
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
https://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[PATCH 0 of 3] HTTP/3 insert count block improvements

Roman Arutyunyan 524 January 05, 2023 10:32AM

[PATCH 1 of 3] QUIC: set stream error flag on reset

Roman Arutyunyan 125 January 05, 2023 10:32AM

Re: [PATCH 1 of 3] QUIC: set stream error flag on reset

Sergey Kandaurov 132 January 06, 2023 06:18AM

[PATCH 2 of 3] HTTP/3: trigger 400 (Bad Request) on stream error while blocked

Roman Arutyunyan 139 January 05, 2023 10:32AM

[PATCH 3 of 3] HTTP/3: insert count block timeout

Roman Arutyunyan 152 January 05, 2023 10:32AM

[PATCH 0 of 4] HTTP/3 insert count block improvements

Roman Arutyunyan 131 January 10, 2023 08:30AM

[PATCH 1 of 4] QUIC: automatically add and never delete stream events

Roman Arutyunyan 126 January 10, 2023 08:30AM

[PATCH 2 of 4] QUIC: set stream error flag on reset

Roman Arutyunyan 137 January 10, 2023 08:30AM

[PATCH 3 of 4] HTTP/3: trigger 400 (Bad Request) on stream error while blocked

Roman Arutyunyan 148 January 10, 2023 08:30AM

[PATCH 4 of 4] HTTP/3: insert count block timeout

Roman Arutyunyan 130 January 10, 2023 08:30AM

Re: [PATCH 0 of 4] HTTP/3 insert count block improvements

Sergey Kandaurov 162 January 10, 2023 08:40AM



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

Online Users

Guests: 196
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready