On Mon, Jul 16, 2012 at 09:57:55AM +0800, 钱晓明 <[email protected]> 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 
<[email protected]> 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
      --==---/ / _ \/ // /\ \/ /      [email protected]
      -=====/_/_//_/\_,_/ /_/\_\

_______________________________________________
libev mailing list
[email protected]
http://lists.schmorp.de/cgi-bin/mailman/listinfo/libev

Reply via email to