vcl: fix read on closed sessions with mt apps 37/43137/2
authorFlorin Coras <[email protected]>
Tue, 10 Jun 2025 08:48:06 +0000 (04:48 -0400)
committerDave Barach <[email protected]>
Tue, 10 Jun 2025 20:23:02 +0000 (20:23 +0000)
Apps like iperf can have a thread close a session that another thread
selects/epolls. Make sure to return error when that happens.

Type: fix

Change-Id: I586f8077431a28e7d8d3e4f21e45efcc035698ba
Signed-off-by: Florin Coras <[email protected]>
src/vcl/ldp.c
src/vcl/vppcom.c

index b4978bf..7e4cddb 100644 (file)
@@ -661,7 +661,9 @@ ldp_select_init_maps (fd_set * __restrict original,
       {
          vlsh_to_session_and_worker_index (vlsh, &session_index, &wrk_index);
          if (wrk_index != vppcom_worker_index ())
-           clib_warning ("migration currently not supported");
+           clib_warning (
+             "migration for %d vlsh %d from %d to %d not supported", fd, vlsh,
+             wrk_index, vppcom_worker_index ());
          else
            *vclb = clib_bitmap_set (*vclb, session_index, 1);
       }
index 0e52a26..9aff1e6 100644 (file)
@@ -617,6 +617,7 @@ vcl_session_unlisten_reply_handler (vcl_worker_t * wrk, void *data)
   if (mp->context != wrk->wrk_index)
     VDBG (0, "wrong context");
 
+  VDBG (0, "unlisten reply freeing %d[0x%llx]", s->session_index, mp->handle);
   vcl_session_table_del_vpp_handle (wrk, mp->handle);
   vcl_session_free (wrk, s);
 }
@@ -2123,7 +2124,9 @@ vppcom_session_read_internal (uint32_t session_handle, void *buf, int n,
            s->session_index, s->vpp_handle, s->session_state,
            vcl_session_state_str (s->session_state));
       rx_fifo = vcl_session_is_ct (s) ? s->ct_rx_fifo : s->rx_fifo;
-      if (svm_fifo_is_empty_cons (rx_fifo))
+      /* If application closed, e.g., mt app, or no data return error */
+      if (s->session_state == VCL_STATE_CLOSED ||
+         svm_fifo_is_empty_cons (rx_fifo))
        return vcl_session_closed_error (s);
     }