On Thu, Feb 22, 2007 at 05:52:10PM -0800, Scott Lamb wrote:
 [...]
> What about just never using sigprocmask() or pthread_sigmask()? The  
> patch I sent to the list a while back fixes two bugs:
>
> * prevents Anton Povarov's reported race in which a signal delivered  
> quickly after event_signal_add() isn't handled correctly
> * avoids sigprocmask(), which is not pthread-safe.

I like your approach; it seems a lot more elegant than the
block-and-unblock approach in the current code.  It looks at least
superficially okay to me.

My only libevent thread needs (for Tor) are to be able to have other
threads running besides the thread the uses libevent.  I don't need to
be able to access libevent at all from more than one of them, but I'd
really like to be able to have the subthreads not get killed when a
signal comes in.

If this goes in, it could IMO warrant a 1.3a; we really need this bug
fixed, especially for BSD and OSX users.

> There are still several caveats with threads. Ignoring the complex  
> idea of sharing an event_base between threads (need still has to be  
> proven...I've been way too busy with other things to run the  
> benchmarks I've been wanting to), these ones remain:
> 
> 2. If you forget event_base_set on an event, it's associated with the  
> latest base created. This will probably work most of the time. It'd  
> be much less confusing if it consistently broke.

How about an "event_clear_default_base()" function to force
current_base to NULL, so that things will consistently break if called
with the default base?

> 3. Each new base created leaks the existing ev_signal_pair descriptors.
>
> 4. Signals are delivered to whatever event loop happens to see them  
> first.
>
> 6. You can't destroy an event_base.

event_base_free() doesn't work?

[...]
> There's one subtlety to it. With my change, evsignal_process() runs
> with signals unblocked, so timing is critical. The original code is
> then racy:

I agree that this is a subtle point; maybe the code needs a comment
explaining the possible race issues.

yrs,
-- 
Nick Mathewson

Attachment: pgpE0eafu9rax.pgp
Description: PGP signature

_______________________________________________
Libevent-users mailing list
Libevent-users@monkey.org
http://monkey.org/mailman/listinfo/libevent-users

Reply via email to