freebsd_network: Rework callout_stop implementation.
From the FreeBSD manual pages: > If the callout is currently being serviced and cannot be stopped, > and at the same time a next invocation of the same callout is also > scheduled, then callout_stop() unschedules the next run and returns > zero. Previously we would return zero but not unschedule the next run. This may fix #18315.
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010, Axel Dörfler, [email protected].
|
* Copyright 2010, Axel Dörfler, [email protected].
|
||||||
* Copyright 2018, Haiku, Inc. All rights reserved.
|
* Copyright 2018-2023, Haiku, Inc. All rights reserved.
|
||||||
* Distributed under the terms of the MIT license.
|
* Distributed under the terms of the MIT license.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -218,22 +218,24 @@ _callout_stop_safe(struct callout *c, int safe)
|
|||||||
|
|
||||||
MutexLocker locker(sLock);
|
MutexLocker locker(sLock);
|
||||||
|
|
||||||
|
int ret = -1;
|
||||||
if (callout_active(c)) {
|
if (callout_active(c)) {
|
||||||
if (safe) {
|
if (safe) {
|
||||||
locker.Unlock();
|
locker.Unlock();
|
||||||
while (callout_active(c))
|
while (callout_active(c))
|
||||||
snooze(100);
|
snooze(100);
|
||||||
|
locker.Lock();
|
||||||
}
|
}
|
||||||
return 0;
|
ret = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (c->c_due <= 0)
|
if (c->c_due <= 0)
|
||||||
return -1;
|
return ret;
|
||||||
|
|
||||||
// this timer is scheduled, cancel it
|
// this timer is scheduled, cancel it
|
||||||
list_remove_item(&sTimers, c);
|
list_remove_item(&sTimers, c);
|
||||||
c->c_due = 0;
|
c->c_due = 0;
|
||||||
return 1;
|
return (ret == -1) ? 1 : ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user