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
_______________________________________________
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to