diff options
Diffstat (limited to 'src/backend/postmaster/bgworker.c')
-rw-r--r-- | src/backend/postmaster/bgworker.c | 82 |
1 files changed, 27 insertions, 55 deletions
diff --git a/src/backend/postmaster/bgworker.c b/src/backend/postmaster/bgworker.c index 68c9505809e..c38d486a20e 100644 --- a/src/backend/postmaster/bgworker.c +++ b/src/backend/postmaster/bgworker.c @@ -954,45 +954,31 @@ WaitForBackgroundWorkerStartup(BackgroundWorkerHandle *handle, pid_t *pidp) { BgwHandleStatus status; int rc; - bool save_set_latch_on_sigusr1; - save_set_latch_on_sigusr1 = set_latch_on_sigusr1; - set_latch_on_sigusr1 = true; - - PG_TRY(); + for (;;) { - for (;;) - { - pid_t pid; + pid_t pid; - CHECK_FOR_INTERRUPTS(); + CHECK_FOR_INTERRUPTS(); - status = GetBackgroundWorkerPid(handle, &pid); - if (status == BGWH_STARTED) - *pidp = pid; - if (status != BGWH_NOT_YET_STARTED) - break; - - rc = WaitLatch(MyLatch, - WL_LATCH_SET | WL_POSTMASTER_DEATH, 0); + status = GetBackgroundWorkerPid(handle, &pid); + if (status == BGWH_STARTED) + *pidp = pid; + if (status != BGWH_NOT_YET_STARTED) + break; - if (rc & WL_POSTMASTER_DEATH) - { - status = BGWH_POSTMASTER_DIED; - break; - } + rc = WaitLatch(MyLatch, + WL_LATCH_SET | WL_POSTMASTER_DEATH, 0); - ResetLatch(MyLatch); + if (rc & WL_POSTMASTER_DEATH) + { + status = BGWH_POSTMASTER_DIED; + break; } + + ResetLatch(MyLatch); } - PG_CATCH(); - { - set_latch_on_sigusr1 = save_set_latch_on_sigusr1; - PG_RE_THROW(); - } - PG_END_TRY(); - set_latch_on_sigusr1 = save_set_latch_on_sigusr1; return status; } @@ -1009,40 +995,26 @@ WaitForBackgroundWorkerShutdown(BackgroundWorkerHandle *handle) { BgwHandleStatus status; int rc; - bool save_set_latch_on_sigusr1; - - save_set_latch_on_sigusr1 = set_latch_on_sigusr1; - set_latch_on_sigusr1 = true; - PG_TRY(); + for (;;) { - for (;;) - { - pid_t pid; + pid_t pid; - CHECK_FOR_INTERRUPTS(); + CHECK_FOR_INTERRUPTS(); - status = GetBackgroundWorkerPid(handle, &pid); - if (status == BGWH_STOPPED) - return status; + status = GetBackgroundWorkerPid(handle, &pid); + if (status == BGWH_STOPPED) + return status; - rc = WaitLatch(&MyProc->procLatch, - WL_LATCH_SET | WL_POSTMASTER_DEATH, 0); + rc = WaitLatch(&MyProc->procLatch, + WL_LATCH_SET | WL_POSTMASTER_DEATH, 0); - if (rc & WL_POSTMASTER_DEATH) - return BGWH_POSTMASTER_DIED; + if (rc & WL_POSTMASTER_DEATH) + return BGWH_POSTMASTER_DIED; - ResetLatch(&MyProc->procLatch); - } - } - PG_CATCH(); - { - set_latch_on_sigusr1 = save_set_latch_on_sigusr1; - PG_RE_THROW(); + ResetLatch(&MyProc->procLatch); } - PG_END_TRY(); - set_latch_on_sigusr1 = save_set_latch_on_sigusr1; return status; } |