Date: Fri, 01 Jun 2007 09:25:27 -0700 From: Sam Leffler <sam@errno.com> To: Artis Caune <Artis.Caune@latnet.lv> Cc: hackers@freebsd.org Subject: Re: stopping callouts Message-ID: <46604877.7030007@errno.com> In-Reply-To: <465FF29B.3010307@latnet.lv> References: <465FF29B.3010307@latnet.lv>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?46604877.7030007>