summaryrefslogtreecommitdiff
path: root/src/irmd/irm_flow.c
diff options
context:
space:
mode:
authorDimitri Staessens <dimitri@ouroboros.rocks>2023-03-14 12:50:26 +0100
committerSander Vrijders <sander@ouroboros.rocks>2023-03-18 17:12:27 +0100
commit3b2f38aeafa1d6d2976dd5581ef46a5d3b463825 (patch)
treeb6672c1baaa813fb5f8865675a322efa280ab532 /src/irmd/irm_flow.c
parented90f46a8207cb1289704ea64bc490d5835f3010 (diff)
downloadouroboros-3b2f38aeafa1d6d2976dd5581ef46a5d3b463825.tar.gz
ouroboros-3b2f38aeafa1d6d2976dd5581ef46a5d3b463825.zip
irmd: Use deadline instead of timeout in mainloop
Reduces the places where we need to do this conversion for pthread_cond_timedwait. Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
Diffstat (limited to 'src/irmd/irm_flow.c')
-rw-r--r--src/irmd/irm_flow.c19
1 files changed, 6 insertions, 13 deletions
diff --git a/src/irmd/irm_flow.c b/src/irmd/irm_flow.c
index 8bdda86b..44d3fb7e 100644
--- a/src/irmd/irm_flow.c
+++ b/src/irmd/irm_flow.c
@@ -176,23 +176,16 @@ void irm_flow_set_state(struct irm_flow * f,
int irm_flow_wait_state(struct irm_flow * f,
enum flow_state state,
- struct timespec * timeo)
+ struct timespec * dl)
{
int ret = 0;
int s;
- struct timespec dl;
-
assert(f);
assert(state != FLOW_NULL);
assert(state != FLOW_DESTROY);
assert(state != FLOW_DEALLOC_PENDING);
- if (timeo != NULL) {
- clock_gettime(PTHREAD_COND_CLOCK, &dl);
- ts_add(&dl, timeo, &dl);
- }
-
pthread_mutex_lock(&f->state_lock);
assert(f->state != FLOW_NULL);
@@ -203,13 +196,13 @@ int irm_flow_wait_state(struct irm_flow * f,
f->state == FLOW_DESTROY ||
f->state == FLOW_DEALLOC_PENDING) &&
ret != -ETIMEDOUT) {
- if (timeo == NULL)
- ret = -pthread_cond_wait(&f->state_cond,
- &f->state_lock);
- else
+ if (dl != NULL)
ret = -pthread_cond_timedwait(&f->state_cond,
&f->state_lock,
- &dl);
+ dl);
+ else
+ ret = -pthread_cond_wait(&f->state_cond,
+ &f->state_lock);
}
if (f->state == FLOW_DESTROY ||