mirror of
https://github.com/postgres/postgres.git
synced 2025-11-19 13:42:17 +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:
@@ -324,10 +324,10 @@ CheckpointerMain(char *startup_data, size_t startup_data_len)
|
||||
UpdateSharedMemoryConfig();
|
||||
|
||||
/*
|
||||
* Advertise our latch that backends can use to wake us up while we're
|
||||
* sleeping.
|
||||
* Advertise our proc number that backends can use to wake us up while
|
||||
* we're sleeping.
|
||||
*/
|
||||
ProcGlobal->checkpointerLatch = &MyProc->procLatch;
|
||||
ProcGlobal->checkpointerProc = MyProcNumber;
|
||||
|
||||
/*
|
||||
* Loop forever
|
||||
@@ -1139,8 +1139,14 @@ ForwardSyncRequest(const FileTag *ftag, SyncRequestType type)
|
||||
LWLockRelease(CheckpointerCommLock);
|
||||
|
||||
/* ... but not till after we release the lock */
|
||||
if (too_full && ProcGlobal->checkpointerLatch)
|
||||
SetLatch(ProcGlobal->checkpointerLatch);
|
||||
if (too_full)
|
||||
{
|
||||
volatile PROC_HDR *procglobal = ProcGlobal;
|
||||
ProcNumber checkpointerProc = procglobal->checkpointerProc;
|
||||
|
||||
if (checkpointerProc != INVALID_PROC_NUMBER)
|
||||
SetLatch(&GetPGProcByNumber(checkpointerProc)->procLatch);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -208,10 +208,10 @@ WalWriterMain(char *startup_data, size_t startup_data_len)
|
||||
SetWalWriterSleeping(false);
|
||||
|
||||
/*
|
||||
* Advertise our latch that backends can use to wake us up while we're
|
||||
* sleeping.
|
||||
* Advertise our proc number that backends can use to wake us up while
|
||||
* we're sleeping.
|
||||
*/
|
||||
ProcGlobal->walwriterLatch = &MyProc->procLatch;
|
||||
ProcGlobal->walwriterProc = MyProcNumber;
|
||||
|
||||
/*
|
||||
* Loop forever
|
||||
|
||||
Reference in New Issue
Block a user