freebsd_network: Properly implement callout_drain().
Also cleanup code a bit. May help with #17634.
This commit is contained in:
parent
49fd143d15
commit
385fce1cde
@ -212,17 +212,24 @@ callout_schedule(struct callout *callout, int _ticks)
|
|||||||
int
|
int
|
||||||
_callout_stop_safe(struct callout *c, int safe)
|
_callout_stop_safe(struct callout *c, int safe)
|
||||||
{
|
{
|
||||||
MutexLocker locker(sLock);
|
if (c == NULL)
|
||||||
|
return -1;
|
||||||
if (c == NULL) {
|
|
||||||
printf("_callout_stop_safe called with NULL callout\n");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
TRACE("_callout_stop_safe %p, func %p, arg %p\n", c, c->c_func, c->c_arg);
|
TRACE("_callout_stop_safe %p, func %p, arg %p\n", c, c->c_func, c->c_arg);
|
||||||
|
|
||||||
|
MutexLocker locker(sLock);
|
||||||
|
|
||||||
if (c->due <= 0)
|
if (c->due <= 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (callout_active(c)) {
|
||||||
|
if (safe) {
|
||||||
|
locker.Unlock();
|
||||||
|
while (callout_active(c))
|
||||||
|
snooze(100);
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
// this timer is scheduled, cancel it
|
// this timer is scheduled, cancel it
|
||||||
list_remove_item(&sTimers, c);
|
list_remove_item(&sTimers, c);
|
||||||
|
Loading…
Reference in New Issue
Block a user