diff src/http/ngx_http_request.c @ 8460:72f9ff4e0a88 quic

HTTP/3: close QUIC connection with HTTP/QPACK errors when needed. Previously errors led only to closing streams. To simplify closing QUIC connection from a QUIC stream context, new macro ngx_http_v3_finalize_connection() is introduced. It calls ngx_quic_finalize_connection() for the parent connection.
author Roman Arutyunyan <arut@nginx.com>
date Thu, 02 Jul 2020 16:47:51 +0300
parents c9538aef3211
children b3c07aa021f6
line wrap: on
line diff
--- a/src/http/ngx_http_request.c
+++ b/src/http/ngx_http_request.c
@@ -416,19 +416,21 @@ static void
 ngx_http_quic_stream_handler(ngx_connection_t *c)
 {
     ngx_event_t               *rev;
-    ngx_connection_t          *pc;
     ngx_http_log_ctx_t        *ctx;
     ngx_http_connection_t     *hc;
     ngx_http_v3_connection_t  *h3c;
 
-    pc = c->qs->parent;
-    h3c = pc->data;
+    h3c = c->qs->parent->data;
 
     if (!h3c->settings_sent) {
         h3c->settings_sent = 1;
 
-        /* TODO close QUIC connection on error */
-        (void) ngx_http_v3_send_settings(c);
+        if (ngx_http_v3_send_settings(c) != NGX_OK) {
+            ngx_http_v3_finalize_connection(c, NGX_HTTP_V3_ERR_INTERNAL_ERROR,
+                                            "could not send settings");
+            ngx_http_close_connection(c);
+            return;
+        }
     }
 
     if (c->qs->id & NGX_QUIC_STREAM_UNIDIRECTIONAL) {