Re: Fix signal handler

2012-09-29 Thread SF Markus Elfring
2. Would it eventually need to be protected by a mutex (from the multi-threading perspective)? Using a mutex in a signal handler is neither conforming nor working in practise, so far worse than the current approach. I find it interesting that the statements ECB_MEMORY_FENCE_ACQUIRE and

Re: Fix signal handler

2012-09-25 Thread SF Markus Elfring
Will any lock-free approaches become feasible for comparison and selection by a build configuration? Libev's algorithm is already lock-free (and has to be) - what do you want to compare it with? How do you think about information from an article like Signal-Safe Locks?

Re: Fix signal handler

2012-09-25 Thread Marc Lehmann
On Tue, Sep 25, 2012 at 09:20:50AM +0200, SF Markus Elfring elfr...@users.sourceforge.net wrote: How do you think about information from an article like Signal-Safe Locks? http://locklessinc.com/articles/signalsafe_locks/ According to the article, it's not applicable to libev and also doesn't

Re: Fix signal handler

2012-09-24 Thread SF Markus Elfring
Can you elaborate on why not? Yes, of course. I find that the information ev_feed_signal ... safe to call this function ..., including signal handlers or random threads. is not satisfied by the current implementation at the moment. Reasons: 1. A shared array is used there. 2. Would it

Re: Fix signal handler

2012-09-24 Thread SF Markus Elfring
1. A shared array is used there. And why would that not be safe? It is not guaranteed that it can be modified in an atomic way. Nothing suggests otherwise. Race conditions are hard to diagnose, aren't they? Is it also a software challenge to agree on proper solutions for this

Re: Fix signal handler

2012-09-24 Thread Marc Lehmann
On Mon, Sep 24, 2012 at 12:50:12PM +0200, SF Markus Elfring elfr...@users.sourceforge.net wrote: And why would that not be safe? It is not guaranteed that it can be modified in an atomic way. Ok, I herewith guarantee it to you. Moreover, atomicity is not required for this variable for

Fix signal handler

2012-09-23 Thread SF Markus Elfring
Hello, I suggest to look at the implementation of the function ev_sighandler again. http://cvs.schmorp.de/libev/ev.c?revision=1.448view=markup#l2029 It calls the function ev_feed_signal which works with the global array signals. I find that the use of this data type is not async-signal-safe for

Re: Fix signal handler

2012-09-23 Thread Marc Lehmann
On Sun, Sep 23, 2012 at 03:51:36PM +0200, SF Markus Elfring elfr...@users.sourceforge.net wrote: It calls the function ev_feed_signal which works with the global array signals. I find that the use of this data type is not async-signal-safe for a strictly conforming program. libev is quite

Re: Fix signal handler

2012-09-23 Thread SF Markus Elfring
So the real question is whether this is a bug or not, or in other words, does this break any of the guarantees that libev gives on any platform that libev is used on? I would see it as an open issue (or more a bug) for a specific implementation detail where I would like to recommend a few

Re: Fix signal handler

2012-09-23 Thread Marc Lehmann
On Sun, Sep 23, 2012 at 07:40:59PM +0200, SF Markus Elfring elfr...@users.sourceforge.net wrote: The expectations from an information in the documentation like the following can not be completely satisfied at the moment. Can you elaborate on why not? As far as we know, the current method

Re: Fix signal handler

2012-09-23 Thread Colin McCabe
If you check the header file, you find that ev_feed_signal_event is writing to a variable of type EV_ATOMIC_T, which turns out to be a typedef for sig_atomic_t. So it's almost standards-compliant, except for the fact that technically the standard says you must use volatile, and libev uses memory

Re: Fix signal handler

2012-09-23 Thread Marc Lehmann
On Sun, Sep 23, 2012 at 02:43:18PM -0700, Colin McCabe cmcc...@alumni.cmu.edu wrote: If you check the header file, you find that ev_feed_signal_event is writing to a variable of type EV_ATOMIC_T, which turns out to be a typedef for sig_atomic_t. Actually, volatile sig_atomic_t, unless