vcl: fix detach of sessions without fifos 71/42971/3
authorFlorin Coras <[email protected]>
Fri, 16 May 2025 04:08:42 +0000 (00:08 -0400)
committerDave Barach <[email protected]>
Fri, 16 May 2025 18:46:43 +0000 (18:46 +0000)
Make sure we only try to cleanup segments for sessions that have not yet
been disconnected.

Type: fix

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

index 80fbd8b..33ce7eb 100644 (file)
@@ -253,18 +253,28 @@ vcl_worker_detach_sessions (vcl_worker_t *wrk)
          s->flags |= VCL_SESSION_F_LISTEN_NO_MQ;
          continue;
        }
-      if ((s->flags & VCL_SESSION_F_IS_VEP) ||
-         s->session_state == VCL_STATE_CLOSED)
+      if ((s->flags & VCL_SESSION_F_IS_VEP))
        continue;
 
-      hash_set (seg_indices_map, s->tx_fifo->segment_index, 1);
+      /* App closed, vpp detached, free session */
+      if (s->session_state == VCL_STATE_CLOSED)
+       {
+         vcl_session_free (wrk, s);
+         continue;
+       }
+
+      /* In other states expect close from app */
+      if (s->session_state == VCL_STATE_READY)
+       {
+         hash_set (seg_indices_map, s->tx_fifo->segment_index, 1);
+         vec_add2 (wrk->unhandled_evts_vector, e, 1);
+         e->event_type = SESSION_CTRL_EVT_DISCONNECTED;
+         e->session_index = s->session_index;
+         e->postponed = 1;
+       }
 
       s->session_state = VCL_STATE_DETACHED;
       s->flags |= VCL_SESSION_F_APP_CLOSING;
-      vec_add2 (wrk->unhandled_evts_vector, e, 1);
-      e->event_type = SESSION_CTRL_EVT_DISCONNECTED;
-      e->session_index = s->session_index;
-      e->postponed = 1;
     }
 
   hash_foreach (seg_index, val, seg_indices_map,