]> git.kaiwu.me - nginx.git/commitdiff
Do not set timers after the connection is closed.
authorVladimir Homutov <vl@nginx.com>
Sat, 4 Apr 2020 19:27:29 +0000 (22:27 +0300)
committerVladimir Homutov <vl@nginx.com>
Sat, 4 Apr 2020 19:27:29 +0000 (22:27 +0300)
The qc->closing flag is set when a connection close is initiated for the first
time.

No timers will be set if the flag is active.

TODO: this is a temporary solution to avoid running timer handlers after
connection (and it's pool) was destroyed.  It looks like currently we have
no clear policy of connection closing in regard to timers.

src/event/ngx_event_quic.c

index ab0cf2cd75d32d9a926cc1a891cf09e8844177c1..d1757246df3720c6c6d3fe8219c91c1a63bfd1aa 100644 (file)
@@ -704,6 +704,7 @@ ngx_quic_close_connection(ngx_connection_t *c)
     qc = c->quic;
 
     if (qc) {
+        qc->closing = 1;
         tree = &qc->streams.tree;
 
         if (tree->root != tree->sentinel) {
@@ -727,6 +728,10 @@ ngx_quic_close_connection(ngx_connection_t *c)
 
                 ngx_post_event(rev, &ngx_posted_events);
 
+                if (rev->timer_set) {
+                    ngx_del_timer(rev);
+                }
+
 #if (NGX_DEBUG)
                 ns++;
 #endif
@@ -735,7 +740,6 @@ ngx_quic_close_connection(ngx_connection_t *c)
             ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0,
                            "quic connection has %ui active streams", ns);
 
-            qc->closing = 1;
             return;
         }
 
@@ -1622,7 +1626,7 @@ ngx_quic_output(ngx_connection_t *c)
         }
     }
 
-    if (!qc->send_timer_set) {
+    if (!qc->send_timer_set && !qc->closing) {
         qc->send_timer_set = 1;
         ngx_add_timer(c->read, qc->tp.max_idle_timeout);
     }