diff options
Diffstat (limited to 'src/backend/storage')
-rw-r--r-- | src/backend/storage/ipc/procsignal.c | 11 | ||||
-rw-r--r-- | src/backend/storage/ipc/shm_mq.c | 76 |
2 files changed, 32 insertions, 55 deletions
diff --git a/src/backend/storage/ipc/procsignal.c b/src/backend/storage/ipc/procsignal.c index 0abde43565b..acfb4e9be82 100644 --- a/src/backend/storage/ipc/procsignal.c +++ b/src/backend/storage/ipc/procsignal.c @@ -59,14 +59,6 @@ typedef struct */ #define NumProcSignalSlots (MaxBackends + NUM_AUXPROCTYPES) -/* - * If this flag is set, the process latch will be set whenever SIGUSR1 - * is received. This is useful when waiting for a signal from the postmaster. - * Spurious wakeups must be expected. Make sure that the flag is cleared - * in the error path. - */ -bool set_latch_on_sigusr1; - static ProcSignalSlot *ProcSignalSlots = NULL; static volatile ProcSignalSlot *MyProcSignalSlot = NULL; @@ -296,8 +288,7 @@ procsignal_sigusr1_handler(SIGNAL_ARGS) if (CheckProcSignal(PROCSIG_RECOVERY_CONFLICT_BUFFERPIN)) RecoveryConflictInterrupt(PROCSIG_RECOVERY_CONFLICT_BUFFERPIN); - if (set_latch_on_sigusr1) - SetLatch(MyLatch); + SetLatch(MyLatch); latch_sigusr1_handler(); diff --git a/src/backend/storage/ipc/shm_mq.c b/src/backend/storage/ipc/shm_mq.c index c78f1650e6a..80956ce4304 100644 --- a/src/backend/storage/ipc/shm_mq.c +++ b/src/backend/storage/ipc/shm_mq.c @@ -962,63 +962,49 @@ static bool shm_mq_wait_internal(volatile shm_mq *mq, PGPROC *volatile * ptr, BackgroundWorkerHandle *handle) { - bool save_set_latch_on_sigusr1; bool result = false; - save_set_latch_on_sigusr1 = set_latch_on_sigusr1; - if (handle != NULL) - set_latch_on_sigusr1 = true; - - PG_TRY(); + for (;;) { - for (;;) + BgwHandleStatus status; + pid_t pid; + bool detached; + + /* Acquire the lock just long enough to check the pointer. */ + SpinLockAcquire(&mq->mq_mutex); + detached = mq->mq_detached; + result = (*ptr != NULL); + SpinLockRelease(&mq->mq_mutex); + + /* Fail if detached; else succeed if initialized. */ + if (detached) + { + result = false; + break; + } + if (result) + break; + + if (handle != NULL) { - BgwHandleStatus status; - pid_t pid; - bool detached; - - /* Acquire the lock just long enough to check the pointer. */ - SpinLockAcquire(&mq->mq_mutex); - detached = mq->mq_detached; - result = (*ptr != NULL); - SpinLockRelease(&mq->mq_mutex); - - /* Fail if detached; else succeed if initialized. */ - if (detached) + /* Check for unexpected worker death. */ + status = GetBackgroundWorkerPid(handle, &pid); + if (status != BGWH_STARTED && status != BGWH_NOT_YET_STARTED) { result = false; break; } - if (result) - break; - - if (handle != NULL) - { - /* Check for unexpected worker death. */ - status = GetBackgroundWorkerPid(handle, &pid); - if (status != BGWH_STARTED && status != BGWH_NOT_YET_STARTED) - { - result = false; - break; - } - } + } - /* Wait to be signalled. */ - WaitLatch(MyLatch, WL_LATCH_SET, 0); + /* Wait to be signalled. */ + WaitLatch(MyLatch, WL_LATCH_SET, 0); - /* An interrupt may have occurred while we were waiting. */ - CHECK_FOR_INTERRUPTS(); + /* An interrupt may have occurred while we were waiting. */ + CHECK_FOR_INTERRUPTS(); - /* Reset the latch so we don't spin. */ - ResetLatch(MyLatch); - } - } - PG_CATCH(); - { - set_latch_on_sigusr1 = save_set_latch_on_sigusr1; - PG_RE_THROW(); + /* Reset the latch so we don't spin. */ + ResetLatch(MyLatch); } - PG_END_TRY(); return result; } |