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

Commitc94ae9d

Browse files
committed
Emulate sigprocmask(), not sigsetmask(), on Windows.
Since commita65e086, we've required Unix systems to havesigprocmask(). As noted in that commit's message, we were stillemulating the historical pre-standard sigsetmask() function in ourWindows support code. Emulate standard sigprocmask() instead, forconsistency.The PG_SETMASK() abstraction is now redundant and all calls could intheory be replaced by plain sigprocmask() calls, but that isn't done bythis commit.Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>Discussion:https://postgr.es/m/3153247.1657834482%40sss.pgh.pa.us
1 parent3b8d23a commitc94ae9d

File tree

2 files changed

+30
-10
lines changed

2 files changed

+30
-10
lines changed

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

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ pgwin32_signal_initialize(void)
112112
/*
113113
* Dispatch all signals currently queued and not blocked
114114
* Blocked signals are ignored, and will be fired at the time of
115-
* thepqsigsetmask() call.
115+
* thepqsigprocmask() call.
116116
*/
117117
void
118118
pgwin32_dispatch_queued_signals(void)
@@ -154,20 +154,37 @@ pgwin32_dispatch_queued_signals(void)
154154

155155
/* signal masking. Only called on main thread, no sync required */
156156
int
157-
pqsigsetmask(intmask)
157+
pqsigprocmask(inthow,constsigset_t*set,sigset_t*oset)
158158
{
159-
intprevmask;
159+
if (oset)
160+
*oset=pg_signal_mask;
160161

161-
prevmask=pg_signal_mask;
162-
pg_signal_mask=mask;
162+
if (!set)
163+
return0;
164+
165+
switch (how)
166+
{
167+
caseSIG_BLOCK:
168+
pg_signal_mask |=*set;
169+
break;
170+
caseSIG_UNBLOCK:
171+
pg_signal_mask &= ~*set;
172+
break;
173+
caseSIG_SETMASK:
174+
pg_signal_mask=*set;
175+
break;
176+
default:
177+
errno=EINVAL;
178+
return-1;
179+
}
163180

164181
/*
165182
* Dispatch any signals queued up right away, in case we have unblocked
166183
* one or more signals previously queued
167184
*/
168185
pgwin32_dispatch_queued_signals();
169186

170-
returnprevmask;
187+
return0;
171188
}
172189

173190

‎src/include/libpq/pqsignal.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,18 @@
1515

1616
#include<signal.h>
1717

18-
#ifndefWIN32
1918
#definePG_SETMASK(mask)sigprocmask(SIG_SETMASK, mask, NULL)
20-
#else
19+
20+
#ifdefWIN32
2121
/* Emulate POSIX sigset_t APIs on Windows */
2222
typedefintsigset_t;
2323

24-
externintpqsigsetmask(intmask);
24+
externintpqsigprocmask(inthow,constsigset_t*set,sigset_t*oset);
2525

26-
#definePG_SETMASK(mask)pqsigsetmask(*(mask))
26+
#defineSIG_BLOCK1
27+
#defineSIG_UNBLOCK2
28+
#defineSIG_SETMASK3
29+
#definesigprocmask(how,set,oset) pqsigprocmask((how), (set), (oset))
2730
#definesigemptyset(set)(*(set) = 0)
2831
#definesigfillset(set)(*(set) = ~0)
2932
#definesigaddset(set,signum)(*(set) |= (sigmask(signum)))

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp