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

Commit214c7a4

Browse files
committed
Fix some more bugs in signal handlers and process shutdown logic.
WalSndKill was doing things exactly backwards: it should first clearMyWalSnd (to stop signal handlers from touching MyWalSnd->latch),then disown the latch, and only then mark the WalSnd struct unused byclearing its pid field.Also, WalRcvSigUsr1Handler and worker_spi_sighup failed to preserveerrno, which is surely a requirement for any signal handler.Per discussion of recent buildfarm failures. Back-patch as faras the relevant code exists.
1 parent7e1531a commit214c7a4

File tree

3 files changed

+22
-7
lines changed

3 files changed

+22
-7
lines changed

‎contrib/worker_spi/worker_spi.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
#include"tcop/utility.h"
4343

4444
PG_MODULE_MAGIC;
45+
4546
PG_FUNCTION_INFO_V1(worker_spi_launch);
4647

4748
void_PG_init(void);
@@ -82,15 +83,19 @@ worker_spi_sigterm(SIGNAL_ARGS)
8283

8384
/*
8485
* Signal handler for SIGHUP
85-
*Set a flag tolet the main loop to reread the config file, and set
86+
*Set a flag totell the main loop to reread the config file, and set
8687
*our latch to wake it up.
8788
*/
8889
staticvoid
8990
worker_spi_sighup(SIGNAL_ARGS)
9091
{
92+
intsave_errno=errno;
93+
9194
got_sighup= true;
9295
if (MyProc)
9396
SetLatch(&MyProc->procLatch);
97+
98+
errno=save_errno;
9499
}
95100

96101
/*

‎src/backend/replication/walreceiver.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,11 @@ WalRcvSigHupHandler(SIGNAL_ARGS)
740740
staticvoid
741741
WalRcvSigUsr1Handler(SIGNAL_ARGS)
742742
{
743+
intsave_errno=errno;
744+
743745
latch_sigusr1_handler();
746+
747+
errno=save_errno;
744748
}
745749

746750
/* SIGTERM: set flag for main loop, or shutdown immediately if safe */

‎src/backend/replication/walsender.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1401,17 +1401,23 @@ InitWalSenderSlot(void)
14011401
staticvoid
14021402
WalSndKill(intcode,Datumarg)
14031403
{
1404-
Assert(MyWalSnd!=NULL);
1404+
WalSnd*walsnd=MyWalSnd;
1405+
1406+
Assert(walsnd!=NULL);
1407+
1408+
/*
1409+
* Clear MyWalSnd first; then disown the latch. This is so that signal
1410+
* handlers won't try to touch the latch after it's no longer ours.
1411+
*/
1412+
MyWalSnd=NULL;
1413+
1414+
DisownLatch(&walsnd->latch);
14051415

14061416
/*
14071417
* Mark WalSnd struct no longer in use. Assume that no lock is required
14081418
* for this.
14091419
*/
1410-
MyWalSnd->pid=0;
1411-
DisownLatch(&MyWalSnd->latch);
1412-
1413-
/* WalSnd struct isn't mine anymore */
1414-
MyWalSnd=NULL;
1420+
walsnd->pid=0;
14151421
}
14161422

14171423
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp