From 1d65279ffecd0f540288187b94cb1a6b84a7a0c6 Mon Sep 17 00:00:00 2001 From: Neale Ranns Date: Thu, 26 Jul 2018 08:05:53 -0700 Subject: VPP-API client: timeout thread loop variable calling thread cancel on the timeout thread whilst it was sleep on condwait and then send the cond signal did not reliably wake up the thread. instead don;t cancel the thread, use a loop variable to terminate it. Change-Id: Ibc8ab6f21db7e4a98266bdf88b8b208b887820dd Signed-off-by: Neale Ranns --- src/vpp-api/client/client.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/vpp-api/client/client.c b/src/vpp-api/client/client.c index f1488e2e513..16c980e5f87 100644 --- a/src/vpp-api/client/client.c +++ b/src/vpp-api/client/client.c @@ -62,6 +62,7 @@ typedef struct { pthread_cond_t suspend_cv; pthread_cond_t resume_cv; pthread_mutex_t timeout_lock; + u8 timeout_loop; pthread_cond_t timeout_cv; pthread_cond_t timeout_cancel_cv; pthread_cond_t terminate_cv; @@ -115,6 +116,7 @@ init (void) pthread_cond_init(&pm->suspend_cv, NULL); pthread_cond_init(&pm->resume_cv, NULL); pthread_mutex_init(&pm->timeout_lock, NULL); + pm->timeout_loop = 1; pthread_cond_init(&pm->timeout_cv, NULL); pthread_cond_init(&pm->timeout_cancel_cv, NULL); pthread_cond_init(&pm->terminate_cv, NULL); @@ -234,7 +236,7 @@ vac_timeout_thread_fn (void *arg) u16 timeout; int rv; - while (1) + while (pm->timeout_loop) { /* Wait for poke */ pthread_mutex_lock(&pm->timeout_lock); @@ -402,7 +404,8 @@ vac_disconnect (void) } if (pm->timeout_thread_handle) { /* cancel, wake then join the timeout thread */ - pthread_cancel(pm->timeout_thread_handle); + clib_warning("vac_disconnect cnacel"); + pm->timeout_loop = 0; set_timeout(0); pthread_join(pm->timeout_thread_handle, (void **) &junk); } -- cgit 1.2.3-korg