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

Commitcdf6518

Browse files
committed
Retire PG_SETMASK() macro.
In the 90s we needed to deal with computers that still had thepre-standard signal masking APIs. That hasn't been relevant for a verylong time on Unix systems, andc94ae9d got rid of a remainingdependency in our Windows porting code. PG_SETMASK didn't exposesave/restore functionality, so we'd already started using sigprocmask()directly in places, creating the visual distraction of having two waysto spell it. It's not part of the API that extensions are expected tobe using (but if they are, the change will be trivial). It seems like agood time to drop the old macro and just call the standard POSIXfunction.Reviewed-by: Nathan Bossart <nathandbossart@gmail.com>Discussion:https://postgr.es/m/CA%2BhUKG%2BKfQgrhHP2DLTohX1WwubaCBHmTzGnAEDPZ-Gug-Xskg%40mail.gmail.com
1 parente0d70a9 commitcdf6518

File tree

14 files changed

+22
-24
lines changed

14 files changed

+22
-24
lines changed

‎src/backend/access/transam/xact.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2755,7 +2755,7 @@ AbortTransaction(void)
27552755
* handler. We do this fairly early in the sequence so that the timeout
27562756
* infrastructure will be functional if needed while aborting.
27572757
*/
2758-
PG_SETMASK(&UnBlockSig);
2758+
sigprocmask(SIG_SETMASK,&UnBlockSig,NULL);
27592759

27602760
/*
27612761
* check the current transaction state
@@ -5115,7 +5115,7 @@ AbortSubTransaction(void)
51155115
* handler. We do this fairly early in the sequence so that the timeout
51165116
* infrastructure will be functional if needed while aborting.
51175117
*/
5118-
PG_SETMASK(&UnBlockSig);
5118+
sigprocmask(SIG_SETMASK,&UnBlockSig,NULL);
51195119

51205120
/*
51215121
* check the current transaction state

‎src/backend/postmaster/autovacuum.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@ AutoVacLauncherMain(int argc, char *argv[])
568568
PG_exception_stack=&local_sigjmp_buf;
569569

570570
/* must unblock signals before calling rebuild_database_list */
571-
PG_SETMASK(&UnBlockSig);
571+
sigprocmask(SIG_SETMASK,&UnBlockSig,NULL);
572572

573573
/*
574574
* Set always-secure search path. Launcher doesn't connect to a database,
@@ -1589,7 +1589,7 @@ AutoVacWorkerMain(int argc, char *argv[])
15891589
/* We can now handle ereport(ERROR) */
15901590
PG_exception_stack=&local_sigjmp_buf;
15911591

1592-
PG_SETMASK(&UnBlockSig);
1592+
sigprocmask(SIG_SETMASK,&UnBlockSig,NULL);
15931593

15941594
/*
15951595
* Set always-secure search path, so malicious users can't redirect user

‎src/backend/postmaster/bgworker.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,7 @@ SanityCheckBackgroundWorker(BackgroundWorker *worker, int elevel)
726726
staticvoid
727727
bgworker_die(SIGNAL_ARGS)
728728
{
729-
PG_SETMASK(&BlockSig);
729+
sigprocmask(SIG_SETMASK,&BlockSig,NULL);
730730

731731
ereport(FATAL,
732732
(errcode(ERRCODE_ADMIN_SHUTDOWN),

‎src/backend/postmaster/bgwriter.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ BackgroundWriterMain(void)
215215
/*
216216
* Unblock signals (they were blocked when the postmaster forked us)
217217
*/
218-
PG_SETMASK(&UnBlockSig);
218+
sigprocmask(SIG_SETMASK,&UnBlockSig,NULL);
219219

220220
/*
221221
* Reset hibernation state after any error.

‎src/backend/postmaster/checkpointer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ CheckpointerMain(void)
326326
/*
327327
* Unblock signals (they were blocked when the postmaster forked us)
328328
*/
329-
PG_SETMASK(&UnBlockSig);
329+
sigprocmask(SIG_SETMASK,&UnBlockSig,NULL);
330330

331331
/*
332332
* Ensure all shared memory values are set correctly for the config. Doing

‎src/backend/postmaster/pgarch.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ PgArchiverMain(void)
227227
pqsignal(SIGCHLD,SIG_DFL);
228228

229229
/* Unblock signals (they were blocked when the postmaster forked us) */
230-
PG_SETMASK(&UnBlockSig);
230+
sigprocmask(SIG_SETMASK,&UnBlockSig,NULL);
231231

232232
/* We shouldn't be launched unnecessarily. */
233233
Assert(XLogArchivingActive());

‎src/backend/postmaster/postmaster.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,7 @@ PostmasterMain(int argc, char *argv[])
639639
* postmaster/bgworker.c and postmaster/checkpointer.c.
640640
*/
641641
pqinitmask();
642-
PG_SETMASK(&BlockSig);
642+
sigprocmask(SIG_SETMASK,&BlockSig,NULL);
643643

644644
pqsignal(SIGHUP,handle_pm_reload_request_signal);
645645
pqsignal(SIGINT,handle_pm_shutdown_request_signal);
@@ -675,7 +675,7 @@ PostmasterMain(int argc, char *argv[])
675675
#endif
676676

677677
/* Begin accepting signals. */
678-
PG_SETMASK(&UnBlockSig);
678+
sigprocmask(SIG_SETMASK,&UnBlockSig,NULL);
679679

680680
/*
681681
* Options setup
@@ -4321,7 +4321,7 @@ BackendInitialize(Port *port)
43214321
pqsignal(SIGTERM,process_startup_packet_die);
43224322
/* SIGQUIT handler was already set up by InitPostmasterChild */
43234323
InitializeTimeouts();/* establishes SIGALRM handler */
4324-
PG_SETMASK(&StartupBlockSig);
4324+
sigprocmask(SIG_SETMASK,&StartupBlockSig,NULL);
43254325

43264326
/*
43274327
* Get the remote host name and port for logging and status display.
@@ -4402,7 +4402,7 @@ BackendInitialize(Port *port)
44024402
* Disable the timeout, and prevent SIGTERM again.
44034403
*/
44044404
disable_timeout(STARTUP_PACKET_TIMEOUT, false);
4405-
PG_SETMASK(&BlockSig);
4405+
sigprocmask(SIG_SETMASK,&BlockSig,NULL);
44064406

44074407
/*
44084408
* As a safety check that nothing in startup has yet performed
@@ -5661,13 +5661,13 @@ BackgroundWorkerInitializeConnectionByOid(Oid dboid, Oid useroid, uint32 flags)
56615661
void
56625662
BackgroundWorkerBlockSignals(void)
56635663
{
5664-
PG_SETMASK(&BlockSig);
5664+
sigprocmask(SIG_SETMASK,&BlockSig,NULL);
56655665
}
56665666

56675667
void
56685668
BackgroundWorkerUnblockSignals(void)
56695669
{
5670-
PG_SETMASK(&UnBlockSig);
5670+
sigprocmask(SIG_SETMASK,&UnBlockSig,NULL);
56715671
}
56725672

56735673
#ifdefEXEC_BACKEND

‎src/backend/postmaster/startup.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ StartupProcessMain(void)
259259
/*
260260
* Unblock signals (they were blocked when the postmaster forked us)
261261
*/
262-
PG_SETMASK(&UnBlockSig);
262+
sigprocmask(SIG_SETMASK,&UnBlockSig,NULL);
263263

264264
/*
265265
* Do what we came for.

‎src/backend/postmaster/syslogger.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ SysLoggerMain(int argc, char *argv[])
263263
*/
264264
pqsignal(SIGCHLD,SIG_DFL);
265265

266-
PG_SETMASK(&UnBlockSig);
266+
sigprocmask(SIG_SETMASK,&UnBlockSig,NULL);
267267

268268
#ifdefWIN32
269269
/* Fire up separate data transfer thread */

‎src/backend/postmaster/walwriter.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ WalWriterMain(void)
205205
/*
206206
* Unblock signals (they were blocked when the postmaster forked us)
207207
*/
208-
PG_SETMASK(&UnBlockSig);
208+
sigprocmask(SIG_SETMASK,&UnBlockSig,NULL);
209209

210210
/*
211211
* Reset hibernation state after any error.

‎src/backend/replication/walreceiver.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ WalReceiverMain(void)
293293
elog(ERROR,"libpqwalreceiver didn't initialize correctly");
294294

295295
/* Unblock signals (they were blocked when the postmaster forked us) */
296-
PG_SETMASK(&UnBlockSig);
296+
sigprocmask(SIG_SETMASK,&UnBlockSig,NULL);
297297

298298
/* Establish the connection to the primary for XLOG streaming */
299299
wrconn=walrcv_connect(conninfo, false,

‎src/backend/tcop/postgres.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2831,7 +2831,7 @@ void
28312831
quickdie(SIGNAL_ARGS)
28322832
{
28332833
sigaddset(&BlockSig,SIGQUIT);/* prevent nested calls */
2834-
PG_SETMASK(&BlockSig);
2834+
sigprocmask(SIG_SETMASK,&BlockSig,NULL);
28352835

28362836
/*
28372837
* Prevent interrupts while exiting; though we just blocked signals that
@@ -4129,7 +4129,7 @@ PostgresMain(const char *dbname, const char *username)
41294129
BaseInit();
41304130

41314131
/* We need to allow SIGINT, etc during the initial transaction */
4132-
PG_SETMASK(&UnBlockSig);
4132+
sigprocmask(SIG_SETMASK,&UnBlockSig,NULL);
41334133

41344134
/*
41354135
* General initialization.

‎src/backend/utils/init/miscinit.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ InitPostmasterChild(void)
159159
pqsignal(SIGQUIT,SignalHandlerForCrashExit);
160160

161161
sigdelset(&BlockSig,SIGQUIT);
162-
PG_SETMASK(&BlockSig);
162+
sigprocmask(SIG_SETMASK,&BlockSig,NULL);
163163

164164
/* Request a signal if the postmaster dies, if possible. */
165165
PostmasterDeathSignalInit();
@@ -196,7 +196,7 @@ InitStandaloneProcess(const char *argv0)
196196
* But we don't unblock SIGQUIT or provide a default handler for it.
197197
*/
198198
pqinitmask();
199-
PG_SETMASK(&BlockSig);
199+
sigprocmask(SIG_SETMASK,&BlockSig,NULL);
200200

201201
/* Compute paths, no postmaster to inherit from */
202202
if (my_exec_path[0]=='\0')

‎src/include/libpq/pqsignal.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515

1616
#include<signal.h>
1717

18-
#definePG_SETMASK(mask)sigprocmask(SIG_SETMASK, mask, NULL)
19-
2018
#ifdefWIN32
2119
/* Emulate POSIX sigset_t APIs on Windows */
2220
typedefintsigset_t;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp