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:
Augustin Cavalier 2023-03-24 11:34:34 -04:00
parent c650846d9e
commit 90d34dcaf0

View File

@ -1,6 +1,6 @@
/*
* Copyright 2010, Axel Dörfler, axeld@pinc-software.de.
* Copyright 2018, Haiku, Inc. All rights reserved.
* Copyright 2018-2023, Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT license.
*/
@ -218,22 +218,24 @@ _callout_stop_safe(struct callout *c, int safe)
MutexLocker locker(sLock);
int ret = -1;
if (callout_active(c)) {
if (safe) {
locker.Unlock();
while (callout_active(c))
snooze(100);
locker.Lock();
}
return 0;
ret = 0;
}
if (c->c_due <= 0)
return -1;
return ret;
// this timer is scheduled, cancel it
list_remove_item(&sTimers, c);
c->c_due = 0;
return 1;
return (ret == -1) ? 1 : ret;
}