http: handle accept errors 28/43928/3
authorFlorin Coras <[email protected]>
Thu, 23 Oct 2025 07:31:18 +0000 (03:31 -0400)
committerDave Barach <[email protected]>
Thu, 23 Oct 2025 15:27:04 +0000 (15:27 +0000)
Type: fix

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

index af9eec4..3e2ba9a 100644 (file)
@@ -1980,7 +1980,11 @@ http1_transport_rx_callback (http_conn_t *hc)
       ASSERT (hc->flags & HTTP_CONN_F_IS_SERVER);
       /* first request - create request ctx and notify app about new conn */
       req = http1_conn_alloc_req (hc);
-      http_conn_accept_request (hc, req);
+      if (http_conn_accept_request (hc, req))
+       {
+         http_disconnect_transport (hc);
+         return;
+       }
       http_stats_connections_accepted_inc (hc->c_thread_index);
       http_req_state_change (req, HTTP_REQ_STATE_WAIT_TRANSPORT_METHOD);
       hc->flags &= ~HTTP_CONN_F_NO_APP_SESSION;
@@ -2058,7 +2062,9 @@ http1_conn_cleanup_callback (http_conn_t *hc)
     return;
 
   req = http1_conn_get_req (hc);
-  session_transport_delete_notify (&req->connection);
+  /* do not notify if accept or connect failed */
+  if (req->c_s_index != SESSION_INVALID_INDEX)
+    session_transport_delete_notify (&req->connection);
   http1_conn_free_req (hc);
 }
 
index ed65ca1..6ff90a2 100644 (file)
@@ -2066,7 +2066,11 @@ http2_handle_headers_frame (http_conn_t *hc, http2_frame_header_t *fh)
       req = http2_conn_alloc_req (hc, 0);
       http2_req_set_stream_id (req, h2c, fh->stream_id, 0);
       req->dispatch_headers_cb = http2_sched_dispatch_resp_headers;
-      http_conn_accept_request (hc, &req->base);
+      if (http_conn_accept_request (hc, &req->base))
+       {
+         http2_conn_free_req (h2c, req, hc->c_thread_index);
+         return HTTP2_ERROR_INTERNAL_ERROR;
+       }
       http_req_state_change (&req->base, HTTP_REQ_STATE_WAIT_TRANSPORT_METHOD);
       req->stream_state = HTTP2_STREAM_STATE_OPEN;
       hc->flags &= ~HTTP_CONN_F_NO_APP_SESSION;
index 7a823d2..cb232e9 100644 (file)
@@ -869,7 +869,6 @@ http_conn_accept_request (http_conn_t *hc, http_req_t *req)
       HTTP_DBG (1, "failed to allocate fifos");
       req->c_s_index = SESSION_INVALID_INDEX;
       session_free (as);
-      hc->flags |= HTTP_CONN_F_NO_APP_SESSION;
       return rv;
     }
 
@@ -882,7 +881,6 @@ http_conn_accept_request (http_conn_t *hc, http_req_t *req)
       HTTP_DBG (1, "app accept returned");
       req->c_s_index = SESSION_INVALID_INDEX;
       session_free (as);
-      hc->flags |= HTTP_CONN_F_NO_APP_SESSION;
       return rv;
     }