freebsd_network: Properly implement callout_drain().

Also cleanup code a bit.

May help with #17634.
This commit is contained in:
Augustin Cavalier 2022-03-09 17:10:35 -05:00
parent 49fd143d15
commit 385fce1cde

View File

@ -212,17 +212,24 @@ callout_schedule(struct callout *callout, int _ticks)
int
_callout_stop_safe(struct callout *c, int safe)
{
MutexLocker locker(sLock);
if (c == NULL) {
printf("_callout_stop_safe called with NULL callout\n");
return 0;
}
if (c == NULL)
return -1;
TRACE("_callout_stop_safe %p, func %p, arg %p\n", c, c->c_func, c->c_arg);
MutexLocker locker(sLock);
if (c->due <= 0)
return -1;
if (callout_active(c)) {
if (safe) {
locker.Unlock();
while (callout_active(c))
snooze(100);
}
return 0;
}
// this timer is scheduled, cancel it
list_remove_item(&sTimers, c);