diff options
author | Dimitri Staessens <dimitri@ouroboros.rocks> | 2020-10-10 14:59:14 +0200 |
---|---|---|
committer | Sander Vrijders <sander@ouroboros.rocks> | 2020-10-11 14:09:44 +0200 |
commit | 31e2ab31a61029130fd8be4b2e8abe35bdc19659 (patch) | |
tree | e86f66e838071c837189c98c9b400f8b87258b45 /src/ipcpd | |
parent | 3aec660e814f470cc9453e69231cbe3102fd2a4c (diff) | |
download | ouroboros-31e2ab31a61029130fd8be4b2e8abe35bdc19659.tar.gz ouroboros-31e2ab31a61029130fd8be4b2e8abe35bdc19659.zip |
ipcpd: Fix condition variable in flow allocator
The condition variable was not initialized correctly and using the
wrong clock for pthread_cond_timedwait.
Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks>
Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
Diffstat (limited to 'src/ipcpd')
-rw-r--r-- | src/ipcpd/unicast/fa.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/ipcpd/unicast/fa.c b/src/ipcpd/unicast/fa.c index e0727e85..e154d785 100644 --- a/src/ipcpd/unicast/fa.c +++ b/src/ipcpd/unicast/fa.c @@ -274,7 +274,8 @@ static void * fa_handle_packet(void * o) int fa_init(void) { - int i; + pthread_condattr_t cattr; + int i; for (i = 0; i < PROG_MAX_FLOWS; ++i) destroy_conn(i); @@ -285,9 +286,17 @@ int fa_init(void) if (pthread_mutex_init(&fa.mtx, NULL)) goto fail_mtx; - if (pthread_cond_init(&fa.cond, NULL)) + if (pthread_condattr_init(&cattr)) + goto fail_cattr; + +#ifndef __APPLE__ + pthread_condattr_setclock(&cattr, PTHREAD_COND_CLOCK); +#endif + if (pthread_cond_init(&fa.cond, &cattr)) goto fail_cond; + pthread_condattr_destroy(&cattr); + list_head_init(&fa.cmds); fa.fd = dt_reg_comp(&fa, &fa_post_packet, FA); @@ -295,6 +304,8 @@ int fa_init(void) return 0; fail_cond: + pthread_condattr_destroy(&cattr); + fail_cattr: pthread_mutex_destroy(&fa.mtx); fail_mtx: pthread_rwlock_destroy(&fa.flows_lock); |