|
6 | 6 | * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
|
7 | 7 | *
|
8 | 8 | * IDENTIFICATION
|
9 |
| - * $PostgreSQL: pgsql/src/backend/port/win32/signal.c,v 1.12 2005/10/15 02:49:23 momjian Exp $ |
| 9 | + * $PostgreSQL: pgsql/src/backend/port/win32/signal.c,v 1.13 2005/10/21 21:43:45 tgl Exp $ |
10 | 10 | *
|
11 | 11 | *-------------------------------------------------------------------------
|
12 | 12 | */
|
|
15 | 15 |
|
16 | 16 | #include <libpq/pqsignal.h>
|
17 | 17 |
|
| 18 | +/* |
| 19 | + * These are exported for use by the UNBLOCKED_SIGNAL_QUEUE() macro. |
| 20 | + * pg_signal_queue must be volatile since it is changed by the signal |
| 21 | + * handling thread and inspected without any lock by the main thread. |
| 22 | + * pg_signal_mask is only changed by main thread so shouldn't need it. |
| 23 | + */ |
| 24 | +volatile int pg_signal_queue; |
| 25 | +int pg_signal_mask; |
18 | 26 |
|
19 |
| -/* pg_signal_crit_sec is used to protect only pg_signal_queue. That is the only |
20 |
| - * variable that can be accessed from the signal sending threads! */ |
| 27 | +HANDLE pgwin32_signal_event; |
| 28 | +HANDLE pgwin32_initial_signal_pipe = INVALID_HANDLE_VALUE; |
| 29 | + |
| 30 | +/* |
| 31 | + * pg_signal_crit_sec is used to protect only pg_signal_queue. That is the only |
| 32 | + * variable that can be accessed from the signal sending threads! |
| 33 | + */ |
21 | 34 | static CRITICAL_SECTION pg_signal_crit_sec;
|
22 |
| -static int pg_signal_queue; |
23 | 35 |
|
24 | 36 | static pqsigfunc pg_signal_array[PG_SIGNAL_COUNT];
|
25 | 37 | static pqsigfunc pg_signal_defaults[PG_SIGNAL_COUNT];
|
26 |
| -static int pg_signal_mask; |
27 |
| - |
28 |
| -DLLIMPORT HANDLE pgwin32_signal_event; |
29 |
| -HANDLE pgwin32_initial_signal_pipe = INVALID_HANDLE_VALUE; |
30 | 38 |
|
31 | 39 |
|
32 | 40 | /* Signal handling thread function */
|
@@ -81,21 +89,31 @@ pgwin32_signal_initialize(void)
|
81 | 89 | (errmsg_internal("failed to set console control handler")));
|
82 | 90 | }
|
83 | 91 |
|
| 92 | +/* |
| 93 | + * Support routine for CHECK_FOR_INTERRUPTS() macro |
| 94 | + */ |
| 95 | +void |
| 96 | +pgwin32_check_queued_signals(void) |
| 97 | +{ |
| 98 | + if (WaitForSingleObjectEx(pgwin32_signal_event, 0, TRUE) == WAIT_OBJECT_0) |
| 99 | + pgwin32_dispatch_queued_signals(); |
| 100 | +} |
84 | 101 |
|
85 |
| -/* Dispatch all signals currently queued and not blocked |
| 102 | +/* |
| 103 | + * Dispatch all signals currently queued and not blocked |
86 | 104 | * Blocked signals are ignored, and will be fired at the time of
|
87 |
| - * the sigsetmask() call. */ |
| 105 | + * the sigsetmask() call. |
| 106 | + */ |
88 | 107 | void
|
89 | 108 | pgwin32_dispatch_queued_signals(void)
|
90 | 109 | {
|
91 | 110 | int i;
|
92 | 111 |
|
93 | 112 | EnterCriticalSection(&pg_signal_crit_sec);
|
94 |
| - while (pg_signal_queue & ~pg_signal_mask) |
| 113 | + while (UNBLOCKED_SIGNAL_QUEUE()) |
95 | 114 | {
|
96 | 115 | /* One or more unblocked signals queued for execution */
|
97 |
| - |
98 |
| - int exec_mask = pg_signal_queue & ~pg_signal_mask; |
| 116 | + int exec_mask = UNBLOCKED_SIGNAL_QUEUE(); |
99 | 117 |
|
100 | 118 | for (i = 0; i < PG_SIGNAL_COUNT; i++)
|
101 | 119 | {
|
|
0 commit comments