Tom Lane wrote:
> Bruce Momjian <bruce@momjian.us> writes:
> ! /* WaitForSingleObjectEx() uses milliseconds */
> > ! waittime = timerCommArea.value.it_value.tv_usec / 1000 + timerCommArea.value.it_value.tv_sec *
1000;
>
> Seems like this probably ought to round up not down:
>
> waittime = (timerCommArea.value.it_value.tv_usec + 999) / 1000 + timerCommArea.value.it_value.tv_sec * 1000;
>
> Otherwise, an attempt to wait for 100 usec would convert to waittime 0,
> which seems like a bad thing. In general the semantics of timed waits
> are always supposed to be "you wait at least this long".
I thought about that, but because statement_timeout is in millis, and
not micros, we can't have a value that gets rounded down. I am
thinking a cleaner solution is to check for secs and if that is 0 and
microsecs < 1000, you set millis = 1.
Patch attached and applied to head and 8.1.X.
--
Bruce Momjian bruce@momjian.us
EnterpriseDB http://www.enterprisedb.com
+ If your life is a hard drive, Christ can be your backup. +
Index: src/backend/port/win32/timer.c
===================================================================
RCS file: /cvsroot/pgsql/src/backend/port/win32/timer.c,v
retrieving revision 1.10
diff -c -c -r1.10 timer.c
*** src/backend/port/win32/timer.c 9 Aug 2006 17:47:03 -0000 1.10
--- src/backend/port/win32/timer.c 9 Aug 2006 20:39:16 -0000
***************
*** 56,63 ****
--- 56,69 ----
timerCommArea.value.it_value.tv_usec == 0)
waittime = INFINITE; /* Cancel the interrupt */
else
+ {
+ /* Minimum wait time is 1ms */
+ if (timerCommArea.value.it_value.tv_sec == 0 &&
+ timerCommArea.value.it_value.tv_usec < 1000)
+ timerCommArea.value.it_value.tv_usec = 1000;
/* WaitForSingleObjectEx() uses milliseconds */
waittime = timerCommArea.value.it_value.tv_usec / 1000 + timerCommArea.value.it_value.tv_sec * 1000;
+ }
ResetEvent(timerCommArea.event);
LeaveCriticalSection(&timerCommArea.crit_sec);
}