About free watcher in callback function
Marc Lehmann
schmorp at schmorp.de
Mon Jul 16 13:13:27 CEST 2012
On Mon, Jul 16, 2012 at 09:57:55AM +0800, 钱晓明 <mailtoantares at 163.com> wrote:
> Hi, if my ev_io watcher is allocated by malloc(), can I stop it and free() it in its read/write callback function? After returned from callback function, dose libev still access this watcher?
On Mon, Jul 16, 2012 at 04:51:55AM +0200, Jonathan Neuschäfer <j.neuschaefer at gmx.net> wrote:
> AFAIK libev won't access a stopped watcher, so you can do that.
Basically yes - one minor nitpick though: a stopped watcher is not enough,
as it might sxpitll be pending (very unlikely in a watcher callback, but
possible if the callback makes it pending again).
ev_XXX_stop is enough to tell libev to keep it hands off because it also does
the equivalent of ev_clear_pending.
So merely being stopped is not ehough, but using ev_XXX_stop is enough.
--
The choice of a Deliantra, the free code+content MORPG
-----==- _GNU_ http://www.deliantra.net
----==-- _ generation
---==---(_)__ __ ____ __ Marc Lehmann
--==---/ / _ \/ // /\ \/ / schmorp at schmorp.de
-=====/_/_//_/\_,_/ /_/\_\
More information about the libev
mailing list