summaryrefslogtreecommitdiff
path: root/src/ipcpd/normal
diff options
context:
space:
mode:
authordimitri staessens <[email protected]>2017-08-03 18:45:28 +0200
committerdimitri staessens <[email protected]>2017-08-03 18:45:28 +0200
commite3d19da0501bbb80ba1caf562ba61a99c63b10b7 (patch)
tree6299c95a879c17ce4609028782acc99b50e6cbf4 /src/ipcpd/normal
parent0dacddfff0a705591e6665a00c367c367c23c1f0 (diff)
downloadouroboros-e3d19da0501bbb80ba1caf562ba61a99c63b10b7.tar.gz
ouroboros-e3d19da0501bbb80ba1caf562ba61a99c63b10b7.zip
ipcpd: Fix pthread_cond_timedwait deadlines
This fixes pthread_condtimedwaits in the flow allocator of all IPCPs that had bad deadlines set (the interval instead of the actual absolute time).
Diffstat (limited to 'src/ipcpd/normal')
-rw-r--r--src/ipcpd/normal/fa.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/ipcpd/normal/fa.c b/src/ipcpd/normal/fa.c
index 26ee9037..40a680c3 100644
--- a/src/ipcpd/normal/fa.c
+++ b/src/ipcpd/normal/fa.c
@@ -83,6 +83,7 @@ static int 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;
@@ -104,6 +105,8 @@ static int 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) {
@@ -114,10 +117,12 @@ static int 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.");
@@ -311,16 +316,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);