Commit 1eab7a56 authored by Heikki Linnakangas's avatar Heikki Linnakangas

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.
parent 4e97631e
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
* Portions Copyright (c) 2010-2010, PostgreSQL Global Development Group * Portions Copyright (c) 2010-2010, PostgreSQL Global Development Group
* *
* IDENTIFICATION * 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) ...@@ -511,15 +511,15 @@ InitWalSnd(void)
else else
{ {
/* /*
* Found a free slot. Take ownership of the latch and initialize * Found a free slot. Reserve it for us.
* the other fields.
*/ */
OwnLatch((Latch *) &walsnd->latch);
walsnd->pid = MyProcPid; walsnd->pid = MyProcPid;
MemSet(&walsnd->sentPtr, 0, sizeof(XLogRecPtr)); MemSet(&walsnd->sentPtr, 0, sizeof(XLogRecPtr));
/* Set MyWalSnd only after it's fully initialized. */
MyWalSnd = (WalSnd *) walsnd;
SpinLockRelease(&walsnd->mutex); SpinLockRelease(&walsnd->mutex);
/* don't need the lock anymore */
OwnLatch((Latch *) &walsnd->latch);
MyWalSnd = (WalSnd *) walsnd;
break; break;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment