From 5706bf3efa8d8262982bbed15fb041e536f56cf2 Mon Sep 17 00:00:00 2001 From: Dimitri Staessens Date: Sat, 7 Oct 2023 14:26:23 +0200 Subject: lib: Wrap pthread_cond_timedwait for NULL abstime We often have the pattern where we NULL-check abstime for pthread_cond_timedwait to call pthread_cond_wait if it is. Added a __timedwait function to wrap this. Signed-off-by: Dimitri Staessens Signed-off-by: Sander Vrijders --- src/irmd/reg/flow.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'src/irmd/reg/flow.c') diff --git a/src/irmd/reg/flow.c b/src/irmd/reg/flow.c index 30b9c504..898f2604 100644 --- a/src/irmd/reg/flow.c +++ b/src/irmd/reg/flow.c @@ -197,15 +197,8 @@ int reg_flow_wait_state(struct reg_flow * f, while (!(f->state == state || f->state == FLOW_DESTROY || f->state == FLOW_DEALLOC_PENDING) && - ret != -ETIMEDOUT) { - if (dl != NULL) - ret = -pthread_cond_timedwait(&f->cond, - &f->mtx, - dl); - else - ret = -pthread_cond_wait(&f->cond, - &f->mtx); - } + ret != -ETIMEDOUT) + ret = -__timedwait(&f->cond, &f->mtx, dl); if (f->state == FLOW_DESTROY || f->state == FLOW_DEALLOC_PENDING || -- cgit v1.2.3