From 3b2f38aeafa1d6d2976dd5581ef46a5d3b463825 Mon Sep 17 00:00:00 2001 From: Dimitri Staessens Date: Tue, 14 Mar 2023 12:50:26 +0100 Subject: 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 Signed-off-by: Sander Vrijders --- src/irmd/proc_table.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'src/irmd/proc_table.c') diff --git a/src/irmd/proc_table.c b/src/irmd/proc_table.c index 8a25831a..ee87813d 100644 --- a/src/irmd/proc_table.c +++ b/src/irmd/proc_table.c @@ -184,19 +184,13 @@ void proc_entry_del_name(struct proc_entry * e, } int proc_entry_sleep(struct proc_entry * e, - struct timespec * timeo) + struct timespec * dl) { - struct timespec dl; int ret = 0; assert(e); - if (timeo != NULL) { - clock_gettime(PTHREAD_COND_CLOCK, &dl); - ts_add(&dl, timeo, &dl); - } - pthread_mutex_lock(&e->lock); if (e->state != PROC_WAKE && e->state != PROC_DESTROY) @@ -205,8 +199,8 @@ int proc_entry_sleep(struct proc_entry * e, pthread_cleanup_push(cancel_proc_entry, e); while (e->state == PROC_SLEEP && ret != -ETIMEDOUT) - if (timeo) - ret = -pthread_cond_timedwait(&e->cond, &e->lock, &dl); + if (dl != NULL) + ret = -pthread_cond_timedwait(&e->cond, &e->lock, dl); else ret = -pthread_cond_wait(&e->cond, &e->lock); -- cgit v1.2.3