In a Windows backend, don't build src/port/pgsleep.c's version of
authorTom Lane <tgl@sss.pgh.pa.us>
Sun, 16 Jul 2006 20:17:04 +0000 (20:17 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Sun, 16 Jul 2006 20:17:04 +0000 (20:17 +0000)
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.

src/backend/port/win32/signal.c
src/backend/postmaster/syslogger.c
src/include/port/win32.h
src/port/pgsleep.c

index 9b417846ca31ee1ecc6191cc715e04d8eedffb03..7da6a70744ab0a2143dcd7182efcf94ba8d8725c 100644 (file)
@@ -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;
index b915ac1575a4cf459ba26309f53d870dff368829..8ce5d6e6814424a632c76127611f188c8641f716 100644 (file)
@@ -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)
index d563ec2d83608fe2603bb71e7a33b0efa89eda68..2d8320a386a2abec30b4c5527679916369d9f9fd 100644 (file)
@@ -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)
index c3fca57168f73ab0635171105b05caca962b7bda..131f1e5e923d97e1dee11590666e5ff90847b5e4 100644 (file)
 #include <unistd.h>
 #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.
  *
@@ -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) */