The spinlock should unlock when clock_gettime() failed. This patch fixes it by invoking clock_gettime() before lock.
Fixes: 26021a715067 ("eal/bsd: support alarm API") Cc: sta...@dpdk.org Signed-off-by: Chengwen Feng <fengcheng...@huawei.com> --- lib/eal/freebsd/eal_alarm.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/eal/freebsd/eal_alarm.c b/lib/eal/freebsd/eal_alarm.c index 1023c32937..1a3e6c0aad 100644 --- a/lib/eal/freebsd/eal_alarm.c +++ b/lib/eal/freebsd/eal_alarm.c @@ -171,12 +171,12 @@ eal_alarm_callback(void *arg __rte_unused) struct timespec now; struct alarm_entry *ap; - rte_spinlock_lock(&alarm_list_lk); - ap = LIST_FIRST(&alarm_list); - if (clock_gettime(CLOCK_TYPE_ID, &now) < 0) return; + rte_spinlock_lock(&alarm_list_lk); + ap = LIST_FIRST(&alarm_list); + while (ap != NULL && timespec_cmp(&now, &ap->time) >= 0) { ap->executing = 1; ap->executing_id = pthread_self(); -- 2.17.1