summaryrefslogtreecommitdiff
path: root/src/backend/replication/walreceiver.c
diff options
context:
space:
mode:
authorThomas Munro <tmunro@postgresql.org>2021-03-12 19:07:27 +1300
committerThomas Munro <tmunro@postgresql.org>2021-03-12 19:45:42 +1300
commitde829ddf23f69190efb4e0178704c4c4228e17cd (patch)
treedaf6a6291626971ffa700db0b2b2d1e4b457eaab /src/backend/replication/walreceiver.c
parent600f2f50b7a57c8481276450c9019fa7b3656411 (diff)
Add condition variable for walreceiver shutdown.
Use this new CV to wait for walreceiver shutdown without a sleep/poll loop, while also benefiting from standard postmaster death handling. Discussion: https://postgr.es/m/CA%2BhUKGK1607VmtrDUHQXrsooU%3Dap4g4R2yaoByWOOA3m8xevUQ%40mail.gmail.com
Diffstat (limited to 'src/backend/replication/walreceiver.c')
-rw-r--r--src/backend/replication/walreceiver.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/backend/replication/walreceiver.c b/src/backend/replication/walreceiver.c
index e5f8a06fea0..8532296f26c 100644
--- a/src/backend/replication/walreceiver.c
+++ b/src/backend/replication/walreceiver.c
@@ -207,6 +207,7 @@ WalReceiverMain(void)
case WALRCV_STOPPED:
SpinLockRelease(&walrcv->mutex);
+ ConditionVariableBroadcast(&walrcv->walRcvStoppedCV);
proc_exit(1);
break;
@@ -784,6 +785,8 @@ WalRcvDie(int code, Datum arg)
walrcv->latch = NULL;
SpinLockRelease(&walrcv->mutex);
+ ConditionVariableBroadcast(&walrcv->walRcvStoppedCV);
+
/* Terminate the connection gracefully. */
if (wrconn != NULL)
walrcv_disconnect(wrconn);