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

Commit2a2352e

Browse files
committed
Replace memcpy() calls in xlog.c critical sections with struct assignments.
This gets rid of a dangerous-looking use of the not-volatile XLogCtlpointer in a couple of spinlock-protected sections, where the normalcoding rule is that you should only access shared memory through apointer-to-volatile. I think the risk is only hypothetical not actual,since for there to be a bug the compiler would have to move the spinlockacquire or release across the memcpy() call, which one sincerely hopesit will not. Still, it looks cleaner this way.Per comment from Daniel Farina and subsequent discussion.
1 parent6259678 commit2a2352e

File tree

1 file changed

+3
-3
lines changed
  • src/backend/access/transam

1 file changed

+3
-3
lines changed

‎src/backend/access/transam/xlog.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8158,8 +8158,8 @@ RecoveryRestartPoint(const CheckPoint *checkPoint)
81588158
* work out the next time it wants to perform a restartpoint.
81598159
*/
81608160
SpinLockAcquire(&xlogctl->info_lck);
8161-
XLogCtl->lastCheckPointRecPtr=ReadRecPtr;
8162-
memcpy(&XLogCtl->lastCheckPoint,checkPoint,sizeof(CheckPoint));
8161+
xlogctl->lastCheckPointRecPtr=ReadRecPtr;
8162+
xlogctl->lastCheckPoint=*checkPoint;
81638163
SpinLockRelease(&xlogctl->info_lck);
81648164
}
81658165

@@ -8194,7 +8194,7 @@ CreateRestartPoint(int flags)
81948194
/* Get a local copy of the last safe checkpoint record. */
81958195
SpinLockAcquire(&xlogctl->info_lck);
81968196
lastCheckPointRecPtr=xlogctl->lastCheckPointRecPtr;
8197-
memcpy(&lastCheckPoint,&XLogCtl->lastCheckPoint,sizeof(CheckPoint));
8197+
lastCheckPoint=xlogctl->lastCheckPoint;
81988198
SpinLockRelease(&xlogctl->info_lck);
81998199

82008200
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp