http: handle ts closed notifications 81/42681/2
authorFlorin Coras <[email protected]>
Sat, 5 Apr 2025 19:41:05 +0000 (15:41 -0400)
committerFlorin Coras <[email protected]>
Sat, 5 Apr 2025 19:57:45 +0000 (19:57 +0000)
Handle transport closed notifications and update connection state.
Also, handle closed state in app close notifications and force http
connection cleanup if transport is already closed to avoid waiting for
timer based cleanups.

Type: improvement

Change-Id: I26ee6a15b0993810d5a75fa56bb24e3396962f7b
Signed-off-by: Florin Coras <[email protected]>
src/plugins/http/http.c
src/plugins/http/http1.c

index 43b0993..1099f9e 100644 (file)
@@ -595,6 +595,19 @@ http_ts_builtin_tx_callback (session_t *ts)
   return 0;
 }
 
+static void
+http_ts_closed_callback (session_t *ts)
+{
+  http_conn_handle_t hc_handle;
+  http_conn_t *hc;
+
+  hc_handle.as_u32 = ts->opaque;
+  hc = http_conn_get_w_thread (hc_handle.conn_index, ts->thread_index);
+
+  http_disconnect_transport (hc);
+  hc->state = HTTP_CONN_STATE_CLOSED;
+}
+
 static void
 http_ts_cleanup_callback (session_t *ts, session_cleanup_ntf_t ntf)
 {
@@ -648,6 +661,7 @@ static session_cb_vft_t http_app_cb_vft = {
   .session_disconnect_callback = http_ts_disconnect_callback,
   .session_connected_callback = http_ts_connected_callback,
   .session_reset_callback = http_ts_reset_callback,
+  .session_transport_closed_callback = http_ts_closed_callback,
   .session_cleanup_callback = http_ts_cleanup_callback,
   .half_open_cleanup_callback = http_ts_ho_cleanup_callback,
   .add_segment_callback = http_add_segment_callback,
index 265f6e7..09d69f5 100644 (file)
@@ -1807,7 +1807,7 @@ http1_app_close_callback (http_conn_t *hc, u32 req_index, u32 thread_index)
       return;
     }
   /* Nothing more to send, confirm close */
-  if (!http_io_as_max_read (req))
+  if (!http_io_as_max_read (req) || hc->state == HTTP_CONN_STATE_CLOSED)
     {
       HTTP_DBG (1, "nothing more to send, confirm close");
       session_transport_closed_notify (&req->connection);