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 <neale.ranns@cisco.com>
diff --git a/src/vpp-api/client/client.c b/src/vpp-api/client/client.c
index f1488e2..16c980e 100644
--- a/src/vpp-api/client/client.c
+++ b/src/vpp-api/client/client.c
@@ -62,6 +62,7 @@
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 @@
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 @@
u16 timeout;
int rv;
- while (1)
+ while (pm->timeout_loop)
{
/* Wait for poke */
pthread_mutex_lock(&pm->timeout_lock);
@@ -402,7 +404,8 @@
}
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);
}