http: h2 handle connect init errors 27/43927/5
authorFlorin Coras <[email protected]>
Thu, 23 Oct 2025 05:11:54 +0000 (01:11 -0400)
committerDave Barach <[email protected]>
Thu, 23 Oct 2025 15:27:04 +0000 (15:27 +0000)
Type: fix

Change-Id: Ia8a27b3066de9fc49bcb5c0ae6c18845ce2eea70
Signed-off-by: Florin Coras <[email protected]>
Signed-off-by: Matus Fabian <[email protected]>
src/plugins/http/http2/http2.c
src/plugins/http/http_private.h

index 286c1fc..ed65ca1 100644 (file)
@@ -469,11 +469,16 @@ http2_connection_error (http_conn_t *hc, http2_error_t error,
            app_worker_connect_notify (app_wrk, 0, SESSION_E_UNKNOWN,
                                       hc->hc_pa_app_api_ctx);
        }
-      else
+      else if (!(hc->flags & HTTP_CONN_F_NO_APP_SESSION))
        {
          req = http2_req_get (h2c->parent_req_index, hc->c_thread_index);
          session_transport_reset_notify (&req->base.connection);
        }
+      else
+       {
+         http_disconnect_transport (hc);
+         return;
+       }
     }
   if (clib_llist_elt_is_linked (h2c, sched_list))
     clib_llist_remove (wrk->conn_pool, sched_list, h2c);
index 14b24b1..7a823d2 100644 (file)
@@ -903,6 +903,14 @@ http_conn_established (http_conn_t *hc, http_req_t *req,
   /* in chain with TLS there is race on half-open cleanup */
   __atomic_fetch_or (&ho_hc->flags, HTTP_CONN_F_HO_DONE, __ATOMIC_RELEASE);
 
+  app_wrk = app_worker_get_if_valid (hc->hc_pa_wrk_index);
+  if (!app_wrk)
+    {
+      HTTP_DBG (1, "no app worker");
+      req->c_s_index = SESSION_INVALID_INDEX;
+      return -1;
+    }
+
   /* allocate app session and initialize */
   as = session_alloc (hc->c_thread_index);
   HTTP_DBG (1, "allocated session 0x%lx", session_handle (as));
@@ -916,19 +924,11 @@ http_conn_established (http_conn_t *hc, http_req_t *req,
     TRANSPORT_PROTO_HTTP, session_type_is_ip4 (ts->session_type));
 
   /* init session fifos and notify app */
-  app_wrk = app_worker_get_if_valid (hc->hc_pa_wrk_index);
-  if (!app_wrk)
-    {
-      HTTP_DBG (1, "no app worker");
-      hc->flags |= HTTP_CONN_F_NO_APP_SESSION;
-      return -1;
-    }
-
   if ((rv = app_worker_init_connected (app_wrk, as)))
     {
       HTTP_DBG (1, "failed to allocate fifos");
       session_free (as);
-      hc->flags |= HTTP_CONN_F_NO_APP_SESSION;
+      req->c_s_index = SESSION_INVALID_INDEX;
       app_worker_connect_notify (app_wrk, 0, rv, parent_app_api_ctx);
       return rv;
     }
@@ -936,6 +936,7 @@ http_conn_established (http_conn_t *hc, http_req_t *req,
   app_worker_connect_notify (app_wrk, as, 0, parent_app_api_ctx);
 
   req->hr_pa_wrk_index = as->app_wrk_index;
+  hc->flags &= ~HTTP_CONN_F_NO_APP_SESSION;
 
   return 0;
 }