Welcome! Log In Create A New Profile

Advanced

Re: [PATCH 07 of 10] HTTP/3: unified hq code with regular HTTP/3 code

Sergey Kandaurov
October 20, 2022 07:36AM
On Thu, Sep 08, 2022 at 01:06:34PM +0400, Roman Arutyunyan wrote:
> # HG changeset patch
> # User Roman Arutyunyan <arut@nginx.com>
> # Date 1662626426 -14400
> # Thu Sep 08 12:40:26 2022 +0400
> # Branch quic
> # Node ID 1dd6fabfdcb5b52af495f9d8fc00f64ae36a537c
> # Parent 28437cb91bd8624b30a4c841852504110b0f3f7d
> HTTP/3: unified hq code with regular HTTP/3 code.
>
> The change removes hq-specific request handler. Now hq requests are handled
> by the HTTP/3 request handler. This brings missing keepalive timeout feature
> to hq.

As discussed in private, this doesn't introduce keepalive timeout for hq,
as it's installed though HTTP/3-specific ngx_http_v3_wait_request_handler(),
while hq uses ngx_http_wait_request_handler(). Though, it appears later
by other means while reworking code for init callback.

>
> diff --git a/src/http/v3/ngx_http_v3.c b/src/http/v3/ngx_http_v3.c
> --- a/src/http/v3/ngx_http_v3.c
> +++ b/src/http/v3/ngx_http_v3.c
> @@ -17,10 +17,13 @@ static void ngx_http_v3_cleanup_session(
> ngx_int_t
> ngx_http_v3_init_session(ngx_connection_t *c)
> {
> - ngx_connection_t *pc;
> - ngx_pool_cleanup_t *cln;
> - ngx_http_connection_t *hc;
> - ngx_http_v3_session_t *h3c;
> + ngx_connection_t *pc;
> + ngx_pool_cleanup_t *cln;
> + ngx_http_connection_t *hc;
> + ngx_http_v3_session_t *h3c;
> +#if (NGX_HTTP_V3_HQ)
> + ngx_http_v3_srv_conf_t *h3scf;
> +#endif
>
> pc = c->quic->parent;
> hc = pc->data;
> @@ -39,6 +42,13 @@ ngx_http_v3_init_session(ngx_connection_
> h3c->max_push_id = (uint64_t) -1;
> h3c->goaway_push_id = (uint64_t) -1;
>
> +#if (NGX_HTTP_V3_HQ)
> + h3scf = ngx_http_get_module_srv_conf(hc->conf_ctx, ngx_http_v3_module);
> + if (h3scf->hq) {
> + h3c->hq = 1;
> + }
> +#endif
> +
> ngx_queue_init(&h3c->blocked);
> ngx_queue_init(&h3c->pushing);
>
> @@ -61,6 +71,12 @@ ngx_http_v3_init_session(ngx_connection_
>
> hc->v3_session = h3c;
>
> +#if (NGX_HTTP_V3_HQ)
> + if (h3c->hq) {
> + return NGX_OK;
> + }
> +#endif
> +
> return ngx_http_v3_send_settings(c);
>
> failed:
> diff --git a/src/http/v3/ngx_http_v3.h b/src/http/v3/ngx_http_v3.h
> --- a/src/http/v3/ngx_http_v3.h
> +++ b/src/http/v3/ngx_http_v3.h
> @@ -145,7 +145,10 @@ struct ngx_http_v3_session_s {
> off_t total_bytes;
> off_t payload_bytes;
>
> - ngx_uint_t goaway; /* unsigned goaway:1; */
> + unsigned goaway:1;
> +#if (NGX_HTTP_V3_HQ)
> + unsigned hq:1;
> +#endif
>
> ngx_connection_t *known_streams[NGX_HTTP_V3_MAX_KNOWN_STREAM];
> };
> diff --git a/src/http/v3/ngx_http_v3_request.c b/src/http/v3/ngx_http_v3_request.c
> --- a/src/http/v3/ngx_http_v3_request.c
> +++ b/src/http/v3/ngx_http_v3_request.c
> @@ -10,9 +10,6 @@
> #include <ngx_http.h>
>
>
> -#if (NGX_HTTP_V3_HQ)
> -static void ngx_http_v3_init_hq_stream(ngx_connection_t *c);
> -#endif
> static void ngx_http_v3_init_request_stream(ngx_connection_t *c);
> static void ngx_http_v3_wait_request_handler(ngx_event_t *rev);
> static void ngx_http_v3_cleanup_request(void *data);
> @@ -86,13 +83,6 @@ ngx_http_v3_init(ngx_connection_t *c)
> ngx_set_connection_log(c, clcf->error_log);
> }
>
> -#if (NGX_HTTP_V3_HQ)
> - if (h3scf->hq) {
> - ngx_http_v3_init_hq_stream(c);
> - return;
> - }
> -#endif
> -
> if (ngx_http_v3_init_session(c) != NGX_OK) {
> ngx_http_close_connection(c);
> return;
> @@ -107,83 +97,12 @@ ngx_http_v3_init(ngx_connection_t *c)
> }
>
>
> -#if (NGX_HTTP_V3_HQ)
> -
> -static void
> -ngx_http_v3_init_hq_stream(ngx_connection_t *c)
> -{
> - uint64_t n;
> - ngx_event_t *rev;
> - ngx_http_connection_t *hc;
> - ngx_http_core_loc_conf_t *clcf;
> - ngx_http_core_srv_conf_t *cscf;
> -
> - ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http3 init hq stream");
> -
> -#if (NGX_STAT_STUB)
> - (void) ngx_atomic_fetch_add(ngx_stat_active, 1);
> -#endif
> -
> - hc = c->data;
> -
> - /* Use HTTP/3 General Protocol Error Code 0x101 for finalization */
> -
> - if (c->quic->id & NGX_QUIC_STREAM_UNIDIRECTIONAL) {
> - ngx_quic_finalize_connection(c->quic->parent,
> - NGX_HTTP_V3_ERR_GENERAL_PROTOCOL_ERROR,
> - "unexpected uni stream");
> - ngx_http_close_connection(c);
> - return;
> - }
> -
> - clcf = ngx_http_get_module_loc_conf(hc->conf_ctx, ngx_http_core_module);
> -
> - n = c->quic->id >> 2;
> -
> - if (n >= clcf->keepalive_requests) {
> - ngx_quic_finalize_connection(c->quic->parent,
> - NGX_HTTP_V3_ERR_GENERAL_PROTOCOL_ERROR,
> - "reached maximum number of requests");
> - ngx_http_close_connection(c);
> - return;
> - }
> -
> - if (ngx_current_msec - c->quic->parent->start_time
> - > clcf->keepalive_time)
> - {
> - ngx_quic_finalize_connection(c->quic->parent,
> - NGX_HTTP_V3_ERR_GENERAL_PROTOCOL_ERROR,
> - "reached maximum time for requests");
> - ngx_http_close_connection(c);
> - return;
> - }
> -
> - rev = c->read;
> -
> - if (rev->ready) {
> - rev->handler(rev);
> - return;
> - }
> -
> - cscf = ngx_http_get_module_srv_conf(hc->conf_ctx, ngx_http_core_module);
> -
> - ngx_add_timer(rev, cscf->client_header_timeout);
> - ngx_reusable_connection(c, 1);
> -
> - if (ngx_handle_read_event(rev, 0) != NGX_OK) {
> - ngx_http_close_connection(c);
> - return;
> - }
> -}
> -
> -#endif
> -
> -
> static void
> ngx_http_v3_init_request_stream(ngx_connection_t *c)
> {
> uint64_t n;
> ngx_event_t *rev;
> + ngx_connection_t *pc;
> ngx_http_connection_t *hc;
> ngx_http_v3_session_t *h3c;
> ngx_http_core_loc_conf_t *clcf;
> @@ -216,15 +135,21 @@ ngx_http_v3_init_request_stream(ngx_conn
> return;
> }
>
> + pc = c->quic->parent;
> +
> if (n + 1 == clcf->keepalive_requests
> - || ngx_current_msec - c->quic->parent->start_time
> - > clcf->keepalive_time)
> + || ngx_current_msec - pc->start_time > clcf->keepalive_time)
> {
> h3c->goaway = 1;
>
> - if (ngx_http_v3_send_goaway(c, (n + 1) << 2) != NGX_OK) {
> - ngx_http_close_connection(c);
> - return;
> +#if (NGX_HTTP_V3_HQ)
> + if (!h3c->hq)
> +#endif
> + {
> + if (ngx_http_v3_send_goaway(c, (n + 1) << 2) != NGX_OK) {
> + ngx_http_close_connection(c);
> + return;
> + }
> }
>
> ngx_http_v3_shutdown_connection(c, NGX_HTTP_V3_ERR_NO_ERROR,
> @@ -232,8 +157,14 @@ ngx_http_v3_init_request_stream(ngx_conn
> }
>
> rev = c->read;
> - rev->handler = ngx_http_v3_wait_request_handler;
> - c->write->handler = ngx_http_empty_handler;
> +
> +#if (NGX_HTTP_V3_HQ)
> + if (!h3c->hq)
> +#endif
> + {
> + rev->handler = ngx_http_v3_wait_request_handler;
> + c->write->handler = ngx_http_empty_handler;
> + }
>
> if (rev->ready) {
> rev->handler(rev);
> @@ -261,8 +192,8 @@ ngx_http_v3_wait_request_handler(ngx_eve
> ngx_connection_t *c;
> ngx_pool_cleanup_t *cln;
> ngx_http_request_t *r;
> + ngx_http_v3_session_t *h3c;
> ngx_http_connection_t *hc;
> - ngx_http_v3_session_t *h3c;
> ngx_http_core_srv_conf_t *cscf;
>
> c = rev->data;
> @@ -401,13 +332,10 @@ ngx_http_v3_reset_connection(ngx_connect
>
> h3scf = ngx_http_v3_get_module_srv_conf(c, ngx_http_v3_module);
>
> + if (h3scf->max_table_capacity > 0 && !c->read->eof
> #if (NGX_HTTP_V3_HQ)
> - if (h3scf->hq) {
> - return;
> - }
> + && !h3scf->hq
> #endif
> -
> - if (h3scf->max_table_capacity > 0 && !c->read->eof
> && (c->quic->id & NGX_QUIC_STREAM_UNIDIRECTIONAL) == 0)
> {
> (void) ngx_http_v3_send_cancel_stream(c, c->quic->id);
> 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
> @@ -37,8 +37,23 @@ void
> ngx_http_v3_init_uni_stream(ngx_connection_t *c)
> {
> uint64_t n;
> +#if (NGX_HTTP_V3_HQ)
> + ngx_http_v3_session_t *h3c;
> +#endif
> ngx_http_v3_uni_stream_t *us;
>
> +#if (NGX_HTTP_V3_HQ)
> + h3c = ngx_http_v3_get_session(c);
> + if (h3c->hq) {
> + ngx_http_v3_finalize_connection(c,
> + NGX_HTTP_V3_ERR_STREAM_CREATION_ERROR,
> + "uni stream in hq mode");
> + c->data = NULL;
> + ngx_http_v3_close_uni_stream(c);
> + return;
> + }
> +#endif
> +
> ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http3 init uni stream");
>
> n = c->quic->id >> 2;
>
> _______________________________________________
> nginx-devel mailing list -- nginx-devel@nginx.org
> To unsubscribe send an email to nginx-devel-leave@nginx.org
_______________________________________________
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 connection reuse

Roman Arutyunyan 1410 May 18, 2022 03:00AM

[PATCH 1 of 2] QUIC: reusable and idle modes for main connection

Roman Arutyunyan 208 May 18, 2022 03:02AM

Re: [PATCH 1 of 2] QUIC: reusable and idle modes for main connection

Sergey Kandaurov 263 May 30, 2022 09:56AM

Re: [PATCH 1 of 2] QUIC: reusable and idle modes for main connection

Roman Arutyunyan 201 June 02, 2022 09:42AM

[PATCH 2 of 2] QUIC: init_streams() callback

Roman Arutyunyan 214 May 18, 2022 03:04AM

Re: [PATCH 2 of 2] QUIC: init_streams() callback

Sergey Kandaurov 215 May 30, 2022 05:56PM

Re: [PATCH 2 of 2] QUIC: init_streams() callback

Roman Arutyunyan 191 June 02, 2022 09:46AM

[PATCH 0 of 3] QUIC connection reuse

Roman Arutyunyan 200 June 02, 2022 09:54AM

[PATCH 2 of 3] QUIC: relocated early streams initialization

Roman Arutyunyan 207 June 02, 2022 09:54AM

Re: [PATCH 2 of 3] QUIC: relocated early streams initialization

Sergey Kandaurov 199 June 06, 2022 06:44AM

[PATCH 0 of 8] QUIC connection reuse

Roman Arutyunyan 179 June 23, 2022 12:00PM

[PATCH 2 of 8] QUIC: ngx_quic_terminate_connection() function

Roman Arutyunyan 207 June 23, 2022 12:00PM

[PATCH 1 of 8] QUIC: treat qc->error == -1 as a missing error

Roman Arutyunyan 322 June 23, 2022 12:00PM

Re: [PATCH 1 of 8] QUIC: treat qc->error == -1 as a missing error

Sergey Kandaurov 210 August 02, 2022 09:50AM

Re: [PATCH 1 of 8] QUIC: treat qc->error == -1 as a missing error

Roman Arutyunyan 149 August 23, 2022 08:22AM

[PATCH 4 of 8] QUIC: removed ngx_quic_shutdown_connection()

Roman Arutyunyan 230 June 23, 2022 12:00PM

Re: [PATCH 4 of 8] QUIC: removed ngx_quic_shutdown_connection()

Sergey Kandaurov 183 August 02, 2022 11:46AM

Re: [PATCH 4 of 8] QUIC: removed ngx_quic_shutdown_connection()

Roman Arutyunyan 149 August 23, 2022 08:30AM

[PATCH 5 of 8] HTTP/3: keepalive timer for hq mode

Roman Arutyunyan 179 June 23, 2022 12:00PM

[PATCH 8 of 8] QUIC: application init() callback

Roman Arutyunyan 180 June 23, 2022 12:00PM

[PATCH 3 of 8] QUIC: reusable mode for main connection

Roman Arutyunyan 170 June 23, 2022 12:00PM

[PATCH 7 of 8] HTTP/3: renamed functions

Roman Arutyunyan 167 June 23, 2022 12:00PM

[PATCH 6 of 8] QUIC: idle mode for main connection

Roman Arutyunyan 192 June 23, 2022 12:00PM

[PATCH 0 of 9] QUIC connection reuse

Roman Arutyunyan 160 August 23, 2022 08:52AM

[PATCH 5 of 9] QUIC: do not send MAX_STREAMS in shutdown state

Roman Arutyunyan 176 August 23, 2022 08:52AM

[PATCH 4 of 9] QUIC: defer stream removal until all its data is acked

Roman Arutyunyan 146 August 23, 2022 08:52AM

[PATCH 1 of 9] QUIC: treat qc->error == -1 as a missing error

Roman Arutyunyan 144 August 23, 2022 08:52AM

[PATCH 7 of 9] QUIC: idle mode for main connection

Roman Arutyunyan 149 August 23, 2022 08:52AM

[PATCH 8 of 9] HTTP/3: renamed functions

Roman Arutyunyan 180 August 23, 2022 08:52AM

[PATCH 9 of 9] QUIC: application init() callback

Roman Arutyunyan 166 August 23, 2022 08:54AM

[PATCH 6 of 9] HTTP/3: unified hq code with HTTP/3 code

Roman Arutyunyan 143 August 23, 2022 08:54AM

[PATCH 00 of 10] QUIC connection reuse

Roman Arutyunyan 142 September 08, 2022 05:08AM

[PATCH 06 of 10] QUIC: do not send MAX_STREAMS in shutdown state

Roman Arutyunyan 135 September 08, 2022 05:08AM

[PATCH 03 of 10] QUIC: post close event for connection close

Roman Arutyunyan 148 September 08, 2022 05:10AM

[PATCH 02 of 10] QUIC: made ngx_quic_finalize_connecion() more graceful

Roman Arutyunyan 141 September 08, 2022 05:10AM

[PATCH 07 of 10] HTTP/3: unified hq code with regular HTTP/3 code

Roman Arutyunyan 142 September 08, 2022 05:10AM

Re: [PATCH 07 of 10] HTTP/3: unified hq code with regular HTTP/3 code

Sergey Kandaurov 129 October 20, 2022 07:36AM

Re: [PATCH 07 of 10] HTTP/3: unified hq code with regular HTTP/3 code

Roman Arutyunyan 154 October 20, 2022 09:56AM

[PATCH 04 of 10] QUIC: reusable mode for main connection

Roman Arutyunyan 152 September 08, 2022 05:10AM

Re: [PATCH 04 of 10] QUIC: reusable mode for main connection

Sergey Kandaurov 117 November 28, 2022 11:12AM

[PATCH 08 of 10] QUIC: idle mode for main connection

Roman Arutyunyan 159 September 08, 2022 05:10AM

Re: [PATCH 08 of 10] QUIC: idle mode for main connection

Sergey Kandaurov 164 October 20, 2022 07:52AM

Re: [PATCH 08 of 10] QUIC: idle mode for main connection

Roman Arutyunyan 150 October 20, 2022 10:26AM

Re: [PATCH 08 of 10] QUIC: idle mode for main connection

Roman Arutyunyan 212 November 24, 2022 10:18AM

Re: [PATCH 08 of 10] QUIC: idle mode for main connection

Sergey Kandaurov 125 November 28, 2022 12:42PM

Re: [PATCH 08 of 10] QUIC: idle mode for main connection

Roman Arutyunyan 118 November 29, 2022 09:02AM

Re: [PATCH 08 of 10] QUIC: idle mode for main connection

Roman Arutyunyan 138 November 30, 2022 05:14AM

[PATCH 05 of 10] QUIC: defer stream removal until all its data is acked

Roman Arutyunyan 144 September 08, 2022 05:10AM

[PATCH 10 of 10] QUIC: application init() callback

Roman Arutyunyan 148 September 08, 2022 05:10AM

Re: [PATCH 10 of 10] QUIC: application init() callback

Sergey Kandaurov 135 October 20, 2022 07:54AM

Re: [PATCH 10 of 10] QUIC: application init() callback

Roman Arutyunyan 163 October 20, 2022 10:34AM

Re: [PATCH 10 of 10] QUIC: application init() callback

Roman Arutyunyan 203 October 25, 2022 05:12AM

[PATCH 09 of 10] HTTP/3: renamed functions

Roman Arutyunyan 218 September 08, 2022 05:10AM



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

Online Users

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