-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hm, I also fixed this thread race condition recently, try using more
recent libevent or svn trunk. It has event_base_once() to use with
event_base_loopexit().

Best regards,
   Wouter

harry wrote:
> I'm having trouble terminating event loops using event_base_loopexit().
> The way it works, as I understand it, is by scheduling an event that
> sets the event_gotterm flag, which will cause the loop to quit after
> its current iteration.  Here's the sequence of function calls:
> 
>   event_base_loopexit()
>     event_once()
>       evtimer_set()    /* this sets ev_base to current_base */
>       event_add()
> 
> This uses the event loop associated with current_base to run the
> callback (event_loopexit_cb()) instead of the base that was passed to
> event_base_loopexit(), which seems weird, but okay.  However, if
> there's no loop running with current_base, event_loopexit_cb() never
> gets called so my loop never terminates.  One could imagine this
> happening if you do something like:
> 
>   base_1 = event_init();
>   base_2 = event_init();    /* current_base is now base_2 */
>   event_base_loop(base_1, 0);
>   /* somehow call event_base_loopexit(base_1, 0) now */
> 
> Why do we schedule a callback to set event_gotterm?  This is a boolean
> flag and we only care if it's zero or non-zero, so why do we need to
> synchronize access to it?
> 
> Harry
> _______________________________________________
> Libevent-users mailing list
> Libevent-users@monkey.org
> http://monkey.org/mailman/listinfo/libevent-users

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org

iD8DBQFGODSqkDLqNwOhpPgRAg43AJ0YxCNTNIRHptjoOnTjN/Tk/eMEaACfT3AV
1zjPqm+jB1zG9psUqRAW7g0=
=1EXD
-----END PGP SIGNATURE-----
_______________________________________________
Libevent-users mailing list
Libevent-users@monkey.org
http://monkey.org/mailman/listinfo/libevent-users

Reply via email to