hsa: improve handling of SESSION_E_REFUSED in http client 54/43154/2
authorSemir Sionek <[email protected]>
Fri, 13 Jun 2025 13:16:47 +0000 (13:16 +0000)
committerFlorin Coras <[email protected]>
Fri, 13 Jun 2025 19:37:28 +0000 (19:37 +0000)
In that case (e.g trying to connect on a closed port), a connection
is refused and no session is allocated. As such, we cannot use the
struct to obtain the worker or vlib_main_t.

Type: fix
Change-Id: I9b44ccb42ba56a75b8ecc39501a7386ba2e84981
Signed-off-by: Semir Sionek <[email protected]>
src/plugins/hs_apps/http_client.c

index 5787b45..a284da8 100644 (file)
@@ -225,17 +225,17 @@ hc_session_connected_callback (u32 app_index, u32 hc_session_index,
   hc_session_t *hc_session;
   hc_http_header_t *header;
 
-  wrk = hc_worker_get (s->thread_index);
-
   if (err)
     {
       clib_warning ("hc_session_index[%d] connected error: %U",
                    hc_session_index, format_session_error, err);
-      vlib_process_signal_event_mt (wrk->vlib_main, hcm->cli_node_index,
+      vlib_process_signal_event_mt (vlib_get_main (), hcm->cli_node_index,
                                    HC_CONNECT_FAILED, 0);
       return -1;
     }
 
+  wrk = hc_worker_get (s->thread_index);
+
   hc_session = hc_session_alloc (wrk);
   clib_spinlock_lock_if_init (&hcm->lock);
   hcm->connected_counter++;