diff options
author | Neale Ranns <neale.ranns@cisco.com> | 2018-07-26 08:05:53 -0700 |
---|---|---|
committer | Neale Ranns <neale.ranns@cisco.com> | 2018-07-26 08:05:57 -0700 |
commit | 1d65279ffecd0f540288187b94cb1a6b84a7a0c6 (patch) | |
tree | fb12e579bc76839692df58a67b2b0a2178db8212 /src/vpp-api/client | |
parent | b842ae117864a410af675bcc4964a4860dfca98a (diff) |
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>
Diffstat (limited to 'src/vpp-api/client')
-rw-r--r-- | src/vpp-api/client/client.c | 7 |
1 files changed, 5 insertions, 2 deletions
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); } |