Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit ab9ed9b

Browse files
committed
Assert that pgwin32_signal_initialize() has been called early enough.
Before the pgwin32_signal_initialize() call, the backend version of pg_usleep() has no effect. No in-tree code falls afoul of that today, but temporary commit 2307868 did so. Discussion: https://postgr.es/m/20190402135442.GA1173872@rfd.leadboat.com
1 parent f433394 commit ab9ed9b

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/backend/port/win32/signal.c

+3
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ static BOOL WINAPI pg_console_handler(DWORD dwCtrlType);
5252
void
5353
pg_usleep(long microsec)
5454
{
55+
Assert(pgwin32_signal_event != NULL);
5556
if (WaitForSingleObject(pgwin32_signal_event,
5657
(microsec < 500 ? 1 : (microsec + 500) / 1000))
5758
== WAIT_OBJECT_0)
@@ -108,6 +109,7 @@ pgwin32_dispatch_queued_signals(void)
108109
{
109110
int exec_mask;
110111

112+
Assert(pgwin32_signal_event != NULL);
111113
EnterCriticalSection(&pg_signal_crit_sec);
112114
while ((exec_mask = UNBLOCKED_SIGNAL_QUEUE()) != 0)
113115
{
@@ -209,6 +211,7 @@ pgwin32_create_signal_listener(pid_t pid)
209211
void
210212
pg_queue_signal(int signum)
211213
{
214+
Assert(pgwin32_signal_event != NULL);
212215
if (signum >= PG_SIGNAL_COUNT || signum <= 0)
213216
return;
214217

src/port/open.c

+3
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ pgwin32_open(const char *fileName, int fileFlags,...)
7070
(O_RANDOM | O_SEQUENTIAL | O_TEMPORARY) |
7171
_O_SHORT_LIVED | O_DSYNC | O_DIRECT |
7272
(O_CREAT | O_TRUNC | O_EXCL) | (O_TEXT | O_BINARY))) == fileFlags);
73+
#ifndef FRONTEND
74+
Assert(pgwin32_signal_event != NULL); /* small chance of pg_usleep() */
75+
#endif
7376

7477
#ifdef FRONTEND
7578

0 commit comments

Comments
 (0)