diff options
Diffstat (limited to 'src/backend/storage/ipc/procsignal.c')
-rw-r--r-- | src/backend/storage/ipc/procsignal.c | 37 |
1 files changed, 14 insertions, 23 deletions
diff --git a/src/backend/storage/ipc/procsignal.c b/src/backend/storage/ipc/procsignal.c index f41563a0a48..00d66902d8b 100644 --- a/src/backend/storage/ipc/procsignal.c +++ b/src/backend/storage/ipc/procsignal.c @@ -81,6 +81,13 @@ typedef struct ProcSignalSlot psh_slot[FLEXIBLE_ARRAY_MEMBER]; } ProcSignalHeader; +/* + * We reserve a slot for each possible BackendId, plus one for each + * possible auxiliary process type. (This scheme assumes there is not + * more than one of any auxiliary process type at a time.) + */ +#define NumProcSignalSlots (MaxBackends + NUM_AUXPROCTYPES) + /* Check whether the relevant type bit is set in the flags. */ #define BARRIER_SHOULD_CHECK(flags, type) \ (((flags) & (((uint32) 1) << (uint32) (type))) != 0) @@ -95,20 +102,6 @@ static ProcSignalSlot *MyProcSignalSlot = NULL; static bool CheckProcSignal(ProcSignalReason reason); static void CleanupProcSignalState(int status, Datum arg); static void ResetProcSignalBarrierBits(uint32 flags); -static inline int GetNumProcSignalSlots(void); - -/* - * GetNumProcSignalSlots - * - * We reserve a slot for each possible BackendId, plus one for each possible - * auxiliary process type. (This scheme assume there is not more than one of - * any auxiliary process type at a time.) - */ -static inline int -GetNumProcSignalSlots(void) -{ - return GetMaxBackends() + NUM_AUXPROCTYPES; -} /* * ProcSignalShmemSize @@ -119,7 +112,7 @@ ProcSignalShmemSize(void) { Size size; - size = mul_size(GetNumProcSignalSlots(), sizeof(ProcSignalSlot)); + size = mul_size(NumProcSignalSlots, sizeof(ProcSignalSlot)); size = add_size(size, offsetof(ProcSignalHeader, psh_slot)); return size; } @@ -133,7 +126,6 @@ ProcSignalShmemInit(void) { Size size = ProcSignalShmemSize(); bool found; - int numProcSignalSlots = GetNumProcSignalSlots(); ProcSignal = (ProcSignalHeader *) ShmemInitStruct("ProcSignal", size, &found); @@ -145,7 +137,7 @@ ProcSignalShmemInit(void) pg_atomic_init_u64(&ProcSignal->psh_barrierGeneration, 0); - for (i = 0; i < numProcSignalSlots; ++i) + for (i = 0; i < NumProcSignalSlots; ++i) { ProcSignalSlot *slot = &ProcSignal->psh_slot[i]; @@ -171,7 +163,7 @@ ProcSignalInit(int pss_idx) ProcSignalSlot *slot; uint64 barrier_generation; - Assert(pss_idx >= 1 && pss_idx <= GetNumProcSignalSlots()); + Assert(pss_idx >= 1 && pss_idx <= NumProcSignalSlots); slot = &ProcSignal->psh_slot[pss_idx - 1]; @@ -300,7 +292,7 @@ SendProcSignal(pid_t pid, ProcSignalReason reason, BackendId backendId) */ int i; - for (i = GetNumProcSignalSlots() - 1; i >= 0; i--) + for (i = NumProcSignalSlots - 1; i >= 0; i--) { slot = &ProcSignal->psh_slot[i]; @@ -341,7 +333,6 @@ EmitProcSignalBarrier(ProcSignalBarrierType type) { uint32 flagbit = 1 << (uint32) type; uint64 generation; - int numProcSignalSlots = GetNumProcSignalSlots(); /* * Set all the flags. @@ -351,7 +342,7 @@ EmitProcSignalBarrier(ProcSignalBarrierType type) * anything that we do afterwards. (This is also true of the later call to * pg_atomic_add_fetch_u64.) */ - for (int i = 0; i < numProcSignalSlots; i++) + for (int i = 0; i < NumProcSignalSlots; i++) { volatile ProcSignalSlot *slot = &ProcSignal->psh_slot[i]; @@ -377,7 +368,7 @@ EmitProcSignalBarrier(ProcSignalBarrierType type) * backends that need to update state - but they won't actually need to * change any state. */ - for (int i = numProcSignalSlots - 1; i >= 0; i--) + for (int i = NumProcSignalSlots - 1; i >= 0; i--) { volatile ProcSignalSlot *slot = &ProcSignal->psh_slot[i]; pid_t pid = slot->pss_pid; @@ -402,7 +393,7 @@ WaitForProcSignalBarrier(uint64 generation) { Assert(generation <= pg_atomic_read_u64(&ProcSignal->psh_barrierGeneration)); - for (int i = GetNumProcSignalSlots() - 1; i >= 0; i--) + for (int i = NumProcSignalSlots - 1; i >= 0; i--) { ProcSignalSlot *slot = &ProcSignal->psh_slot[i]; uint64 oldval; |