Welcome! Log In Create A New Profile

Advanced

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

Roman Arutyunyan
September 08, 2022 05:10AM
# HG changeset patch
# User Roman Arutyunyan <arut@nginx.com>
# Date 1662564313 -14400
# Wed Sep 07 19:25:13 2022 +0400
# Branch quic
# Node ID b4662fc66f1e8388f54d988777b741964892cec2
# Parent a3be42d42e7e6e6a941adb458cab201ff2cce8ce
QUIC: post close event for connection close.

Previously, close event was used only for close timeout, while read event was
used for posting connection close.

diff --git a/src/event/quic/ngx_event_quic.c b/src/event/quic/ngx_event_quic.c
--- a/src/event/quic/ngx_event_quic.c
+++ b/src/event/quic/ngx_event_quic.c
@@ -15,8 +15,7 @@ static ngx_quic_connection_t *ngx_quic_n
static ngx_int_t ngx_quic_handle_stateless_reset(ngx_connection_t *c,
ngx_quic_header_t *pkt);
static void ngx_quic_input_handler(ngx_event_t *rev);
-
-static void ngx_quic_close_timer_handler(ngx_event_t *ev);
+static void ngx_quic_close_handler(ngx_event_t *ev);

static ngx_int_t ngx_quic_handle_datagram(ngx_connection_t *c, ngx_buf_t *b,
ngx_quic_conf_t *conf);
@@ -283,6 +282,11 @@ ngx_quic_new_connection(ngx_connection_t
qc->push.handler = ngx_quic_push_handler;
qc->push.cancelable = 1;

+ qc->close.log = c->log;
+ qc->close.data = c;
+ qc->close.handler = ngx_quic_close_handler;
+ qc->close.cancelable = 1;
+
qc->path_validation.log = c->log;
qc->path_validation.data = c;
qc->path_validation.handler = ngx_quic_path_validation_handler;
@@ -420,19 +424,11 @@ ngx_quic_input_handler(ngx_event_t *rev)
return;
}

- if (!rev->ready) {
- if (qc->closing) {
- ngx_quic_close_connection(c, NGX_OK);
-
- } else if (qc->shutdown) {
- ngx_quic_shutdown_quic(c);
- }
-
+ b = c->udp->buffer;
+ if (b == NULL) {
return;
}

- b = c->udp->buffer;
-
rc = ngx_quic_handle_datagram(c, b, NULL);

if (rc == NGX_ERROR) {
@@ -520,11 +516,6 @@ ngx_quic_close_connection(ngx_connection
qc->error_reason ? qc->error_reason : "");

if (rc == NGX_OK) {
- qc->close.log = c->log;
- qc->close.data = c;
- qc->close.handler = ngx_quic_close_timer_handler;
- qc->close.cancelable = 1;
-
ctx = ngx_quic_get_send_ctx(qc, qc->error_level);
ngx_add_timer(&qc->close, 3 * ngx_quic_pto(c, ctx));
}
@@ -570,6 +561,10 @@ ngx_quic_close_connection(ngx_connection
return;
}

+ if (qc->close.posted) {
+ ngx_delete_posted_event(&qc->close);
+ }
+
ngx_quic_close_sockets(c);

ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, 0, "quic close completed");
@@ -633,14 +628,22 @@ ngx_quic_shutdown_connection(ngx_connect


static void
-ngx_quic_close_timer_handler(ngx_event_t *ev)
+ngx_quic_close_handler(ngx_event_t *ev)
{
- ngx_connection_t *c;
+ ngx_connection_t *c;
+ ngx_quic_connection_t *qc;

- ngx_log_debug0(NGX_LOG_DEBUG_EVENT, ev->log, 0, "quic close timer");
+ ngx_log_debug0(NGX_LOG_DEBUG_EVENT, ev->log, 0, "quic close handler");

c = ev->data;
- ngx_quic_close_connection(c, NGX_DONE);
+ qc = ngx_quic_get_connection(c);
+
+ if (qc->closing) {
+ ngx_quic_close_connection(c, NGX_OK);
+
+ } else if (qc->shutdown) {
+ ngx_quic_shutdown_quic(c);
+ }
}


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
@@ -1031,7 +1031,7 @@ ngx_quic_close_stream(ngx_quic_stream_t

if (qc->closing) {
/* schedule handler call to continue ngx_quic_close_connection() */
- ngx_post_event(pc->read, &ngx_posted_events);
+ ngx_post_event(&qc->close, &ngx_posted_events);
return NGX_OK;
}

@@ -1057,7 +1057,7 @@ ngx_quic_close_stream(ngx_quic_stream_t
}

if (qc->shutdown) {
- ngx_post_event(pc->read, &ngx_posted_events);
+ ngx_post_event(&qc->close, &ngx_posted_events);
}

return NGX_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 connection reuse

Roman Arutyunyan 1407 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 208 May 18, 2022 03:04AM

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

Sergey Kandaurov 212 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 197 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 202 June 23, 2022 12:00PM

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

Roman Arutyunyan 319 June 23, 2022 12:00PM

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

Sergey Kandaurov 205 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 180 August 02, 2022 11:46AM

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

Roman Arutyunyan 146 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 175 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 189 June 23, 2022 12:00PM

[PATCH 0 of 9] QUIC connection reuse

Roman Arutyunyan 157 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 140 August 23, 2022 08:52AM

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

Roman Arutyunyan 141 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 138 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 131 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 112 November 28, 2022 11:12AM

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

Roman Arutyunyan 156 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 197 November 24, 2022 10:18AM

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

Sergey Kandaurov 122 November 28, 2022 12:42PM

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

Roman Arutyunyan 115 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 145 September 08, 2022 05:10AM

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

Sergey Kandaurov 130 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 198 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: 165
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