Welcome! Log In Create A New Profile

Advanced

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

Roman Arutyunyan
January 31, 2022 02:42AM
# HG changeset patch
# User Roman Arutyunyan <arut@nginx.com>
# Date 1643187691 -10800
# Wed Jan 26 12:01:31 2022 +0300
# Branch quic
# Node ID 9f5c59800a9894aad00b06df93ec454aab97372d
# Parent d3c6dea9454c48ded14b8c087dffc4dea46f78ef
QUIC: stream event setting function.

The function ngx_quic_set_event() is now called instead of posting events
directly.

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
@@ -34,6 +34,7 @@ static ngx_int_t ngx_quic_control_flow(n
static ngx_int_t ngx_quic_update_flow(ngx_connection_t *c, uint64_t last);
static ngx_int_t ngx_quic_update_max_stream_data(ngx_connection_t *c);
static ngx_int_t ngx_quic_update_max_data(ngx_connection_t *c);
+static void ngx_quic_set_event(ngx_event_t *ev);


ngx_connection_t *
@@ -156,7 +157,6 @@ ngx_quic_close_streams(ngx_connection_t
{
ngx_pool_t *pool;
ngx_queue_t *q;
- ngx_event_t *rev, *wev;
ngx_rbtree_t *tree;
ngx_rbtree_node_t *node;
ngx_quic_stream_t *qs;
@@ -195,17 +195,8 @@ ngx_quic_close_streams(ngx_connection_t
qs->recv_state = NGX_QUIC_STREAM_RECV_RESET_RECVD;
qs->send_state = NGX_QUIC_STREAM_SEND_RESET_SENT;

- rev = qs->connection->read;
- rev->ready = 1;
-
- wev = qs->connection->write;
- wev->ready = 1;
-
- ngx_post_event(rev, &ngx_posted_events);
-
- if (rev->timer_set) {
- ngx_del_timer(rev);
- }
+ ngx_quic_set_event(qs->connection->read);
+ ngx_quic_set_event(qs->connection->write);

#if (NGX_DEBUG)
ns++;
@@ -1024,7 +1015,6 @@ ngx_quic_handle_stream_frame(ngx_connect
ngx_quic_frame_t *frame)
{
uint64_t last;
- ngx_event_t *rev;
ngx_connection_t *sc;
ngx_quic_stream_t *qs;
ngx_quic_connection_t *qc;
@@ -1102,12 +1092,7 @@ ngx_quic_handle_stream_frame(ngx_connect
}

if (f->offset == qs->recv_offset) {
- rev = sc->read;
- rev->ready = 1;
-
- if (rev->active) {
- ngx_post_event(rev, &ngx_posted_events);
- }
+ ngx_quic_set_event(sc->read);
}

return NGX_OK;
@@ -1118,7 +1103,6 @@ ngx_int_t
ngx_quic_handle_max_data_frame(ngx_connection_t *c,
ngx_quic_max_data_frame_t *f)
{
- ngx_event_t *wev;
ngx_rbtree_t *tree;
ngx_rbtree_node_t *node;
ngx_quic_stream_t *qs;
@@ -1140,12 +1124,7 @@ ngx_quic_handle_max_data_frame(ngx_conne
node = ngx_rbtree_next(tree, node))
{
qs = (ngx_quic_stream_t *) node;
- wev = qs->connection->write;
-
- if (wev->active) {
- wev->ready = 1;
- ngx_post_event(wev, &ngx_posted_events);
- }
+ ngx_quic_set_event(qs->connection->write);
}
}

@@ -1206,7 +1185,6 @@ ngx_quic_handle_max_stream_data_frame(ng
ngx_quic_header_t *pkt, ngx_quic_max_stream_data_frame_t *f)
{
uint64_t sent;
- ngx_event_t *wev;
ngx_quic_stream_t *qs;
ngx_quic_connection_t *qc;

@@ -1236,12 +1214,7 @@ ngx_quic_handle_max_stream_data_frame(ng
sent = qs->connection->sent;

if (sent >= qs->send_max_data) {
- wev = qs->connection->write;
-
- if (wev->active) {
- wev->ready = 1;
- ngx_post_event(wev, &ngx_posted_events);
- }
+ ngx_quic_set_event(qs->connection->write);
}

qs->send_max_data = f->limit;
@@ -1254,7 +1227,6 @@ 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_connection_t *sc;
ngx_quic_stream_t *qs;
ngx_quic_connection_t *qc;
@@ -1308,12 +1280,7 @@ ngx_quic_handle_reset_stream_frame(ngx_c
return NGX_ERROR;
}

- rev = sc->read;
- rev->ready = 1;
-
- if (rev->active) {
- ngx_post_event(rev, &ngx_posted_events);
- }
+ ngx_quic_set_event(qs->connection->read);

return NGX_OK;
}
@@ -1323,7 +1290,6 @@ ngx_int_t
ngx_quic_handle_stop_sending_frame(ngx_connection_t *c,
ngx_quic_header_t *pkt, ngx_quic_stop_sending_frame_t *f)
{
- ngx_event_t *wev;
ngx_quic_stream_t *qs;
ngx_quic_connection_t *qc;

@@ -1350,12 +1316,7 @@ ngx_quic_handle_stop_sending_frame(ngx_c
return NGX_ERROR;
}

- wev = qs->connection->write;
-
- if (wev->active) {
- wev->ready = 1;
- ngx_post_event(wev, &ngx_posted_events);
- }
+ ngx_quic_set_event(qs->connection->write);

return NGX_OK;
}
@@ -1394,7 +1355,6 @@ void
ngx_quic_handle_stream_ack(ngx_connection_t *c, ngx_quic_frame_t *f)
{
uint64_t sent, unacked;
- ngx_event_t *wev;
ngx_quic_stream_t *qs;
ngx_quic_connection_t *qc;

@@ -1405,13 +1365,11 @@ ngx_quic_handle_stream_ack(ngx_connectio
return;
}

- wev = qs->connection->write;
sent = qs->connection->sent;
unacked = sent - qs->acked;

- if (unacked >= qc->conf->stream_buffer_size && wev->active) {
- wev->ready = 1;
- ngx_post_event(wev, &ngx_posted_events);
+ if (unacked >= qc->conf->stream_buffer_size) {
+ ngx_quic_set_event(qs->connection->write);
}

qs->acked += f->u.stream.length;
@@ -1585,6 +1543,17 @@ ngx_quic_update_max_data(ngx_connection_
}


+static void
+ngx_quic_set_event(ngx_event_t *ev)
+{
+ ev->ready = 1;
+
+ if (ev->active) {
+ ngx_post_event(ev, &ngx_posted_events);
+ }
+}
+
+
ngx_int_t
ngx_quic_handle_read_event(ngx_event_t *rev, ngx_uint_t flags)
{
_______________________________________________
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 96 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 99 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 86 January 31, 2022 05:20AM

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

Roman Arutyunyan 92 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 94 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: 196
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