aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>2010-09-15 06:51:19 +0000
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>2010-09-15 06:51:19 +0000
commit1eab7a560d09fcd7314acd46ded955a37a262683 (patch)
tree5026c58e24c63c08bf96c677589c8503e37361b3 /src
parent4e97631e6a9d31acfde1057ad966e73f9d28c28d (diff)
downloadpostgresql-1eab7a560d09fcd7314acd46ded955a37a262683.tar.gz
postgresql-1eab7a560d09fcd7314acd46ded955a37a262683.zip
Don't call OwnLatch while holding a spinlock. OwnLatch can elog() under
some "can't happen" scenarios, and spinlocks should only be held for a few instructions anyway. As pointed out by Fujii Masao.
Diffstat (limited to 'src')
-rw-r--r--src/backend/replication/walsender.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c
index c477e7c9872..9be53eec603 100644
--- a/src/backend/replication/walsender.c
+++ b/src/backend/replication/walsender.c
@@ -28,7 +28,7 @@
* Portions Copyright (c) 2010-2010, PostgreSQL Global Development Group
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/replication/walsender.c,v 1.31 2010/09/14 13:35:14 heikki Exp $
+ * $PostgreSQL: pgsql/src/backend/replication/walsender.c,v 1.32 2010/09/15 06:51:19 heikki Exp $
*
*-------------------------------------------------------------------------
*/
@@ -511,15 +511,15 @@ InitWalSnd(void)
else
{
/*
- * Found a free slot. Take ownership of the latch and initialize
- * the other fields.
+ * Found a free slot. Reserve it for us.
*/
- OwnLatch((Latch *) &walsnd->latch);
walsnd->pid = MyProcPid;
MemSet(&walsnd->sentPtr, 0, sizeof(XLogRecPtr));
- /* Set MyWalSnd only after it's fully initialized. */
- MyWalSnd = (WalSnd *) walsnd;
SpinLockRelease(&walsnd->mutex);
+ /* don't need the lock anymore */
+ OwnLatch((Latch *) &walsnd->latch);
+ MyWalSnd = (WalSnd *) walsnd;
+
break;
}
}