Welcome! Log In Create A New Profile

Advanced

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

Roman Arutyunyan
October 25, 2022 05:12AM
Hi,

On Thu, Oct 20, 2022 at 06:33:22PM +0400, Roman Arutyunyan wrote:
> Hi,
>
> On Thu, Oct 20, 2022 at 03:51:54PM +0400, Sergey Kandaurov wrote:
> > On Thu, Sep 08, 2022 at 01:06:37PM +0400, Roman Arutyunyan wrote:
> > > # HG changeset patch
> > > # User Roman Arutyunyan <arut@nginx.com>
> > > # Date 1662627905 -14400
> > > # Thu Sep 08 13:05:05 2022 +0400
> > > # Branch quic
> > > # Node ID 8e58a27b320807aae00194b82e2c997287e3ad42
> > > # Parent 861d6897151fe6773898db6cfdb36f56403302c5
> > > QUIC: application init() callback.
> > >
> > > It's called after handshake completion or prior to the first early data stream
> > > creation. The callback should initialize application-level data before
> > > creating streams.
> > >
> > > HTTP/3 callback implementation sets keepalive timer and sends SETTINGS.
> > >
> > > Also, this allows to limit max handshake time in ngx_http_v3_init_stream().
> >
> > Also brings header timeout (to limit handshake time)
> > and keepalive timeout in hq mode.
>
> Looks like for hq keepalive timeout is now set in ngx_http_v3_init_stream()
> when main connection is created and in ngx_http_v3_init() at the end of
> handshake. After that it's neither set nor deleted. The code which does this,
> only works for http/3, but not hq. This should be addressed.

[..]

Attached is a patch which fixes this. Now there's a connection cleanup
which works for hq as well. The patch should be applied before the patch #10.

--
Roman Arutyunyan
# HG changeset patch
# User Roman Arutyunyan <arut@nginx.com>
# Date 1666687929 -14400
# Tue Oct 25 12:52:09 2022 +0400
# Branch quic
# Node ID 16896749d64305c5e873434e420c95f58823dd4f
# Parent e9285a39ff34aab034bb11b10e6ad723fd9cc2fa
HTTP/3: implement keepalive for hq.

Previously, keepalive timer was deleted in ngx_http_v3_wait_request_handler()
and set in request cleanup handler. This worked for HTTP/3 connections, but not
for hq connections. Now keepalive timer is deleted in
ngx_http_v3_init_request_stream() and set in connection cleanup handler,
which works both for HTTP/3 and hq.

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
@@ -12,6 +12,7 @@

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_connection(void *data);
static void ngx_http_v3_cleanup_request(void *data);
static void ngx_http_v3_process_request(ngx_event_t *rev);
static ngx_int_t ngx_http_v3_process_header(ngx_http_request_t *r,
@@ -134,6 +135,7 @@ ngx_http_v3_init_request_stream(ngx_conn
uint64_t n;
ngx_event_t *rev;
ngx_connection_t *pc;
+ ngx_pool_cleanup_t *cln;
ngx_http_connection_t *hc;
ngx_http_v3_session_t *h3c;
ngx_http_core_loc_conf_t *clcf;
@@ -189,6 +191,21 @@ ngx_http_v3_init_request_stream(ngx_conn
"reached maximum number of requests");
}

+ cln = ngx_pool_cleanup_add(c->pool, 0);
+ if (cln == NULL) {
+ ngx_http_close_connection(c);
+ return;
+ }
+
+ cln->handler = ngx_http_v3_cleanup_connection;
+ cln->data = c;
+
+ h3c->nrequests++;
+
+ if (h3c->keepalive.timer_set) {
+ ngx_del_timer(&h3c->keepalive);
+ }
+
rev = c->read;

#if (NGX_HTTP_V3_HQ)
@@ -225,7 +242,6 @@ 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_core_srv_conf_t *cscf;

@@ -346,13 +362,6 @@ ngx_http_v3_wait_request_handler(ngx_eve
cln->handler = ngx_http_v3_cleanup_request;
cln->data = r;

- h3c = ngx_http_v3_get_session(c);
- h3c->nrequests++;
-
- if (h3c->keepalive.timer_set) {
- ngx_del_timer(&h3c->keepalive);
- }
-
rev->handler = ngx_http_v3_process_request;
ngx_http_v3_process_request(rev);
}
@@ -387,20 +396,13 @@ ngx_http_v3_reset_stream(ngx_connection_


static void
-ngx_http_v3_cleanup_request(void *data)
+ngx_http_v3_cleanup_connection(void *data)
{
- ngx_http_request_t *r = data;
+ ngx_connection_t *c = data;

- ngx_connection_t *c;
ngx_http_v3_session_t *h3c;
ngx_http_core_loc_conf_t *clcf;

- c = r->connection;
-
- if (!r->response_sent) {
- c->error = 1;
- }
-
h3c = ngx_http_v3_get_session(c);

if (--h3c->nrequests == 0) {
@@ -411,6 +413,17 @@ ngx_http_v3_cleanup_request(void *data)


static void
+ngx_http_v3_cleanup_request(void *data)
+{
+ ngx_http_request_t *r = data;
+
+ if (!r->response_sent) {
+ r->connection->error = 1;
+ }
+}
+
+
+static void
ngx_http_v3_process_request(ngx_event_t *rev)
{
u_char *p;
_______________________________________________
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 1405 May 18, 2022 03:00AM

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

Roman Arutyunyan 204 May 18, 2022 03:02AM

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

Sergey Kandaurov 260 May 30, 2022 09:56AM

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

Roman Arutyunyan 195 June 02, 2022 09:42AM

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

Roman Arutyunyan 207 May 18, 2022 03:04AM

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

Sergey Kandaurov 209 May 30, 2022 05:56PM

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

Roman Arutyunyan 188 June 02, 2022 09:46AM

[PATCH 0 of 3] QUIC connection reuse

Roman Arutyunyan 195 June 02, 2022 09:54AM

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

Roman Arutyunyan 202 June 02, 2022 09:54AM

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

Sergey Kandaurov 193 June 06, 2022 06:44AM

[PATCH 0 of 8] QUIC connection reuse

Roman Arutyunyan 172 June 23, 2022 12:00PM

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

Roman Arutyunyan 201 June 23, 2022 12:00PM

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

Roman Arutyunyan 318 June 23, 2022 12:00PM

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

Sergey Kandaurov 203 August 02, 2022 09:50AM

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

Roman Arutyunyan 144 August 23, 2022 08:22AM

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

Roman Arutyunyan 225 June 23, 2022 12:00PM

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

Sergey Kandaurov 179 August 02, 2022 11:46AM

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

Roman Arutyunyan 144 August 23, 2022 08:30AM

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

Roman Arutyunyan 175 June 23, 2022 12:00PM

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

Roman Arutyunyan 174 June 23, 2022 12:00PM

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

Roman Arutyunyan 167 June 23, 2022 12:00PM

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

Roman Arutyunyan 163 June 23, 2022 12:00PM

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

Roman Arutyunyan 188 June 23, 2022 12:00PM

[PATCH 0 of 9] QUIC connection reuse

Roman Arutyunyan 154 August 23, 2022 08:52AM

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

Roman Arutyunyan 172 August 23, 2022 08:52AM

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

Roman Arutyunyan 139 August 23, 2022 08:52AM

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

Roman Arutyunyan 139 August 23, 2022 08:52AM

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

Roman Arutyunyan 144 August 23, 2022 08:52AM

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

Roman Arutyunyan 174 August 23, 2022 08:52AM

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

Roman Arutyunyan 162 August 23, 2022 08:54AM

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

Roman Arutyunyan 137 August 23, 2022 08:54AM

[PATCH 00 of 10] QUIC connection reuse

Roman Arutyunyan 139 September 08, 2022 05:08AM

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

Roman Arutyunyan 130 September 08, 2022 05:08AM

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

Roman Arutyunyan 144 September 08, 2022 05:10AM

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

Roman Arutyunyan 138 September 08, 2022 05:10AM

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

Roman Arutyunyan 136 September 08, 2022 05:10AM

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

Sergey Kandaurov 126 October 20, 2022 07:36AM

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

Roman Arutyunyan 151 October 20, 2022 09:56AM

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

Roman Arutyunyan 148 September 08, 2022 05:10AM

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

Sergey Kandaurov 111 November 28, 2022 11:12AM

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

Roman Arutyunyan 154 September 08, 2022 05:10AM

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

Sergey Kandaurov 159 October 20, 2022 07:52AM

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

Roman Arutyunyan 144 October 20, 2022 10:26AM

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

Roman Arutyunyan 196 November 24, 2022 10:18AM

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

Sergey Kandaurov 120 November 28, 2022 12:42PM

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

Roman Arutyunyan 113 November 29, 2022 09:02AM

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

Roman Arutyunyan 133 November 30, 2022 05:14AM

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

Roman Arutyunyan 141 September 08, 2022 05:10AM

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

Roman Arutyunyan 142 September 08, 2022 05:10AM

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

Sergey Kandaurov 129 October 20, 2022 07:54AM

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

Roman Arutyunyan 160 October 20, 2022 10:34AM

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

Roman Arutyunyan 197 October 25, 2022 05:12AM

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

Roman Arutyunyan 214 September 08, 2022 05:10AM



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

Online Users

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