From 631f505f8281bc95c31361c01aee207866e569dc Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Thu, 7 Jul 2022 14:43:27 -0400 Subject: [PATCH] freebsd_network: Fix callout_active checking in callout_stop. We have to perform the "due" check after checking callout_active, because due is set to -1 while the callout is actually active. --- src/libs/compat/freebsd_network/callout.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libs/compat/freebsd_network/callout.cpp b/src/libs/compat/freebsd_network/callout.cpp index e91416c846..8ecd727a42 100644 --- a/src/libs/compat/freebsd_network/callout.cpp +++ b/src/libs/compat/freebsd_network/callout.cpp @@ -219,9 +219,6 @@ _callout_stop_safe(struct callout *c, int safe) MutexLocker locker(sLock); - if (c->due <= 0) - return -1; - if (callout_active(c)) { if (safe) { locker.Unlock(); @@ -231,6 +228,9 @@ _callout_stop_safe(struct callout *c, int safe) return 0; } + if (c->due <= 0) + return -1; + // this timer is scheduled, cancel it list_remove_item(&sTimers, c); c->due = 0;