aboutsummaryrefslogtreecommitdiffstats
path: root/src/vcl/vcl_private.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/vcl/vcl_private.c')
-rw-r--r--src/vcl/vcl_private.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/vcl/vcl_private.c b/src/vcl/vcl_private.c
index b1f159f2245..6892688da5a 100644
--- a/src/vcl/vcl_private.c
+++ b/src/vcl/vcl_private.c
@@ -211,6 +211,7 @@ vcl_worker_detach_sessions (vcl_worker_t *wrk)
hash_set (seg_indices_map, s->tx_fifo->segment_index, 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;
@@ -220,11 +221,22 @@ vcl_worker_detach_sessions (vcl_worker_t *wrk)
hash_foreach (seg_index, val, seg_indices_map,
({ vec_add1 (seg_indices, seg_index); }));
+ /* If multi-threaded apps, wait for all threads to hopefully finish
+ * their blocking operations */
+ if (wrk->pre_wait_fn)
+ wrk->pre_wait_fn (VCL_INVALID_SESSION_INDEX);
+ sleep (1);
+ if (wrk->post_wait_fn)
+ wrk->post_wait_fn (VCL_INVALID_SESSION_INDEX);
+
vcl_segment_detach_segments (seg_indices);
/* Detach worker's mqs segment */
vcl_segment_detach (vcl_vpp_worker_segment_handle (wrk->wrk_index));
+ wrk->app_event_queue = 0;
+ wrk->ctrl_mq = 0;
+
vec_free (seg_indices);
hash_free (seg_indices_map);
}
@@ -363,8 +375,8 @@ vcl_session_read_ready (vcl_session_t * s)
}
else
{
- return (s->session_state == VCL_STATE_DISCONNECT) ?
- VPPCOM_ECONNRESET : VPPCOM_ENOTCONN;
+ return (s->session_state == VCL_STATE_DISCONNECT) ? VPPCOM_ECONNRESET :
+ VPPCOM_ENOTCONN;
}
}