diff options
author | Dimitri Staessens <dimitri.staessens@ugent.be> | 2017-08-03 11:09:58 -0600 |
---|---|---|
committer | Dimitri Staessens <dimitri.staessens@ugent.be> | 2017-08-03 11:09:58 -0600 |
commit | 6eb3105f908158130bbc415e7376e3c2d7aafb5e (patch) | |
tree | c758cb4008d7d81173fca556ae8a2fd210b295ec /src/ipcpd/normal/fa.c | |
parent | b92eac2e9f6d686a9e2f748f8097aedbb373395c (diff) | |
parent | e3d19da0501bbb80ba1caf562ba61a99c63b10b7 (diff) | |
download | ouroboros-6eb3105f908158130bbc415e7376e3c2d7aafb5e.tar.gz ouroboros-6eb3105f908158130bbc415e7376e3c2d7aafb5e.zip |
Merge remote-tracking branch 'origin/testing-deadlines' into be
Diffstat (limited to 'src/ipcpd/normal/fa.c')
-rw-r--r-- | src/ipcpd/normal/fa.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/ipcpd/normal/fa.c b/src/ipcpd/normal/fa.c index d346f67c..704f4f16 100644 --- a/src/ipcpd/normal/fa.c +++ b/src/ipcpd/normal/fa.c @@ -84,6 +84,7 @@ static void fa_post_sdu(void * ae, struct shm_du_buff * sdb) { struct timespec ts = {0, TIMEOUT * 1000}; + struct timespec abstime; int fd; flow_alloc_msg_t * msg; @@ -108,6 +109,8 @@ static void fa_post_sdu(void * ae, switch (msg->code) { case FLOW_ALLOC_CODE__FLOW_REQ: + clock_gettime(PTHREAD_COND_CLOCK, &abstime); + pthread_mutex_lock(&ipcpi.alloc_lock); if (!msg->has_hash || !msg->has_s_fd || !msg->has_s_addr) { @@ -118,10 +121,12 @@ static void fa_post_sdu(void * ae, } while (ipcpi.alloc_id != -1 && - ipcp_get_state() == IPCP_OPERATIONAL) + 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."); @@ -275,16 +280,19 @@ int fa_alloc_resp(int fd, int response) { struct timespec ts = {0, TIMEOUT * 1000}; + struct timespec abstime; flow_alloc_msg_t msg = FLOW_ALLOC_MSG__INIT; struct shm_du_buff * sdb; qoscube_t qc; 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); |