lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Mon, Apr 12, 2010 at 6:45 PM, Matthew Wild <mwild1@gmail.com> wrote:
> On 13/04/10 03:05, Sam Roberts wrote:
>>
>> And why do you go through the effort of counting signals? Signal
>> delivery is not reliable, the pending
>> signals are a bitmask, there is no counting for non-realtime signals.
>>
>
> We encountered an issue with it in Prosody whereby multiple signals in quick
> succession (that is, multiple signals before the Lua callback is actually
> called) would mess up the lua-signal state and cause looping.
> Counting/queuing the signals seems an appropriate solution to me, but do
> correct me if I'm wrong.

Honestly, despite what Patrick said, I've never heard of signals being
allowed to be queued by POSIX. Its a big spec, though!

The realtime extensions for signalling were developed in part because
signals are NOT reliably queued, and realtime processes wanted that
behaviour. This is alluded to here, for example:

http://www.lynuxworks.com/products/posix/signals.php3

and there is even a seperate function for sending queuable signals:

http://www.opengroup.org/onlinepubs/007908799/xsh/sigqueue.html

Normal POSIX just has the notion of pending or not-pending, with no count:

http://www.opengroup.org/onlinepubs/007908799/xsh/sigpending.html

Or maybe I missed something, and POSIX "allows" all signals to be
queued, not just realtime. If so, I very much doubt if any mainstream
unixen implement that, but whatever.

It doesn't sound like this is related to the "messed up" lua signal
state you saw. The hook function just increments a global count. I'm
not sure if the signal counts were declared as sigatomic_t, it's
possible you saw a reentrancy problem, or were so many signals getting
delivered that lua-signal was effectively busy-looping calling the lua
function intended to handle it? Or maybe you were using signal()
instead of sigaction() and running into some oddity of signal handling
on your system? signal() isn't very portable, see Portability:

http://www.kernel.org/doc/man-pages/online/pages/man2/signal.2.html

Cheers,
Sam