]> git.kaiwu.me - nginx.git/commitdiff
Fixed sanitizer errors.
authorRoman Arutyunyan <arut@nginx.com>
Fri, 13 Mar 2020 17:44:32 +0000 (20:44 +0300)
committerRoman Arutyunyan <arut@nginx.com>
Fri, 13 Mar 2020 17:44:32 +0000 (20:44 +0300)
src/core/ngx_connection.c
src/event/ngx_event_quic.c

index 33682532aff9b5f0fa2d7118acb62288d11518d6..9ec1cd7aca6147fa4ba7214f3990754a3bf7686f 100644 (file)
@@ -1178,11 +1178,6 @@ 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);
     }
@@ -1191,7 +1186,7 @@ ngx_close_connection(ngx_connection_t *c)
         ngx_del_timer(c->write);
     }
 
-    if (!c->shared) {
+    if (!c->shared && c->fd != (ngx_socket_t) -1) {
         if (ngx_del_conn) {
             ngx_del_conn(c, NGX_CLOSE_EVENT);
 
@@ -1223,6 +1218,11 @@ 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 f290cbe95613ad08509cf4ca2f5e1b2885f630f1..7819e3f51debd9a53d7dc9bff98ef9515cefddb4 100644 (file)
@@ -1934,6 +1934,7 @@ static ssize_t
 ngx_quic_stream_send(ngx_connection_t *c, u_char *buf, size_t size)
 {
     u_char                  *p;
+    ngx_connection_t        *pc;
     ngx_quic_frame_t        *frame;
     ngx_quic_stream_t       *qs;
     ngx_quic_connection_t   *qc;
@@ -1942,8 +1943,8 @@ ngx_quic_stream_send(ngx_connection_t *c, u_char *buf, size_t size)
     ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, "quic send: %uz", size);
 
     qs = c->qs;
-    qc = qs->parent->quic;
-
+    pc = qs->parent;
+    qc = pc->quic;
 
     // XXX: get direct pointer from stream structure?
     sn = ngx_quic_stream_lookup(&qc->stree, qs->id);
@@ -1952,12 +1953,12 @@ ngx_quic_stream_send(ngx_connection_t *c, u_char *buf, size_t size)
         return NGX_ERROR;
     }
 
-    frame = ngx_pcalloc(c->pool, sizeof(ngx_quic_frame_t));
+    frame = ngx_pcalloc(pc->pool, sizeof(ngx_quic_frame_t));
     if (frame == NULL) {
         return 0;
     }
 
-    p = ngx_pnalloc(c->pool, size);
+    p = ngx_pnalloc(pc->pool, size);
     if (p == NULL) {
         return 0;
     }