diff options
author | Tom Lane | 2013-06-23 18:43:10 +0000 |
---|---|---|
committer | Tom Lane | 2013-06-23 18:43:10 +0000 |
commit | 8c1a71d36f5d667f3c2236e0e015a48f809ca240 (patch) | |
tree | ab49a58a73858b7b69c3ffd26caca8bcdc97f45b | |
parent | 1f09121b4edee8b4d4cdd4ee0a8cffacee7b85f7 (diff) |
Add a comment warning against use of pg_usleep() for long sleeps.
Follow-up to commit 873ab97219caabeb2f7b390268a4fe01e2b7518c, in which
I noted that WaitLatch was a better solution in the commit log message,
but neglected to add any documentation in the code.
-rw-r--r-- | src/port/pgsleep.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/port/pgsleep.c b/src/port/pgsleep.c index 1e2c74dbab..3e6b665625 100644 --- a/src/port/pgsleep.c +++ b/src/port/pgsleep.c @@ -29,6 +29,16 @@ * the requested delay to be rounded up to the next resolution boundary. * * On machines where "long" is 32 bits, the maximum delay is ~2000 seconds. + * + * CAUTION: the behavior when a signal arrives during the sleep is platform + * dependent. On most Unix-ish platforms, a signal does not terminate the + * sleep; but on some, it will (the Windows implementation also allows signals + * to terminate pg_usleep). And there are platforms where not only does a + * signal not terminate the sleep, but it actually resets the timeout counter + * so that the sleep effectively starts over! It is therefore rather hazardous + * to use this for long sleeps; a continuing stream of signal events could + * prevent the sleep from ever terminating. Better practice for long sleeps + * is to use WaitLatch() with a timeout. */ void pg_usleep(long microsec) |