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

Commit4971c36

Browse files
committed
Don't let protected variable access to be reordered after spinlock release.
LWLockAcquireWithVar needs to set the protected variable while holdingthe spinlock. Need to use a volatile pointer to make sure it doesn't getreordered by the compiler. The other functions that accessed the protectedvariable already got this right.9.4 only. Earlier releases didn't have this code, and in master, spinlockrelease acts as a compiler barrier.
1 parent4dbc760 commit4971c36

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

‎src/backend/storage/lmgr/lwlock.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,7 @@ static inline bool
482482
LWLockAcquireCommon(LWLock*l,LWLockModemode,uint64*valptr,uint64val)
483483
{
484484
volatileLWLock*lock=l;
485+
volatileuint64*valp=valptr;
485486
PGPROC*proc=MyProc;
486487
boolretry= false;
487488
boolresult= true;
@@ -637,8 +638,8 @@ LWLockAcquireCommon(LWLock *l, LWLockMode mode, uint64 *valptr, uint64 val)
637638
}
638639

639640
/* If there's a variable associated with this lock, initialize it */
640-
if (valptr)
641-
*valptr=val;
641+
if (valp)
642+
*valp=val;
642643

643644
/* We are done updating shared state of the lock itself. */
644645
SpinLockRelease(&lock->mutex);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp