PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
bgworker.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  BackgroundWorker
 

Macros

#define BGWORKER_SHMEM_ACCESS   0x0001
 
#define BGWORKER_BACKEND_DATABASE_CONNECTION   0x0002
 
#define BGWORKER_CLASS_PARALLEL   0x0010
 
#define BGW_DEFAULT_RESTART_INTERVAL   60
 
#define BGW_NEVER_RESTART   -1
 
#define BGW_MAXLEN   64
 
#define BGW_EXTRALEN   128
 

Typedefs

typedef void(* bgworker_main_type )(Datum main_arg)
 
typedef struct BackgroundWorker BackgroundWorker
 
typedef enum BgwHandleStatus BgwHandleStatus
 
typedef struct
BackgroundWorkerHandle 
BackgroundWorkerHandle
 

Enumerations

enum  BgWorkerStartTime { BgWorkerStart_PostmasterStart, BgWorkerStart_ConsistentState, BgWorkerStart_RecoveryFinished }
 
enum  BgwHandleStatus { BGWH_STARTED, BGWH_NOT_YET_STARTED, BGWH_STOPPED, BGWH_POSTMASTER_DIED }
 

Functions

void RegisterBackgroundWorker (BackgroundWorker *worker)
 
bool RegisterDynamicBackgroundWorker (BackgroundWorker *worker, BackgroundWorkerHandle **handle)
 
BgwHandleStatus GetBackgroundWorkerPid (BackgroundWorkerHandle *handle, pid_t *pidp)
 
BgwHandleStatus WaitForBackgroundWorkerStartup (BackgroundWorkerHandle *handle, pid_t *pid)
 
BgwHandleStatus WaitForBackgroundWorkerShutdown (BackgroundWorkerHandle *)
 
void TerminateBackgroundWorker (BackgroundWorkerHandle *handle)
 
void BackgroundWorkerInitializeConnection (char *dbname, char *username)
 
void BackgroundWorkerInitializeConnectionByOid (Oid dboid, Oid useroid)
 
void BackgroundWorkerBlockSignals (void)
 
void BackgroundWorkerUnblockSignals (void)
 

Variables

PGDLLIMPORT BackgroundWorkerMyBgworkerEntry
 

Macro Definition Documentation

#define BGW_DEFAULT_RESTART_INTERVAL   60

Definition at line 83 of file bgworker.h.

#define BGW_EXTRALEN   128

Definition at line 86 of file bgworker.h.

Referenced by BackgroundWorkerStateChange(), and LaunchParallelWorkers().

#define BGWORKER_CLASS_PARALLEL   0x0010

Typedef Documentation

typedef void(* bgworker_main_type)(Datum main_arg)

Definition at line 71 of file bgworker.h.

Enumeration Type Documentation

Enumerator
BGWH_STARTED 
BGWH_NOT_YET_STARTED 
BGWH_STOPPED 
BGWH_POSTMASTER_DIED 

Definition at line 102 of file bgworker.h.

