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

Appearance settings

Commit 0ecb4ea

Browse filesBrowse files
committed
Volatile-qualify the ProcArray PGPROC pointer in a bunch of routines
that examine fields that could change under them. This is just to make really sure that when we are fetching a value 'only once', that's what actually happens. Possibly this is a bug that should be back-patched, but in the absence of solid evidence that it's needed, I won't bother.
1 parent 4bf2dfb commit 0ecb4ea
Copy full SHA for 0ecb4ea

File tree

Expand file treeCollapse file tree

1 file changed

+14
-14
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+14
-14
lines changed

‎src/backend/storage/ipc/procarray.c

Copy file name to clipboardExpand all lines: src/backend/storage/ipc/procarray.c
+14-14Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
*
2424
*
2525
* IDENTIFICATION
26-
* $PostgreSQL: pgsql/src/backend/storage/ipc/procarray.c,v 1.29 2007/09/05 18:10:47 tgl Exp $
26+
* $PostgreSQL: pgsql/src/backend/storage/ipc/procarray.c,v 1.30 2007/09/05 21:11:19 tgl Exp $
2727
*
2828
*-------------------------------------------------------------------------
2929
*/
@@ -233,7 +233,7 @@ TransactionIdIsInProgress(TransactionId xid)
233233

234234
for (i = 0; i < arrayP->numProcs; i++)
235235
{
236-
PGPROC *proc = arrayP->procs[i];
236+
volatile PGPROC *proc = arrayP->procs[i];
237237

238238
/* Fetch xid just once - see GetNewTransactionId */
239239
TransactionId pxid = proc->xid;
@@ -361,7 +361,7 @@ TransactionIdIsActive(TransactionId xid)
361361

362362
for (i = 0; i < arrayP->numProcs; i++)
363363
{
364-
PGPROC *proc = arrayP->procs[i];
364+
volatile PGPROC *proc = arrayP->procs[i];
365365

366366
/* Fetch xid just once - see GetNewTransactionId */
367367
TransactionId pxid = proc->xid;
@@ -434,7 +434,7 @@ GetOldestXmin(bool allDbs, bool ignoreVacuum)
434434

435435
for (index = 0; index < arrayP->numProcs; index++)
436436
{
437-
PGPROC *proc = arrayP->procs[index];
437+
volatile PGPROC *proc = arrayP->procs[index];
438438

439439
if (ignoreVacuum && proc->inVacuum)
440440
continue;
@@ -613,7 +613,7 @@ GetSnapshotData(Snapshot snapshot, bool serializable)
613613
*/
614614
for (index = 0; index < arrayP->numProcs; index++)
615615
{
616-
PGPROC *proc = arrayP->procs[index];
616+
volatile PGPROC *proc = arrayP->procs[index];
617617
TransactionId xid;
618618

619619
/* Ignore procs running LAZY VACUUM */
@@ -672,7 +672,7 @@ GetSnapshotData(Snapshot snapshot, bool serializable)
672672
if (nxids > 0)
673673
{
674674
memcpy(snapshot->subxip + subcount,
675-
proc->subxids.xids,
675+
(void *) proc->subxids.xids,
676676
nxids * sizeof(TransactionId));
677677
subcount += nxids;
678678
}
@@ -739,7 +739,7 @@ GetTransactionsInCommit(TransactionId **xids_p)
739739

740740
for (index = 0; index < arrayP->numProcs; index++)
741741
{
742-
PGPROC *proc = arrayP->procs[index];
742+
volatile PGPROC *proc = arrayP->procs[index];
743743
/* Fetch xid just once - see GetNewTransactionId */
744744
TransactionId pxid = proc->xid;
745745

@@ -773,7 +773,7 @@ HaveTransactionsInCommit(TransactionId *xids, int nxids)
773773

774774
for (index = 0; index < arrayP->numProcs; index++)
775775
{
776-
PGPROC *proc = arrayP->procs[index];
776+
volatile PGPROC *proc = arrayP->procs[index];
777777
/* Fetch xid just once - see GetNewTransactionId */
778778
TransactionId pxid = proc->xid;
779779

@@ -861,7 +861,7 @@ BackendXidGetPid(TransactionId xid)
861861

862862
for (index = 0; index < arrayP->numProcs; index++)
863863
{
864-
PGPROC *proc = arrayP->procs[index];
864+
volatile PGPROC *proc = arrayP->procs[index];
865865

866866
if (proc->xid == xid)
867867
{
@@ -909,7 +909,7 @@ GetCurrentVirtualXIDs(TransactionId limitXmin)
909909

910910
for (index = 0; index < arrayP->numProcs; index++)
911911
{
912-
PGPROC *proc = arrayP->procs[index];
912+
volatile PGPROC *proc = arrayP->procs[index];
913913
/* Fetch xmin just once - might change on us? */
914914
TransactionId pxmin = proc->xmin;
915915

@@ -963,7 +963,7 @@ CountActiveBackends(void)
963963
*/
964964
for (index = 0; index < arrayP->numProcs; index++)
965965
{
966-
PGPROC *proc = arrayP->procs[index];
966+
volatile PGPROC *proc = arrayP->procs[index];
967967

968968
if (proc == MyProc)
969969
continue; /* do not count myself */
@@ -993,7 +993,7 @@ CountDBBackends(Oid databaseid)
993993

994994
for (index = 0; index < arrayP->numProcs; index++)
995995
{
996-
PGPROC *proc = arrayP->procs[index];
996+
volatile PGPROC *proc = arrayP->procs[index];
997997

998998
if (proc->pid == 0)
999999
continue; /* do not count prepared xacts */
@@ -1020,7 +1020,7 @@ CountUserBackends(Oid roleid)
10201020

10211021
for (index = 0; index < arrayP->numProcs; index++)
10221022
{
1023-
PGPROC *proc = arrayP->procs[index];
1023+
volatile PGPROC *proc = arrayP->procs[index];
10241024

10251025
if (proc->pid == 0)
10261026
continue; /* do not count prepared xacts */
@@ -1072,7 +1072,7 @@ CheckOtherDBBackends(Oid databaseId)
10721072

10731073
for (index = 0; index < arrayP->numProcs; index++)
10741074
{
1075-
PGPROC *proc = arrayP->procs[index];
1075+
volatile PGPROC *proc = arrayP->procs[index];
10761076

10771077
if (proc->databaseId != databaseId)
10781078
continue;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.