lua-users home
lua-l archive

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


Excerpts from Sam Roberts's message of Tue Apr 13 19:42:54 +0100 2010:
> 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!
> 

I don't get it, why does POSIX care what we do when signals are handled inside an app? :)

> The realtime extensions for signalling were developed in part because
> signals are NOT reliably queued, and realtime processes wanted that
> behaviour.
> 

Again, this has nothing to do with the OS. I think you're missing the point that lua-signal
does not block signals.

> 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.

It didn't before we fixed it. It used to set a debug hook (preserving the old one). When the hook ran it would immediately restore the old hook and then call the Lua signal handler.

The problem being that if a second signal was triggered before the hook ran then lua-signal would set a new (3rd) hook, and preserve the already-set lua-signal (2nd) hook, and losing forever the original application's (1st) hook. The 3rd hook would restore the 2nd hook, call the callback which would trigger the 2nd hook to run, which would restore itself and the whole thing descended from there.

The solution I added was to queue the signals (as you can see in the Prosody version of lua-signal), Patrick uses simply a counter. Both methods work, and I don't see how POSIX could possibly say we can't do either of these things :)

Regards,
Matthew