Welcome! Log In Create A New Profile

Advanced

Re: [PATCH 2 of 3] HTTP/3: proper uni stream closure detection

Vladimir Homutov
January 31, 2022 05:44AM
On Mon, Jan 31, 2022 at 10:34:07AM +0300, Roman Arutyunyan wrote:
> # HG changeset patch
> # User Roman Arutyunyan <arut@nginx.com>
> # Date 1643611590 -10800
> # Mon Jan 31 09:46:30 2022 +0300
> # Branch quic
> # Node ID d3c6dea9454c48ded14b8c087dffc4dea46f78ef
> # Parent 8dcb9908989401d750b14fe5dccf444a5485c23d
> HTTP/3: proper uni stream closure detection.
>
> Previously, closure detection for server-initiated uni streams was not properly
> implemented. Instead, HTTP/3 code relied on QUIC code posting the read event
> and setting rev->error when it needed to close the stream. Then, regular
> uni stream read handler called c->recv() and received error, which closed the
> stream. This was an ad-hoc solution. If, for whatever reason, the read
> handler was called earlier, c->recv() would return 0, which would also close
> the stream.
>
> Now server-initiated uni streams have a separate read event handler for
> tracking stream closure. The handler calls c->recv(), which normally returns
> 0, but may return error in case of closure.
>
> diff --git a/src/http/v3/ngx_http_v3_uni.c b/src/http/v3/ngx_http_v3_uni.c
> --- a/src/http/v3/ngx_http_v3_uni.c
> +++ b/src/http/v3/ngx_http_v3_uni.c
> @@ -26,6 +26,7 @@ typedef struct {
>
> static void ngx_http_v3_close_uni_stream(ngx_connection_t *c);
> static void ngx_http_v3_uni_read_handler(ngx_event_t *rev);
> +static void ngx_http_v3_dummy_read_handler(ngx_event_t *wev);
> static void ngx_http_v3_dummy_write_handler(ngx_event_t *wev);
> static void ngx_http_v3_push_cleanup(void *data);
> static ngx_connection_t *ngx_http_v3_get_uni_stream(ngx_connection_t *c,
> @@ -252,6 +253,32 @@ failed:
>
>
> static void
> +ngx_http_v3_dummy_read_handler(ngx_event_t *rev)

should it be ngx_http_v3_uni_dummy_read_handler?

> +{
> + u_char ch;
> + ngx_connection_t *c;
> +
> + c = rev->data;
> +
> + ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http3 dummy read handler");
> +
> + if (rev->ready) {
> + if (c->recv(c, &ch, 1) != 0) {
> + ngx_http_v3_finalize_connection(c, NGX_HTTP_V3_ERR_NO_ERROR, NULL);
> + ngx_http_v3_close_uni_stream(c);
> + return;
> + }
> + }
> +
> + if (ngx_handle_read_event(rev, 0) != NGX_OK) {
> + ngx_http_v3_finalize_connection(c, NGX_HTTP_V3_ERR_INTERNAL_ERROR,
> + NULL);
> + ngx_http_v3_close_uni_stream(c);
> + }
> +}
> +
> +
> +static void
> ngx_http_v3_dummy_write_handler(ngx_event_t *wev)
> {
> ngx_connection_t *c;
> @@ -393,7 +420,7 @@ ngx_http_v3_get_uni_stream(ngx_connectio
>
> sc->data = us;
>
> - sc->read->handler = ngx_http_v3_uni_read_handler;
> + sc->read->handler = ngx_http_v3_dummy_read_handler;
> sc->write->handler = ngx_http_v3_dummy_write_handler;
>
> if (index >= 0) {
> @@ -409,6 +436,8 @@ ngx_http_v3_get_uni_stream(ngx_connectio
> goto failed;
> }
>
> + ngx_post_event(sc->read, &ngx_posted_events);
> +
> return sc;
>
> failed:

Looks ok
_______________________________________________
nginx-devel mailing list -- nginx-devel@nginx.org
To unsubscribe send an email to nginx-devel-leave@nginx.org
Subject Author Views Posted

[PATCH 0 of 2] QUIC stream states and events

Roman Arutyunyan 361 January 26, 2022 04:10AM

[PATCH 1 of 2] QUIC: introduced explicit stream states

Roman Arutyunyan 97 January 26, 2022 04:12AM

[PATCH 2 of 2] QUIC: stream event setting function

Roman Arutyunyan 148 January 26, 2022 04:14AM

[PATCH 0 of 3] QUIC stream states and events

Roman Arutyunyan 100 January 31, 2022 02:36AM

[PATCH 1 of 3] QUIC: introduced explicit stream states

Roman Arutyunyan 93 January 31, 2022 02:38AM

Re: [PATCH 1 of 3] QUIC: introduced explicit stream states

Vladimir Homutov 87 January 31, 2022 05:20AM

Re: [PATCH 1 of 3] QUIC: introduced explicit stream states

Roman Arutyunyan 93 January 31, 2022 10:14AM

[PATCH 2 of 3] HTTP/3: proper uni stream closure detection

Roman Arutyunyan 120 January 31, 2022 02:40AM

Re: [PATCH 2 of 3] HTTP/3: proper uni stream closure detection

Vladimir Homutov 78 January 31, 2022 05:44AM

Re: [PATCH 2 of 3] HTTP/3: proper uni stream closure detection

Roman Arutyunyan 92 January 31, 2022 10:16AM

[PATCH 3 of 3] QUIC: stream event setting function

Roman Arutyunyan 95 January 31, 2022 02:42AM

Re: [PATCH 3 of 3] QUIC: stream event setting function

Vladimir Homutov 106 January 31, 2022 07:22AM

[PATCH 0 of 4] QUIC stream states and events

Roman Arutyunyan 177 January 31, 2022 10:24AM

[PATCH 1 of 4] QUIC: introduced explicit stream states

Roman Arutyunyan 129 January 31, 2022 10:26AM

[PATCH 2 of 4] HTTP/3: proper uni stream closure detection

Roman Arutyunyan 103 January 31, 2022 10:28AM

[PATCH 3 of 4] QUIC: style

Roman Arutyunyan 103 January 31, 2022 10:30AM

[PATCH 4 of 4] QUIC: stream event setting function

Roman Arutyunyan 144 January 31, 2022 10:32AM

Re: [PATCH 0 of 4] QUIC stream states and events

Vladimir Homutov 136 January 31, 2022 12:16PM



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

Online Users

Guests: 287
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