From 9c0c55198c2406fea6be189e1ec6b3ac3cc565fc Mon Sep 17 00:00:00 2001 From: dimitri staessens Date: Wed, 24 Aug 2016 17:52:48 +0200 Subject: ipcpd: Revised locking The state lock was reverted to an rwlock to avoid interference of management functions with the fast path. IPCPs now close without calling unsafe functions in the signal handler. --- src/ipcpd/normal/fmgr.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'src/ipcpd/normal/fmgr.c') diff --git a/src/ipcpd/normal/fmgr.c b/src/ipcpd/normal/fmgr.c index 70afff37..1c8330a8 100644 --- a/src/ipcpd/normal/fmgr.c +++ b/src/ipcpd/normal/fmgr.c @@ -81,17 +81,16 @@ static void * fmgr_listen(void * o) char * ae_name; while (true) { - pthread_mutex_lock(&_ipcp->state_lock); - while (!(_ipcp->state == IPCP_ENROLLED || - _ipcp->state == IPCP_SHUTDOWN)) - pthread_cond_wait(&_ipcp->state_cond, - &_ipcp->state_lock); - - if (_ipcp->state == IPCP_SHUTDOWN) { - pthread_mutex_unlock(&_ipcp->state_lock); + ipcp_wait_state(_ipcp, IPCP_ENROLLED, NULL); + + pthread_rwlock_rdlock(&_ipcp->state_lock); + + if (ipcp_get_state(_ipcp) == IPCP_SHUTDOWN) { + pthread_rwlock_unlock(&_ipcp->state_lock); return 0; } - pthread_mutex_unlock(&_ipcp->state_lock); + + pthread_rwlock_unlock(&_ipcp->state_lock); fd = flow_accept(&ae_name); if (fd < 0) { -- cgit v1.2.3