mirror of https://github.com/postgres/postgres
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.
This commit is contained in:
parent
e96373aae5
commit
93120f3501
|
@ -6,7 +6,7 @@
|
|||
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/port/win32/signal.c,v 1.16 2006/03/05 15:58:35 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/port/win32/signal.c,v 1.17 2006/07/16 20:17:04 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
@ -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;
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/postmaster/syslogger.c,v 1.27 2006/07/11 18:26:10 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/postmaster/syslogger.c,v 1.28 2006/07/16 20:17:04 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
@ -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)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $PostgreSQL: pgsql/src/include/port/win32.h,v 1.52 2006/06/07 22:24:45 momjian Exp $ */
|
||||
/* $PostgreSQL: pgsql/src/include/port/win32.h,v 1.53 2006/07/16 20:17:04 tgl Exp $ */
|
||||
|
||||
/* undefine and redefine after #include */
|
||||
#undef mkdir
|
||||
|
@ -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)
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
*
|
||||
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/port/pgsleep.c,v 1.7 2006/03/05 15:59:10 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/port/pgsleep.c,v 1.8 2006/07/16 20:17:04 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
@ -15,6 +15,12 @@
|
|||
#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) */
|
||||
|
|
Loading…
Reference in New Issue