]> git.kaiwu.me - nginx.git/commitdiff
QUIC: revised ngx_quic_handle_datagram() error codes.
authorVladimir Homutov <vl@nginx.com>
Tue, 1 Feb 2022 11:35:31 +0000 (14:35 +0300)
committerVladimir Homutov <vl@nginx.com>
Tue, 1 Feb 2022 11:35:31 +0000 (14:35 +0300)
The NGX_DECLINED is replaced with NGX_DONE to match closer to return code
of ngx_quic_handle_packet() and ngx_quic_close_connection() rc argument.

The ngx_quic_close_connection() rc code is used only when quic connection
exists, thus anything goes if qc == NULL.

The ngx_quic_handle_datagram() does not return NG_OK in cases when quic
connection is not yet created.

src/event/quic/ngx_event_quic.c
src/event/quic/ngx_event_quic_output.c

index 9309faa6c7ffe1b7ad86deb31157086f72f17030..ed970bc4c882d3190396868cbe479f611fd33404 100644 (file)
@@ -210,17 +210,13 @@ ngx_quic_run(ngx_connection_t *c, ngx_quic_conf_t *conf)
 
     rc = ngx_quic_handle_datagram(c, c->buffer, conf);
     if (rc != NGX_OK) {
-        ngx_quic_close_connection(c, rc == NGX_DECLINED ? NGX_DONE : NGX_ERROR);
+        ngx_quic_close_connection(c, rc);
         return;
     }
 
+    /* quic connection is now created */
     qc = ngx_quic_get_connection(c);
 
-    if (qc == NULL) {
-        ngx_quic_close_connection(c, NGX_DONE);
-        return;
-    }
-
     ngx_add_timer(c->read, qc->tp.max_idle_timeout);
     ngx_quic_connstate_dbg(c);
 
@@ -443,7 +439,7 @@ ngx_quic_input_handler(ngx_event_t *rev)
         return;
     }
 
-    if (rc == NGX_DECLINED) {
+    if (rc == NGX_DONE) {
         return;
     }
 
@@ -709,13 +705,8 @@ ngx_quic_handle_datagram(ngx_connection_t *c, ngx_buf_t *b,
         }
 #endif
 
-        if (rc == NGX_ERROR) {
-            return NGX_ERROR;
-        }
-
-        if (rc == NGX_DONE) {
-            /* stop further processing */
-            return NGX_DECLINED;
+        if (rc == NGX_ERROR || rc == NGX_DONE) {
+            return rc;
         }
 
         if (rc == NGX_OK) {
@@ -750,7 +741,7 @@ ngx_quic_handle_datagram(ngx_connection_t *c, ngx_buf_t *b,
     }
 
     if (!good) {
-        return NGX_DECLINED;
+        return NGX_DONE;
     }
 
     qc = ngx_quic_get_connection(c);
index 67e527462cc4c1affa6511b4a3b497078f7bab93..b34ca7855480afabb03e10c8bc926efc2422a283 100644 (file)
@@ -979,7 +979,7 @@ ngx_quic_send_early_cc(ngx_connection_t *c, ngx_quic_header_t *inpkt,
         return NGX_ERROR;
     }
 
-    return NGX_OK;
+    return NGX_DONE;
 }