103 {
104  BGWH_STARTED, /* worker is running */
105  BGWH_NOT_YET_STARTED, /* worker hasn't been started yet */
106  BGWH_STOPPED, /* worker has exited */
107  BGWH_POSTMASTER_DIED /* postmaster died; worker status unclear */
BgwHandleStatus
Definition: bgworker.h:102
Enumerator
BgWorkerStart_PostmasterStart 
BgWorkerStart_ConsistentState 
BgWorkerStart_RecoveryFinished 

Definition at line 76 of file bgworker.h.

Function Documentation

void BackgroundWorkerBlockSignals ( void  )

Definition at line 5491 of file postmaster.c.

References BlockSig, and PG_SETMASK.

5492 {
5493  PG_SETMASK(&BlockSig);
5494 }
#define PG_SETMASK(mask)
Definition: pqsignal.h:19
sigset_t BlockSig
Definition: pqsignal.c:22
void BackgroundWorkerInitializeConnection ( char *  dbname,
char *  username 
)

Definition at line 5445 of file postmaster.c.

References BackgroundWorker::bgw_flags, BGWORKER_BACKEND_DATABASE_CONNECTION, ereport, errcode(), errmsg(), ERROR, FATAL, InitPostgres(), InvalidOid, IsInitProcessingMode, MyBgworkerEntry, NormalProcessing, NULL, and SetProcessingMode.

Referenced by ApplyLauncherMain().

5446 {
5448 
5449  /* XXX is this the right errcode? */
5451  ereport(FATAL,
5452  (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
5453  errmsg("database connection requirement not indicated during registration")));
5454 
5456 
5457  /* it had better not gotten out of "init" mode yet */
5458  if (!IsInitProcessingMode())
5459  ereport(ERROR,
5460  (errmsg("invalid processing mode in background worker")));
5462 }
int errcode(int sqlerrcode)
Definition: elog.c:575
#define SetProcessingMode(mode)
Definition: miscadmin.h:371
BackgroundWorker * MyBgworkerEntry
Definition: postmaster.c:189
#define ERROR
Definition: elog.h:43
#define FATAL
Definition: elog.h:52
#define ereport(elevel, rest)
Definition: elog.h:122
static char * username
Definition: initdb.c:129
#define InvalidOid
Definition: postgres_ext.h:36
#define NULL
Definition: c.h:226
#define BGWORKER_BACKEND_DATABASE_CONNECTION
Definition: bgworker.h:59
char * dbname
Definition: streamutil.c:38
void InitPostgres(const char *in_dbname, Oid dboid, const char *username, Oid useroid, char *out_dbname)
Definition: postinit.c:558
int errmsg(const char *fmt,...)
Definition: elog.c:797
#define IsInitProcessingMode()
Definition: miscadmin.h:366
void BackgroundWorkerInitializeConnectionByOid ( Oid  dboid,
Oid  useroid 
)

Definition at line 5468 of file postmaster.c.

References BackgroundWorker::bgw_flags, BGWORKER_BACKEND_DATABASE_CONNECTION, ereport, errcode(), errmsg(), ERROR, FATAL, InitPostgres(), IsInitProcessingMode, MyBgworkerEntry, NormalProcessing, NULL, and SetProcessingMode.

Referenced by ApplyWorkerMain(), and ParallelWorkerMain().

5469 {
5471 
5472  /* XXX is this the right errcode? */
5474  ereport(FATAL,
5475  (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
5476  errmsg("database connection requirement not indicated during registration")));
5477 
5478  InitPostgres(NULL, dboid, NULL, useroid, NULL);
5479 
5480  /* it had better not gotten out of "init" mode yet */
5481  if (!IsInitProcessingMode())
5482  ereport(ERROR,
5483  (errmsg("invalid processing mode in background worker")));
5485 }
int errcode(int sqlerrcode)
Definition: elog.c:575
#define SetProcessingMode(mode)
Definition: miscadmin.h:371
BackgroundWorker * MyBgworkerEntry
Definition: postmaster.c:189
#define ERROR
Definition: elog.h:43
#define FATAL
Definition: elog.h:52
#define ereport(elevel, rest)
Definition: elog.h:122
#define NULL
Definition: c.h:226
#define BGWORKER_BACKEND_DATABASE_CONNECTION
Definition: bgworker.h:59
void InitPostgres(const char *in_dbname, Oid dboid, const char *username, Oid useroid, char *out_dbname)
Definition: postinit.c:558
int errmsg(const char *fmt,...)
Definition: elog.c:797
#define IsInitProcessingMode()
Definition: miscadmin.h:366
void BackgroundWorkerUnblockSignals ( void  )

Definition at line 5497 of file postmaster.c.

References PG_SETMASK, and UnBlockSig.

Referenced by ApplyLauncherMain(), ApplyWorkerMain(), ParallelWorkerMain(), and test_shm_mq_main().

5498 {
5500 }
#define PG_SETMASK(mask)
Definition: pqsignal.h:19
sigset_t UnBlockSig
Definition: pqsignal.c:22
BgwHandleStatus GetBackgroundWorkerPid ( BackgroundWorkerHandle handle,
pid_t *  pidp 
)

Definition at line 969 of file bgworker.c.

References Assert, BGWH_NOT_YET_STARTED, BGWH_STARTED, BGWH_STOPPED, BackgroundWorkerSlot::generation, BackgroundWorkerHandle::generation, InvalidPid, LW_SHARED, LWLockAcquire(), LWLockRelease(), max_worker_processes, BackgroundWorkerSlot::pid, BackgroundWorkerArray::slot, and BackgroundWorkerHandle::slot.

Referenced by check_worker_status(), shm_mq_counterparty_gone(), shm_mq_wait_internal(), WaitForBackgroundWorkerShutdown(), WaitForBackgroundWorkerStartup(), and WaitForReplicationWorkerAttach().

970 {
971  BackgroundWorkerSlot *slot;
972  pid_t pid;
973 
974  Assert(handle->slot < max_worker_processes);
975  slot = &BackgroundWorkerData->slot[handle->slot];
976 
977  /*
978  * We could probably arrange to synchronize access to data using memory
979  * barriers only, but for now, let's just keep it simple and grab the
980  * lock. It seems unlikely that there will be enough traffic here to
981  * result in meaningful contention.
982  */
983  LWLockAcquire(BackgroundWorkerLock, LW_SHARED);
984 
985  /*
986  * The generation number can't be concurrently changed while we hold the
987  * lock. The pid, which is updated by the postmaster, can change at any
988  * time, but we assume such changes are atomic. So the value we read
989  * won't be garbage, but it might be out of date by the time the caller
990  * examines it (but that's unavoidable anyway).
991  */
992  if (handle->generation != slot->generation)
993  pid = 0;
994  else
995  pid = slot->pid;
996 
997  /* All done. */
998  LWLockRelease(BackgroundWorkerLock);
999 
1000  if (pid == 0)
1001  return BGWH_STOPPED;
1002  else if (pid == InvalidPid)
1003  return BGWH_NOT_YET_STARTED;
1004  *pidp = pid;
1005  return BGWH_STARTED;
1006 }
static BackgroundWorkerArray * BackgroundWorkerData
Definition: bgworker.c:109
void LWLockRelease(LWLock *lock)
Definition: lwlock.c:1714
#define Assert(condition)
Definition: c.h:671
bool LWLockAcquire(LWLock *lock, LWLockMode mode)
Definition: lwlock.c:1110
int max_worker_processes
Definition: globals.c:124
BackgroundWorkerSlot slot[FLEXIBLE_ARRAY_MEMBER]
Definition: bgworker.c:100
#define InvalidPid
Definition: miscadmin.h:31
void RegisterBackgroundWorker ( BackgroundWorker worker)

Definition at line 770 of file bgworker.c.

References BackgroundWorker::bgw_main, BackgroundWorker::bgw_name, BackgroundWorker::bgw_notify_pid, DEBUG1, ereport, errcode(), errdetail_plural(), errhint(), errmsg(), i, InternalBGWorkers, IsUnderPostmaster, LOG, malloc, max_worker_processes, NULL, process_shared_preload_libraries_in_progress, RegisteredBgWorker::rw_backend, RegisteredBgWorker::rw_child_slot, RegisteredBgWorker::rw_crashed_at, RegisteredBgWorker::rw_lnode, RegisteredBgWorker::rw_pid, RegisteredBgWorker::rw_terminate, RegisteredBgWorker::rw_worker, SanityCheckBackgroundWorker(), and slist_push_head().

Referenced by _PG_init(), and ApplyLauncherRegister().

771 {
772  RegisteredBgWorker *rw;
773  static int numworkers = 0;
774  bool internal = false;
775  int i;
776 
777  if (!IsUnderPostmaster)
778  ereport(DEBUG1,
779  (errmsg("registering background worker \"%s\"", worker->bgw_name)));
780 
781  for (i = 0; InternalBGWorkers[i]; i++)
782  {
783  if (worker->bgw_main == InternalBGWorkers[i])
784  {
785  internal = true;
786  break;
787  }
788  }
789 
791  {
792  if (!IsUnderPostmaster)
793  ereport(LOG,
794  (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
795  errmsg("background worker \"%s\": must be registered in shared_preload_libraries",
796  worker->bgw_name)));
797  return;
798  }
799 
800  if (!SanityCheckBackgroundWorker(worker, LOG))
801  return;
802 
803  if (worker->bgw_notify_pid != 0)
804  {
805  ereport(LOG,
806  (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
807  errmsg("background worker \"%s\": only dynamic background workers can request notification",
808  worker->bgw_name)));
809  return;
810  }
811 
812  /*
813  * Enforce maximum number of workers. Note this is overly restrictive: we
814  * could allow more non-shmem-connected workers, because these don't count
815  * towards the MAX_BACKENDS limit elsewhere. For now, it doesn't seem
816  * important to relax this restriction.
817  */
818  if (++numworkers > max_worker_processes)
819  {
820  ereport(LOG,
821  (errcode(ERRCODE_CONFIGURATION_LIMIT_EXCEEDED),
822  errmsg("too many background workers"),
823  errdetail_plural("Up to %d background worker can be registered with the current settings.",
824  "Up to %d background workers can be registered with the current settings.",
827  errhint("Consider increasing the configuration parameter \"max_worker_processes\".")));
828  return;
829  }
830 
831  /*
832  * Copy the registration data into the registered workers list.
833  */
834  rw = malloc(sizeof(RegisteredBgWorker));
835  if (rw == NULL)
836  {
837  ereport(LOG,
838  (errcode(ERRCODE_OUT_OF_MEMORY),
839  errmsg("out of memory")));
840  return;
841  }
842 
843  rw->rw_worker = *worker;
844  rw->rw_backend = NULL;
845  rw->rw_pid = 0;
846  rw->rw_child_slot = 0;
847  rw->rw_crashed_at = 0;
848  rw->rw_terminate = false;
849 
851 }
struct bkend * rw_backend
#define DEBUG1
Definition: elog.h:25
int errhint(const char *fmt,...)
Definition: elog.c:987
bool process_shared_preload_libraries_in_progress
Definition: miscinit.c:1400
static void slist_push_head(slist_head *head, slist_node *node)
Definition: ilist.h:574
int errcode(int sqlerrcode)
Definition: elog.c:575
#define LOG
Definition: elog.h:26
static const bgworker_main_type InternalBGWorkers[]
Definition: bgworker.c:115
#define malloc(a)
Definition: header.h:45
bgworker_main_type bgw_main
Definition: bgworker.h:94
slist_head BackgroundWorkerList
Definition: bgworker.c:41
bool IsUnderPostmaster
Definition: globals.c:100
#define ereport(elevel, rest)
Definition: elog.h:122
static bool SanityCheckBackgroundWorker(BackgroundWorker *worker, int elevel)
Definition: bgworker.c:507
#define NULL
Definition: c.h:226
char bgw_name[BGW_MAXLEN]
Definition: bgworker.h:90
int errdetail_plural(const char *fmt_singular, const char *fmt_plural, unsigned long n,...)
Definition: elog.c:965
int errmsg(const char *fmt,...)
Definition: elog.c:797
pid_t bgw_notify_pid
Definition: bgworker.h:99
int i
int max_worker_processes
Definition: globals.c:124
BackgroundWorker rw_worker
bool RegisterDynamicBackgroundWorker ( BackgroundWorker worker,
BackgroundWorkerHandle **  handle 
)

Definition at line 864 of file bgworker.c.

References BackgroundWorker::bgw_flags, BGWORKER_CLASS_PARALLEL, ERROR, BackgroundWorkerSlot::generation, BackgroundWorkerSlot::in_use, InvalidPid, IsUnderPostmaster, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), max_parallel_workers, palloc(), BackgroundWorkerArray::parallel_register_count, BackgroundWorkerArray::parallel_terminate_count, pg_write_barrier, BackgroundWorkerSlot::pid, PMSIGNAL_BACKGROUND_WORKER_CHANGE, SanityCheckBackgroundWorker(), SendPostmasterSignal(), BackgroundWorkerArray::slot, success, BackgroundWorkerSlot::terminate, BackgroundWorkerArray::total_slots, and BackgroundWorkerSlot::worker.

Referenced by LaunchParallelWorkers(), logicalrep_worker_launch(), setup_background_workers(), and worker_spi_launch().

866 {
867  int slotno;
868  bool success = false;
869  bool parallel;
870  uint64 generation = 0;
871 
872  /*
873  * We can't register dynamic background workers from the postmaster. If
874  * this is a standalone backend, we're the only process and can't start
875  * any more. In a multi-process environment, it might be theoretically
876  * possible, but we don't currently support it due to locking
877  * considerations; see comments on the BackgroundWorkerSlot data
878  * structure.
879  */
880  if (!IsUnderPostmaster)
881  return false;
882 
883  if (!SanityCheckBackgroundWorker(worker, ERROR))
884  return false;
885 
886  parallel = (worker->bgw_flags & BGWORKER_CLASS_PARALLEL) != 0;
887 
888  LWLockAcquire(BackgroundWorkerLock, LW_EXCLUSIVE);
889 
890  /*
891  * If this is a parallel worker, check whether there are already too many
892  * parallel workers; if so, don't register another one. Our view of
893  * parallel_terminate_count may be slightly stale, but that doesn't really
894  * matter: we would have gotten the same result if we'd arrived here
895  * slightly earlier anyway. There's no help for it, either, since the
896  * postmaster must not take locks; a memory barrier wouldn't guarantee
897  * anything useful.
898  */
902  {
903  LWLockRelease(BackgroundWorkerLock);
904  return false;
905  }
906 
907  /*
908  * Look for an unused slot. If we find one, grab it.
909  */
910  for (slotno = 0; slotno < BackgroundWorkerData->total_slots; ++slotno)
911  {
913 
914  if (!slot->in_use)
915  {
916  memcpy(&slot->worker, worker, sizeof(BackgroundWorker));
917  slot->pid = InvalidPid; /* indicates not started yet */
918  slot->generation++;
919  slot->terminate = false;
920  generation = slot->generation;
921  if (parallel)
923 
924  /*
925  * Make sure postmaster doesn't see the slot as in use before it
926  * sees the new contents.
927  */
929 
930  slot->in_use = true;
931  success = true;
932  break;
933  }
934  }
935 
936  LWLockRelease(BackgroundWorkerLock);
937 
938  /* If we found a slot, tell the postmaster to notice the change. */
939  if (success)
941 
942  /*
943  * If we found a slot and the user has provided a handle, initialize it.
944  */
945  if (success && handle)
946  {
947  *handle = palloc(sizeof(BackgroundWorkerHandle));
948  (*handle)->slot = slotno;
949  (*handle)->generation = generation;
950  }
951 
952  return success;
953 }
int max_parallel_workers
Definition: globals.c:125
static BackgroundWorkerArray * BackgroundWorkerData
Definition: bgworker.c:109
#define BGWORKER_CLASS_PARALLEL
Definition: bgworker.h:67
void LWLockRelease(LWLock *lock)
Definition: lwlock.c:1714
#define ERROR
Definition: elog.h:43
static bool success
Definition: pg_basebackup.c:98
uint32 parallel_register_count
Definition: bgworker.c:98
bool IsUnderPostmaster
Definition: globals.c:100
static bool SanityCheckBackgroundWorker(BackgroundWorker *worker, int elevel)
Definition: bgworker.c:507
BackgroundWorker worker
Definition: bgworker.c:81
bool LWLockAcquire(LWLock *lock, LWLockMode mode)
Definition: lwlock.c:1110
void * palloc(Size size)
Definition: mcxt.c:891
uint32 parallel_terminate_count
Definition: bgworker.c:99
#define pg_write_barrier()
Definition: atomics.h:161
void SendPostmasterSignal(PMSignalReason reason)
Definition: pmsignal.c:113
BackgroundWorkerSlot slot[FLEXIBLE_ARRAY_MEMBER]
Definition: bgworker.c:100
#define InvalidPid
Definition: miscadmin.h:31
void TerminateBackgroundWorker ( BackgroundWorkerHandle handle)

Definition at line 1099 of file bgworker.c.

References Assert, BackgroundWorkerSlot::generation, BackgroundWorkerHandle::generation, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), max_worker_processes, PMSIGNAL_BACKGROUND_WORKER_CHANGE, SendPostmasterSignal(), BackgroundWorkerArray::slot, BackgroundWorkerHandle::slot, and BackgroundWorkerSlot::terminate.

Referenced by cleanup_background_workers(), and DestroyParallelContext().

1100 {
1101  BackgroundWorkerSlot *slot;
1102  bool signal_postmaster = false;
1103 
1104  Assert(handle->slot < max_worker_processes);
1105  slot = &BackgroundWorkerData->slot[handle->slot];
1106 
1107  /* Set terminate flag in shared memory, unless slot has been reused. */
1108  LWLockAcquire(BackgroundWorkerLock, LW_EXCLUSIVE);
1109  if (handle->generation == slot->generation)
1110  {
1111  slot->terminate = true;
1112  signal_postmaster = true;
1113  }
1114  LWLockRelease(BackgroundWorkerLock);
1115 
1116  /* Make sure the postmaster notices the change to shared memory. */
1117  if (signal_postmaster)
1119 }
static BackgroundWorkerArray * BackgroundWorkerData
Definition: bgworker.c:109
void LWLockRelease(LWLock *lock)
Definition: lwlock.c:1714
#define Assert(condition)
Definition: c.h:671
bool LWLockAcquire(LWLock *lock, LWLockMode mode)
Definition: lwlock.c:1110
int max_worker_processes
Definition: globals.c:124
void SendPostmasterSignal(PMSignalReason reason)
Definition: pmsignal.c:113
BackgroundWorkerSlot slot[FLEXIBLE_ARRAY_MEMBER]
Definition: bgworker.c:100
BgwHandleStatus WaitForBackgroundWorkerShutdown ( BackgroundWorkerHandle )

