Re: TODO-item: Add sleep() function, remove from regress.c - Mailing list pgsql-patches

From Andrew Dunstan
Subject Re: TODO-item: Add sleep() function, remove from regress.c
Date
Msg-id 43C4592F.6000104@dunslane.net
Whole thread Raw
In response to Re: TODO-item: Add sleep() function, remove from regress.c  ("Jim C. Nasby" <jnasby@pervasive.com>)
Responses Re: TODO-item: Add sleep() function, remove from regress.c
List pgsql-patches

Jim C. Nasby wrote:

>On Tue, Jan 10, 2006 at 11:31:13AM +0100, Joachim Wieland wrote:
>
>
>>No, cancelling the sleep works (at least for Unix). Isn't cancelling
>>implemented via a signal that interrupts select() ?
>>
>>Anyway, I've changed it, removing the ~2000s limit is a good point.
>>+     while (secs > 1.0)
>>+     {
>>+         pg_usleep(1000000);
>>+         CHECK_FOR_INTERRUPTS();
>>+         secs -= 1.0;
>>+     }
>>
>>
>
>Won't this result in a call to pg_sleep with a long sleep time ending up
>sleeping noticeably longer than requested?
>
>

Looks like it to me.

Instead of using a counter it might be better to set a target end time
and check that against the value returned from time() or gettimeofday().

cheers

andrew

pgsql-patches by date:

Previous
From: "Jim C. Nasby"
Date:
Subject: Re: TODO-item: Add sleep() function, remove from regress.c
Next
From: Mark Kirkwood
Date:
Subject: Re: Summary table trigger example race condition