stopping callouts
Sam Leffler
sam at errno.com
Fri Jun 1 17:02:08 UTC 2007
Artis Caune wrote:
> Hello FreeBSD-hackers!
>
> what is the right way to stop callout which is initialized with mutex:
> callout_init_mtx(&callout_function, &my_mtx, 0);
>
> should I lock mutex before calling callout_drain() or not?
>
> man page says: callout_drain() is identical to callout_stop() and
> if the callout has an associated mutex, then that mutex must be held
> when callout_stop() is called.
>
>
> /* MOD_UNLOAD */
>
> MTX_LOCK;
> callout_drain()
> MTX_UNLOCK;
If you use callout_init_mtx then use callout_stop while holding my_mtx;
if the callout is blocked waiting for my_mtx the request will be discarded.
callout_drain should not be called while holding my_mtx because it can
sleep.
Sam
More information about the freebsd-hackers
mailing list