mirror of
https://github.com/postgres/postgres.git
synced 2025-11-10 17:42:29 +03:00
Use ProcNumbers instead of direct Latch pointers to address other procs
This is in preparation for replacing Latches with a new abstraction. That's still work in progress, but this seems a little tidier anyway, so let's get this refactoring out of the way already. Discussion: https://www.postgresql.org/message-id/391abe21-413e-4d91-a650-b663af49500c%40iki.fi
This commit is contained in:
@@ -266,8 +266,8 @@ WalReceiverMain(char *startup_data, size_t startup_data_len)
|
||||
walrcv->lastMsgSendTime =
|
||||
walrcv->lastMsgReceiptTime = walrcv->latestWalEndTime = now;
|
||||
|
||||
/* Report the latch to use to awaken this process */
|
||||
walrcv->latch = &MyProc->procLatch;
|
||||
/* Report our proc number so that others can wake us up */
|
||||
walrcv->procno = MyProcNumber;
|
||||
|
||||
SpinLockRelease(&walrcv->mutex);
|
||||
|
||||
@@ -819,8 +819,8 @@ WalRcvDie(int code, Datum arg)
|
||||
Assert(walrcv->pid == MyProcPid);
|
||||
walrcv->walRcvState = WALRCV_STOPPED;
|
||||
walrcv->pid = 0;
|
||||
walrcv->procno = INVALID_PROC_NUMBER;
|
||||
walrcv->ready_to_display = false;
|
||||
walrcv->latch = NULL;
|
||||
SpinLockRelease(&walrcv->mutex);
|
||||
|
||||
ConditionVariableBroadcast(&walrcv->walRcvStoppedCV);
|
||||
@@ -1358,15 +1358,15 @@ WalRcvComputeNextWakeup(WalRcvWakeupReason reason, TimestampTz now)
|
||||
void
|
||||
WalRcvForceReply(void)
|
||||
{
|
||||
Latch *latch;
|
||||
ProcNumber procno;
|
||||
|
||||
WalRcv->force_reply = true;
|
||||
/* fetching the latch pointer might not be atomic, so use spinlock */
|
||||
/* fetching the proc number is probably atomic, but don't rely on it */
|
||||
SpinLockAcquire(&WalRcv->mutex);
|
||||
latch = WalRcv->latch;
|
||||
procno = WalRcv->procno;
|
||||
SpinLockRelease(&WalRcv->mutex);
|
||||
if (latch)
|
||||
SetLatch(latch);
|
||||
if (procno != INVALID_PROC_NUMBER)
|
||||
SetLatch(&GetPGProcByNumber(procno)->procLatch);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user