Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit93120f3

Browse files
committed
In a Windows backend, don't build src/port/pgsleep.c's version of
pg_usleep at all. Instead call the replacement function inport/win32/signal.c by that name. Avoids tricky macro-redefinitionlogic and suppresses a compiler warning; furthermore it ensures thatno one can accidentally use the non-signal-aware version of pg_usleepin a Windows backend.
1 parente96373a commit93120f3

File tree

4 files changed

+24
-16
lines changed

4 files changed

+24
-16
lines changed

‎src/backend/port/win32/signal.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
77
*
88
* IDENTIFICATION
9-
* $PostgreSQL: pgsql/src/backend/port/win32/signal.c,v 1.16 2006/03/05 15:58:35 momjian Exp $
9+
* $PostgreSQL: pgsql/src/backend/port/win32/signal.c,v 1.17 2006/07/16 20:17:04 tgl Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -41,11 +41,19 @@ static pqsigfunc pg_signal_defaults[PG_SIGNAL_COUNT];
4141
staticDWORDWINAPIpg_signal_thread(LPVOIDparam);
4242
staticBOOLWINAPIpg_console_handler(DWORDdwCtrlType);
4343

44-
/* Sleep function that can be interrupted by signals */
44+
45+
/*
46+
* pg_usleep --- delay the specified number of microseconds, but
47+
* stop waiting if a signal arrives.
48+
*
49+
* This replaces the non-signal-aware version provided by src/port/pgsleep.c.
50+
*/
4551
void
46-
pgwin32_backend_usleep(longmicrosec)
52+
pg_usleep(longmicrosec)
4753
{
48-
if (WaitForSingleObject(pgwin32_signal_event, (microsec<500 ?1 : (microsec+500) /1000))==WAIT_OBJECT_0)
54+
if (WaitForSingleObject(pgwin32_signal_event,
55+
(microsec<500 ?1 : (microsec+500) /1000))
56+
==WAIT_OBJECT_0)
4957
{
5058
pgwin32_dispatch_queued_signals();
5159
errno=EINTR;

‎src/backend/postmaster/syslogger.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*
1919
*
2020
* IDENTIFICATION
21-
* $PostgreSQL: pgsql/src/backend/postmaster/syslogger.c,v 1.27 2006/07/11 18:26:10 momjian Exp $
21+
* $PostgreSQL: pgsql/src/backend/postmaster/syslogger.c,v 1.28 2006/07/16 20:17:04 tgl Exp $
2222
*
2323
*-------------------------------------------------------------------------
2424
*/
@@ -348,7 +348,7 @@ SysLoggerMain(int argc, char *argv[])
348348
* detect pipe EOF. The main thread just wakes up once a second to
349349
* check for SIGHUP and rotation conditions.
350350
*/
351-
pgwin32_backend_usleep(1000000);
351+
pg_usleep(1000000L);
352352
#endif/* WIN32 */
353353

354354
if (pipe_eof_seen)

‎src/include/port/win32.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/include/port/win32.h,v 1.52 2006/06/07 22:24:45 momjian Exp $ */
1+
/* $PostgreSQL: pgsql/src/include/port/win32.h,v 1.53 2006/07/16 20:17:04 tgl Exp $ */
22

33
/* undefine and redefine after #include */
44
#undef mkdir
@@ -221,11 +221,6 @@ HANDLEpgwin32_create_signal_listener(pid_t pid);
221221
voidpgwin32_dispatch_queued_signals(void);
222222
voidpg_queue_signal(intsignum);
223223

224-
#ifndefFRONTEND
225-
#definepg_usleep(t) pgwin32_backend_usleep(t)
226-
voidpgwin32_backend_usleep(longmicrosec);
227-
#endif
228-
229224
/* In backend/port/win32/socket.c */
230225
#ifndefFRONTEND
231226
#definesocket(af,type,protocol) pgwin32_socket(af, type, protocol)

‎src/port/pgsleep.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
88
*
9-
* $PostgreSQL: pgsql/src/port/pgsleep.c,v 1.7 2006/03/05 15:59:10 momjian Exp $
9+
* $PostgreSQL: pgsql/src/port/pgsleep.c,v 1.8 2006/07/16 20:17:04 tgl Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -15,6 +15,12 @@
1515
#include<unistd.h>
1616
#include<sys/time.h>
1717

18+
/*
19+
* In a Windows backend, we don't use this implementation, but rather
20+
* the signal-aware version in src/backend/port/win32/signal.c.
21+
*/
22+
#if defined(FRONTEND)|| !defined(WIN32)
23+
1824
/*
1925
* pg_usleep --- delay the specified number of microseconds.
2026
*
@@ -24,9 +30,6 @@
2430
*
2531
* On machines where "long" is 32 bits, the maximum delay is ~2000 seconds.
2632
*/
27-
#ifdefpg_usleep
28-
#undef pg_usleep
29-
#endif
3033
void
3134
pg_usleep(longmicrosec)
3235
{
@@ -43,3 +46,5 @@ pg_usleep(long microsec)
4346
#endif
4447
}
4548
}
49+
50+
#endif/* defined(FRONTEND) || !defined(WIN32) */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp