diff options
author | dimitri staessens <[email protected]> | 2017-08-16 12:11:21 +0200 |
---|---|---|
committer | dimitri staessens <[email protected]> | 2017-08-16 12:11:21 +0200 |
commit | 6b33850f488ddd23fa29952a8c5d2a7c544617d3 (patch) | |
tree | 0ac36f828e5bafc09f2b2d72dbadd3608e7d239e /src/ipcpd/ipcp.c | |
parent | c8283ea410e7d640537303c6b644bbc3afb35cd5 (diff) | |
download | ouroboros-6b33850f488ddd23fa29952a8c5d2a7c544617d3.tar.gz ouroboros-6b33850f488ddd23fa29952a8c5d2a7c544617d3.zip |
irmd, ipcpd: Signal acceptor only
This adds an extra condvar so the mainloops can signal the acceptor
thread without waking up all mainloops.
Diffstat (limited to 'src/ipcpd/ipcp.c')
-rw-r--r-- | src/ipcpd/ipcp.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/ipcpd/ipcp.c b/src/ipcpd/ipcp.c index c5769f9e..7066fb04 100644 --- a/src/ipcpd/ipcp.c +++ b/src/ipcpd/ipcp.c @@ -138,7 +138,7 @@ static void * acceptloop(void * o) pthread_cond_signal(&ipcpi.cmd_cond); while (ipcpi.csockfd != -1) - pthread_cond_wait(&ipcpi.cmd_cond, &ipcpi.cmd_lock); + pthread_cond_wait(&ipcpi.acc_cond, &ipcpi.cmd_lock); pthread_mutex_unlock(&ipcpi.cmd_lock); } @@ -189,7 +189,7 @@ static void * mainloop(void * o) continue; } - pthread_cond_broadcast(&ipcpi.cmd_cond); + pthread_cond_signal(&ipcpi.acc_cond); msg = ipcp_msg__unpack(NULL, ipcpi.cmd_len, ipcpi.cbuf); if (msg == NULL) { @@ -591,6 +591,11 @@ int ipcp_init(int argc, goto fail_cmd_cond; } + if (pthread_cond_init(&ipcpi.acc_cond, &cattr)) { + log_err("Failed to init convar."); + goto fail_acc_cond; + } + ipcpi.alloc_id = -1; ipcpi.csockfd = -1; @@ -607,6 +612,8 @@ int ipcp_init(int argc, return 0; fail_shim_data: + pthread_cond_destroy(&ipcpi.acc_cond); + fail_acc_cond: pthread_cond_destroy(&ipcpi.cmd_cond); fail_cmd_cond: pthread_mutex_destroy(&ipcpi.cmd_lock); @@ -702,6 +709,7 @@ void ipcp_fini() pthread_mutex_destroy(&ipcpi.state_mtx); pthread_cond_destroy(&ipcpi.alloc_cond); pthread_mutex_destroy(&ipcpi.alloc_lock); + pthread_cond_destroy(&ipcpi.acc_cond); pthread_cond_destroy(&ipcpi.cmd_cond); pthread_mutex_destroy(&ipcpi.cmd_lock); |