patch: sleep/nanosleep bug
Wed Dec 16 16:09:00 GMT 2009
On Fri, Nov 20, 2009 at 07:15:40AM -0700, Eric Blake wrote:
>-----BEGIN PGP SIGNED MESSAGE-----
>According to Christopher Faylor on 11/18/2009 1:47 PM:
>> On Wed, Nov 18, 2009 at 01:13:53PM -0700, Eric Blake wrote:
>>> 2009-11-18 Eric Blake <firstname.lastname@example.org>
>>> * signal.cc (nanosleep): Support 'infinite' sleep times.
>>> (sleep): Avoid uninitialized memory.
>> Sorry but, while I agree with the basic idea, this seems like
>> unnecessary use of recursion. It seems like you could accomplish the
>> same thing by just putting the cancelable_wait in a for loop. I think
>> adding recursion here obfuscates the function unnecesarily.
>How about the following, then? Same changelog.
It wonder if your while (!done) loop could be expressed as a for loop but
it isn't enough of an issue to block inclusion of this patch.
So, thanks for the patch and please check in. This will then go into 1.7.2.
>+ while (!done)
>- _my_tls.call_signal_handler ();
>- set_errno (EINTR);
>- res = -1;
>+ /* Divide user's input into transactions no larger than 49.7
>+ days at a time. */
>+ if (sec > HIRES_DELAY_MAX)
>+ req = ((HIRES_DELAY_MAX * 1000 + resolution - 1)
>+ / resolution * resolution);
>+ sec -= HIRES_DELAY_MAX;
>+ req = ((sec * 1000 + (rqtp->tv_nsec + 999999) / 1000000
>+ + resolution - 1) / resolution) * resolution;
>+ sec = 0;
>+ done = true;
More information about the Cygwin-patches