nearly-tickless-tinc
Loïc Grenié
loic.grenie at gmail.com
Fri Jun 3 11:36:58 CEST 2011
2011/6/2 Guus Sliepen <guus at tinc-vpn.org>:
> On Thu, Jun 02, 2011 at 10:43:43AM +0200, Loïc Grenié wrote:
>> 2011/6/2 Guus Sliepen <guus at tinc-vpn.org>:
>> > Hm, in this case it is better to explicitly use #ifdef ... #else ... #endif in
>> > the main loop, instead of #defining tinc_pselect and friends. With the former
>> > it is more clear what happens.
>>
>> Here you go !
>
> By "Here you go", did you mean there should have been a patch attached to the
> email? :)
I'll ignore such a futile insinuation that I might have forgotten
to attach anything.
>> It is probably a good idea to also change time comparison: with this
>> patch "now" is evaluated after pselect(), thus with code like this:
>>
>> timeout = now+1;
>> [... pselect() lasting 1s ... ]
>> if (timeout < now) {
>> contional code
>> }
>>
>> conditional code will not get executed. It would be if comparison were
>> timeout <= now (the instruction "next_event++;" in the patch would
>> also disappear). I can take care of it.
>
> now = time(NULL) should indeed by right after pselect(). Using <= seems better
> as well.
Ok. Please check that that comparison with now in try_harder is
still correct
and check also "diff = " in "expire_events".
> From the patch in the previous email:
>
>> + if(next_event <= now || sighup || sigalrm)
>
> It shouldn't be necessary to check for sighup or sigalrm at that point; if they
> are set there then surely pselect() will return with EINTR immediately anyway.
It is indeed not necessary because signals are blocked outside pselect
and sighup || sigalrm can only be set by the handlers. However if ever they
were set pselect would *not* return EINTR (signals have already been
caught). I've removed them.
Thanks,
Loïc
-------------- next part --------------
A non-text attachment was scrubbed...
Name: tinc-pselect.diff
Type: text/x-diff
Size: 8210 bytes
Desc: not available
URL: <http://www.tinc-vpn.org/pipermail/tinc-devel/attachments/20110603/25206180/attachment.diff>
More information about the tinc-devel
mailing list