Skip to content

Commit 1eab7a5

Browse files
committed
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.
1 parent 4e97631 commit 1eab7a5

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/backend/replication/walsender.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
* Portions Copyright (c) 2010-2010, PostgreSQL Global Development Group
2929
*
3030
* IDENTIFICATION
31-
* $PostgreSQL: pgsql/src/backend/replication/walsender.c,v 1.31 2010/09/14 13:35:14 heikki Exp $
31+
* $PostgreSQL: pgsql/src/backend/replication/walsender.c,v 1.32 2010/09/15 06:51:19 heikki Exp $
3232
*
3333
*-------------------------------------------------------------------------
3434
*/
@@ -511,15 +511,15 @@ InitWalSnd(void)
511511
else
512512
{
513513
/*
514-
* Found a free slot. Take ownership of the latch and initialize
515-
* the other fields.
514+
* Found a free slot. Reserve it for us.
516515
*/
517-
OwnLatch((Latch *) &walsnd->latch);
518516
walsnd->pid = MyProcPid;
519517
MemSet(&walsnd->sentPtr, 0, sizeof(XLogRecPtr));
520-
/* Set MyWalSnd only after it's fully initialized. */
521-
MyWalSnd = (WalSnd *) walsnd;
522518
SpinLockRelease(&walsnd->mutex);
519+
/* don't need the lock anymore */
520+
OwnLatch((Latch *) &walsnd->latch);
521+
MyWalSnd = (WalSnd *) walsnd;
522+
523523
break;
524524
}
525525
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy