diff options
author | Dimitri Staessens <[email protected]> | 2023-10-07 14:26:23 +0200 |
---|---|---|
committer | Sander Vrijders <[email protected]> | 2023-10-25 09:53:27 +0200 |
commit | 5706bf3efa8d8262982bbed15fb041e536f56cf2 (patch) | |
tree | 3cd9db132bb5756bdaa64982b63ad9b9dbe4aaad /src/irmd/reg/proc.c | |
parent | 180e92c5f13b99ed171e8efe11058eb943bc6506 (diff) | |
download | ouroboros-5706bf3efa8d8262982bbed15fb041e536f56cf2.tar.gz ouroboros-5706bf3efa8d8262982bbed15fb041e536f56cf2.zip |
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 <[email protected]>
Signed-off-by: Sander Vrijders <[email protected]>
Diffstat (limited to 'src/irmd/reg/proc.c')
-rw-r--r-- | src/irmd/reg/proc.c | 6 |
1 files changed, 1 insertions, 5 deletions
diff --git a/src/irmd/reg/proc.c b/src/irmd/reg/proc.c index 1aae789d..8a016afe 100644 --- a/src/irmd/reg/proc.c +++ b/src/irmd/reg/proc.c @@ -211,11 +211,7 @@ int reg_proc_sleep(struct reg_proc * proc, pthread_cleanup_push(cancel_reg_proc, proc); while (proc->state == PROC_SLEEP && ret != -ETIMEDOUT) - if (dl != NULL) - ret = -pthread_cond_timedwait(&proc->cond, - &proc->lock, dl); - else - ret = -pthread_cond_wait(&proc->cond, &proc->lock); + ret = -__timedwait(&proc->cond, &proc->lock, dl); pthread_cleanup_pop(false); |