diff options
author | dimitri staessens <dimitri.staessens@intec.ugent.be> | 2016-12-27 19:18:06 +0100 |
---|---|---|
committer | dimitri staessens <dimitri.staessens@intec.ugent.be> | 2016-12-27 19:18:06 +0100 |
commit | 0324479318e76cecbe70b274cf2ab3479fe6f437 (patch) | |
tree | 708bea2e2d6b433fe806de3e8d0941b45ded3a84 /src | |
parent | 7a286471720aca037ea001f052630c16044198ee (diff) | |
download | ouroboros-0324479318e76cecbe70b274cf2ab3479fe6f437.tar.gz ouroboros-0324479318e76cecbe70b274cf2ab3479fe6f437.zip |
ipcpd: Simplify ipcp_wait_state implementation
Diffstat (limited to 'src')
-rw-r--r-- | src/ipcpd/ipcp.c | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/src/ipcpd/ipcp.c b/src/ipcpd/ipcp.c index 8bd2ba77..fdf3a340 100644 --- a/src/ipcpd/ipcp.c +++ b/src/ipcpd/ipcp.c @@ -143,6 +143,7 @@ int ipcp_wait_state(enum ipcp_state state, const struct timespec * timeout) { struct timespec abstime; + int ret = 0; clock_gettime(PTHREAD_COND_CLOCK, &abstime); ts_add(&abstime, timeout, &abstime); @@ -150,23 +151,18 @@ int ipcp_wait_state(enum ipcp_state state, pthread_mutex_lock(&ipcpi.state_mtx); while (ipcpi.state != state && ipcpi.state != IPCP_SHUTDOWN) { - int ret; if (timeout == NULL) - ret = pthread_cond_wait(&ipcpi.state_cond, - &ipcpi.state_mtx); + ret = -pthread_cond_wait(&ipcpi.state_cond, + &ipcpi.state_mtx); else - ret = pthread_cond_timedwait(&ipcpi.state_cond, - &ipcpi.state_mtx, - &abstime); - if (ret) { - pthread_mutex_unlock(&ipcpi.state_mtx); - return -ret; - } + ret = -pthread_cond_timedwait(&ipcpi.state_cond, + &ipcpi.state_mtx, + &abstime); } pthread_mutex_unlock(&ipcpi.state_mtx); - return 0; + return ret; } int ipcp_parse_arg(int argc, char * argv[]) |