Definition at line 1060 of file bgworker.c.

References BGWH_POSTMASTER_DIED, BGWH_STOPPED, CHECK_FOR_INTERRUPTS, GetBackgroundWorkerPid(), MyProc, PGPROC::procLatch, ResetLatch(), status(), WAIT_EVENT_BGWORKER_SHUTDOWN, WaitLatch(), WL_LATCH_SET, and WL_POSTMASTER_DEATH.

Referenced by WaitForParallelWorkersToExit().

1061 {
1063  int rc;
1064 
1065  for (;;)
1066  {
1067  pid_t pid;
1068 
1070 
1071  status = GetBackgroundWorkerPid(handle, &pid);
1072  if (status == BGWH_STOPPED)
1073  break;
1074 
1075  rc = WaitLatch(&MyProc->procLatch,
1078 
1079  if (rc & WL_POSTMASTER_DEATH)
1080  {
1081  status = BGWH_POSTMASTER_DIED;
1082  break;
1083  }
1084 
1086  }
1087 
1088  return status;
1089 }
PGPROC * MyProc
Definition: proc.c:67
void ResetLatch(volatile Latch *latch)
Definition: latch.c:461
Latch procLatch
Definition: proc.h:93
int WaitLatch(volatile Latch *latch, int wakeEvents, long timeout, uint32 wait_event_info)
Definition: latch.c:300
BgwHandleStatus
Definition: bgworker.h:102
#define WL_POSTMASTER_DEATH
Definition: latch.h:128
#define CHECK_FOR_INTERRUPTS()
Definition: miscadmin.h:97
static void static void status(const char *fmt,...) pg_attribute_printf(1
Definition: pg_regress.c:222
#define WL_LATCH_SET
Definition: latch.h:124
BgwHandleStatus GetBackgroundWorkerPid(BackgroundWorkerHandle *handle, pid_t *pidp)
Definition: bgworker.c:969
BgwHandleStatus WaitForBackgroundWorkerStartup ( BackgroundWorkerHandle handle,
pid_t *  pid 
)

Definition at line 1018 of file bgworker.c.

References BGWH_NOT_YET_STARTED, BGWH_POSTMASTER_DIED, BGWH_STARTED, CHECK_FOR_INTERRUPTS, GetBackgroundWorkerPid(), MyLatch, ResetLatch(), status(), WAIT_EVENT_BGWORKER_STARTUP, WaitLatch(), WL_LATCH_SET, and WL_POSTMASTER_DEATH.

Referenced by worker_spi_launch().

1019 {
1021  int rc;
1022 
1023  for (;;)
1024  {
1025  pid_t pid;
1026 
1028 
1029  status = GetBackgroundWorkerPid(handle, &pid);
1030  if (status == BGWH_STARTED)
1031  *pidp = pid;
1032  if (status != BGWH_NOT_YET_STARTED)
1033  break;
1034 
1035  rc = WaitLatch(MyLatch,
1038 
1039  if (rc & WL_POSTMASTER_DEATH)
1040  {
1041  status = BGWH_POSTMASTER_DIED;
1042  break;
1043  }
1044 
1046  }
1047 
1048  return status;
1049 }
void ResetLatch(volatile Latch *latch)
Definition: latch.c:461
int WaitLatch(volatile Latch *latch, int wakeEvents, long timeout, uint32 wait_event_info)
Definition: latch.c:300
BgwHandleStatus
Definition: bgworker.h:102
#define WL_POSTMASTER_DEATH
Definition: latch.h:128
struct Latch * MyLatch
Definition: globals.c:51
#define CHECK_FOR_INTERRUPTS()
Definition: miscadmin.h:97
static void static void status(const char *fmt,...) pg_attribute_printf(1
Definition: pg_regress.c:222
#define WL_LATCH_SET
Definition: latch.h:124
BgwHandleStatus GetBackgroundWorkerPid(BackgroundWorkerHandle *handle, pid_t *pidp)
Definition: bgworker.c:969

Variable Documentation