diff options
author | Sander Vrijders <sander.vrijders@ugent.be> | 2017-08-03 19:33:00 +0200 |
---|---|---|
committer | Sander Vrijders <sander.vrijders@ugent.be> | 2017-08-03 19:33:00 +0200 |
commit | e77db148ce7adbaefb2ec7fb66a1fe0a36cff72f (patch) | |
tree | 8f69e8ca7817cefcdece2f749a83de32fea9be18 /src/ipcpd/local/main.c | |
parent | 3b06d69d61cd677394fa7adf1ffcfa13ab8bac70 (diff) | |
parent | 9017e3006c1e1246de5291f13319a763fd440e2f (diff) | |
download | ouroboros-e77db148ce7adbaefb2ec7fb66a1fe0a36cff72f.tar.gz ouroboros-e77db148ce7adbaefb2ec7fb66a1fe0a36cff72f.zip |
Merge branch 'testing' into be
Diffstat (limited to 'src/ipcpd/local/main.c')
-rw-r--r-- | src/ipcpd/local/main.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/ipcpd/local/main.c b/src/ipcpd/local/main.c index ddb5e4ec..78224fbd 100644 --- a/src/ipcpd/local/main.c +++ b/src/ipcpd/local/main.c @@ -177,18 +177,23 @@ static int ipcp_local_flow_alloc(int fd, qoscube_t cube) { struct timespec ts = {0, EVENT_WAIT_TIMEOUT * 1000}; + struct timespec abstime; int out_fd = -1; log_dbg("Allocating flow to " HASH_FMT " on fd %d.", HASH_VAL(dst), fd); assert(dst); + clock_gettime(PTHREAD_COND_CLOCK, &abstime); + pthread_mutex_lock(&ipcpi.alloc_lock); - while (ipcpi.alloc_id != -1 && ipcp_get_state() == IPCP_OPERATIONAL) + while (ipcpi.alloc_id != -1 && ipcp_get_state() == IPCP_OPERATIONAL) { + ts_add(&abstime, &ts, &abstime); pthread_cond_timedwait(&ipcpi.alloc_cond, &ipcpi.alloc_lock, - &ts); + &abstime); + } if (ipcp_get_state() != IPCP_OPERATIONAL) { log_dbg("Won't allocate over non-operational IPCP."); @@ -228,15 +233,20 @@ static int ipcp_local_flow_alloc_resp(int fd, int response) { struct timespec ts = {0, EVENT_WAIT_TIMEOUT * 1000}; + struct timespec abstime; int out_fd = -1; int ret = -1; + clock_gettime(PTHREAD_COND_CLOCK, &abstime); + pthread_mutex_lock(&ipcpi.alloc_lock); - while (ipcpi.alloc_id != fd && ipcp_get_state() == IPCP_OPERATIONAL) + while (ipcpi.alloc_id != fd && ipcp_get_state() == IPCP_OPERATIONAL) { + ts_add(&abstime, &ts, &abstime); pthread_cond_timedwait(&ipcpi.alloc_cond, &ipcpi.alloc_lock, - &ts); + &abstime); + } if (ipcp_get_state() != IPCP_OPERATIONAL) { pthread_mutex_unlock(&ipcpi.alloc_lock); |