diff options
author | Tom Lane | 2006-07-16 20:17:04 +0000 |
---|---|---|
committer | Tom Lane | 2006-07-16 20:17:04 +0000 |
commit | a0161fe68b7784f4e72340c6edeadcd6d2c4ee1b (patch) | |
tree | ac8e89cb45bd5c5722bb0bd3e1b5368eb52307e0 | |
parent | 5a2f99bcabf95e2458af56f32a659f43ed49361f (diff) |
In a Windows backend, don't build src/port/pgsleep.c's version of
pg_usleep at all. Instead call the replacement function in
port/win32/signal.c by that name. Avoids tricky macro-redefinition
logic and suppresses a compiler warning; furthermore it ensures that
no one can accidentally use the non-signal-aware version of pg_usleep
in a Windows backend.
-rw-r--r-- | src/backend/port/win32/signal.c | 14 | ||||
-rw-r--r-- | src/backend/postmaster/syslogger.c | 2 | ||||
-rw-r--r-- | src/include/port/win32.h | 5 | ||||
-rw-r--r-- | src/port/pgsleep.c | 11 |
4 files changed, 20 insertions, 12 deletions
diff --git a/src/backend/port/win32/signal.c b/src/backend/port/win32/signal.c index 9b417846ca..7da6a70744 100644 --- a/src/backend/port/win32/signal.c +++ b/src/backend/port/win32/signal.c @@ -41,11 +41,19 @@ static pqsigfunc pg_signal_defaults[PG_SIGNAL_COUNT]; static DWORD WINAPI pg_signal_thread(LPVOID param); static BOOL WINAPI pg_console_handler(DWORD dwCtrlType); -/* Sleep function that can be interrupted by signals */ + +/* + * pg_usleep --- delay the specified number of microseconds, but + * stop waiting if a signal arrives. + * + * This replaces the non-signal-aware version provided by src/port/pgsleep.c. + */ void -pgwin32_backend_usleep(long microsec) +pg_usleep(long microsec) { - if (WaitForSingleObject(pgwin32_signal_event, (microsec < 500 ? 1 : (microsec + 500) / 1000)) == WAIT_OBJECT_0) + if (WaitForSingleObject(pgwin32_signal_event, + (microsec < 500 ? 1 : (microsec + 500) / 1000)) + == WAIT_OBJECT_0) { pgwin32_dispatch_queued_signals(); errno = EINTR; diff --git a/src/backend/postmaster/syslogger.c b/src/backend/postmaster/syslogger.c index b915ac1575..8ce5d6e681 100644 --- a/src/backend/postmaster/syslogger.c +++ b/src/backend/postmaster/syslogger.c @@ -348,7 +348,7 @@ SysLoggerMain(int argc, char *argv[]) * detect pipe EOF. The main thread just wakes up once a second to * check for SIGHUP and rotation conditions. */ - pgwin32_backend_usleep(1000000); + pg_usleep(1000000L); #endif /* WIN32 */ if (pipe_eof_seen) diff --git a/src/include/port/win32.h b/src/include/port/win32.h index d563ec2d83..2d8320a386 100644 --- a/src/include/port/win32.h +++ b/src/include/port/win32.h @@ -221,11 +221,6 @@ HANDLE pgwin32_create_signal_listener(pid_t pid); void pgwin32_dispatch_queued_signals(void); void pg_queue_signal(int signum); -#ifndef FRONTEND -#define pg_usleep(t) pgwin32_backend_usleep(t) -void pgwin32_backend_usleep(long microsec); -#endif - /* In backend/port/win32/socket.c */ #ifndef FRONTEND #define socket(af, type, protocol) pgwin32_socket(af, type, protocol) diff --git a/src/port/pgsleep.c b/src/port/pgsleep.c index c3fca57168..131f1e5e92 100644 --- a/src/port/pgsleep.c +++ b/src/port/pgsleep.c @@ -16,6 +16,12 @@ #include <sys/time.h> /* + * In a Windows backend, we don't use this implementation, but rather + * the signal-aware version in src/backend/port/win32/signal.c. + */ +#if defined(FRONTEND) || !defined(WIN32) + +/* * pg_usleep --- delay the specified number of microseconds. * * NOTE: although the delay is specified in microseconds, the effective @@ -24,9 +30,6 @@ * * On machines where "long" is 32 bits, the maximum delay is ~2000 seconds. */ -#ifdef pg_usleep -#undef pg_usleep -#endif void pg_usleep(long microsec) { @@ -43,3 +46,5 @@ pg_usleep(long microsec) #endif } } + +#endif /* defined(FRONTEND) || !defined(WIN32) */ |