]> git.kaiwu.me - nginx.git/commitdiff
QUIC: store QUIC connection fd in stream fake connection.
authorRoman Arutyunyan <arut@nginx.com>
Mon, 6 Sep 2021 13:59:00 +0000 (16:59 +0300)
committerRoman Arutyunyan <arut@nginx.com>
Mon, 6 Sep 2021 13:59:00 +0000 (16:59 +0300)
Previously it had -1 as fd.  This fixes proxying, which relies on downstream
connection having a real fd.  Also, this reduces diff to the default branch for
ngx_close_connection().

src/core/ngx_connection.c
src/event/quic/ngx_event_quic_streams.c

index 974f48c9a7773905525836870dce520bcb3e21c9..4a7d2fe79656646c227884b98ca266a7763502fb 100644 (file)
@@ -1185,6 +1185,11 @@ ngx_close_connection(ngx_connection_t *c)
     ngx_uint_t    log_error, level;
     ngx_socket_t  fd;
 
+    if (c->fd == (ngx_socket_t) -1) {
+        ngx_log_error(NGX_LOG_ALERT, c->log, 0, "connection already closed");
+        return;
+    }
+
     if (c->read->timer_set) {
         ngx_del_timer(c->read);
     }
@@ -1193,7 +1198,7 @@ ngx_close_connection(ngx_connection_t *c)
         ngx_del_timer(c->write);
     }
 
-    if (!c->shared && c->fd != (ngx_socket_t) -1) {
+    if (!c->shared) {
         if (ngx_del_conn) {
             ngx_del_conn(c, NGX_CLOSE_EVENT);
 
@@ -1225,11 +1230,6 @@ ngx_close_connection(ngx_connection_t *c)
 
     ngx_free_connection(c);
 
-    if (c->fd == (ngx_socket_t) -1) {
-        ngx_log_debug0(NGX_LOG_DEBUG_CORE, c->log, 0, "connection has no fd");
-        return;
-    }
-
     fd = c->fd;
     c->fd = (ngx_socket_t) -1;
 
index ef8a9df47ee48c05e3fb352c6d4daae6ad2e2e90..a4f4cb57cce4e54b5fb2309c70aba429302c5703 100644 (file)
@@ -440,6 +440,8 @@ ngx_quic_create_stream(ngx_connection_t *c, uint64_t id)
     qs->connection = sc;
 
     sc->quic = qs;
+    sc->fd = c->fd;
+    sc->shared = 1;
     sc->type = SOCK_STREAM;
     sc->pool = pool;
     sc->ssl = c->ssl;