nearly-tickless-tinc
Guus Sliepen
guus at tinc-vpn.org
Sun May 29 22:25:11 CEST 2011
On Sun, May 29, 2011 at 10:17:03PM +0200, Loïc Grenié wrote:
> > but to prevent race conditions, only pselect() should change the
> > signal mask in the main loop.
>
> I might be wrong but I think there is no race condition in my code.
> However I can eliminate all the problems if you tell me that tincd
> does not block/unblock SIGHUP and SIGALARM while running
> (block_mask can be initialized before the main loop, signals blocked
> there and never unblocked). In that case the main loop is mostly
> unchanged (except for computing "next_event") and we can
> emulate pselect() when it does not exist (or is racy) by a
> standard select() with a 1s timeout (without blocking signals
> obviously).
Tinc never changes the signal mask. The only thing it does is install signal
handlers. So you can read the signal mask once before main_loop(), add SIGUP
and SIGALARM, and use that for pselect().
> The "selfpipe" trick is another option obviously if you prefer. It is
> not very elegant but has no real downside (I don't know whether
> there are pipes under Windows, but since there are no signals
> anyway...).
Windows has pipes. But again, I think it is less work and code to use
pselect(). You might want to check whether it is properly supported on the BSD
variants (including MacOS/X) though.
--
Met vriendelijke groet / with kind regards,
Guus Sliepen <guus at tinc-vpn.org>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://www.tinc-vpn.org/pipermail/tinc-devel/attachments/20110529/0831d60d/attachment.pgp>
More information about the tinc-devel
mailing list