summaryrefslogtreecommitdiffstats
path: root/src/vcl/vcl_private.c
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2018-09-07 17:09:35 -0700
committerDamjan Marion <dmarion@me.com>2018-09-08 12:12:13 +0000
commit3348a4cf070b90a9c23bbc0b3752fa2801f832a9 (patch)
tree67e6a8b2db134daa8b62eb241e161137fdbc4f32 /src/vcl/vcl_private.c
parentde9f08b0302d5b4cdc8fbfeb9a9585f46e8314f2 (diff)
vcl: set worker pthread stop key
Otherwise the key destructor is not called on pthread_exit. Change-Id: I11e6b9683a926eecd3f40a44aab41924ff9c3101 Signed-off-by: Florin Coras <fcoras@cisco.com>
Diffstat (limited to 'src/vcl/vcl_private.c')
-rw-r--r--src/vcl/vcl_private.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/vcl/vcl_private.c b/src/vcl/vcl_private.c
index ae4498ef4b5..0b8c2da45db 100644
--- a/src/vcl/vcl_private.c
+++ b/src/vcl/vcl_private.c
@@ -15,7 +15,7 @@
#include <vcl/vcl_private.h>
-pthread_key_t vcl_worker_stop_key;
+static pthread_key_t vcl_worker_stop_key;
static const char *
vppcom_app_state_str (app_state_t state)
@@ -224,6 +224,7 @@ static void
vcl_worker_cleanup (void *arg)
{
vcl_worker_t *wrk = vcl_worker_get_current ();
+
VDBG (0, "cleaning up worker %u", wrk->wrk_index);
vcl_send_app_worker_add_del (0 /* is_add */ );
close (wrk->mqs_epfd);
@@ -290,6 +291,9 @@ vcl_worker_alloc_and_init ()
if (pthread_key_create (&vcl_worker_stop_key, vcl_worker_cleanup))
clib_warning ("failed to add pthread cleanup function");
+ if (pthread_setspecific (vcl_worker_stop_key, &wrk->thread_id))
+ clib_warning ("failed to setup key value");
+ wrk->thread_id = pthread_self ();
clib_spinlock_unlock (&vcm->workers_lock);