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().

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 101 of file bgworker.h.

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

Definition at line 76 of file bgworker.h.

Function Documentation

void BackgroundWorkerBlockSignals ( void  )

Definition at line 5516 of file postmaster.c.

References BlockSig, and PG_SETMASK.

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

Definition at line 5470 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().

5471 {
5473 
5474  /* XXX is this the right errcode? */
5476  ereport(FATAL,
5477  (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
5478  errmsg("database connection requirement not indicated during registration")));
5479 
5481 
5482  /* it had better not gotten out of "init" mode yet */
5483  if (!IsInitProcessingMode())
5484  ereport(ERROR,
5485  (errmsg("invalid processing mode in background worker")));
5487 }
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:131
#define InvalidOid
Definition: postgres_ext.h:36
#define NULL
Definition: c.h:229
#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 5493 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().

5494 {
5496 
5497  /* XXX is this the right errcode? */
5499  ereport(FATAL,
5500  (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
5501  errmsg("database connection requirement not indicated during registration")));
5502 
5503  InitPostgres(NULL, dboid, NULL, useroid, NULL);
5504 
5505  /* it had better not gotten out of "init" mode yet */
5506  if (!IsInitProcessingMode())
5507  ereport(ERROR,
5508  (errmsg("invalid processing mode in background worker")));
5510 }
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:229
#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 5522 of file postmaster.c.

References PG_SETMASK, and UnBlockSig.

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

5523 {
5525 }
#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 1041 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().

1042 {
1043  BackgroundWorkerSlot *slot;
1044  pid_t pid;
1045 
1046  Assert(handle->slot < max_worker_processes);
1047  slot = &BackgroundWorkerData->slot[handle->slot];
1048 
1049  /*
1050  * We could probably arrange to synchronize access to data using memory
1051  * barriers only, but for now, let's just keep it simple and grab the
1052  * lock. It seems unlikely that there will be enough traffic here to
1053  * result in meaningful contention.
1054  */
1055  LWLockAcquire(BackgroundWorkerLock, LW_SHARED);
1056 
1057  /*
1058  * The generation number can't be concurrently changed while we hold the
1059  * lock. The pid, which is updated by the postmaster, can change at any
1060  * time, but we assume such changes are atomic. So the value we read
1061  * won't be garbage, but it might be out of date by the time the caller
1062  * examines it (but that's unavoidable anyway).
1063  */
1064  if (handle->generation != slot->generation)
1065  pid = 0;
1066  else
1067  pid = slot->pid;
1068 
1069  /* All done. */
1070  LWLockRelease(BackgroundWorkerLock);
1071 
1072  if (pid == 0)
1073  return BGWH_STOPPED;
1074  else if (pid == InvalidPid)
1075  return BGWH_NOT_YET_STARTED;
1076  *pidp = pid;
1077  return BGWH_STARTED;
1078 }
static BackgroundWorkerArray * BackgroundWorkerData
Definition: bgworker.c:111
void LWLockRelease(LWLock *lock)
Definition: lwlock.c:1715
#define Assert(condition)
Definition: c.h:675
bool LWLockAcquire(LWLock *lock, LWLockMode mode)
Definition: lwlock.c:1111
int max_worker_processes
Definition: globals.c:124
BackgroundWorkerSlot slot[FLEXIBLE_ARRAY_MEMBER]
Definition: bgworker.c:102
#define InvalidPid
Definition: miscadmin.h:31
void RegisterBackgroundWorker ( BackgroundWorker worker)

Definition at line 849 of file bgworker.c.

References BackgroundWorker::bgw_library_name, BackgroundWorker::bgw_name, BackgroundWorker::bgw_notify_pid, DEBUG1, ereport, errcode(), errdetail_plural(), errhint(), errmsg(), 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().

850 {
851  RegisteredBgWorker *rw;
852  static int numworkers = 0;
853 
854  if (!IsUnderPostmaster)
855  ereport(DEBUG1,
856  (errmsg("registering background worker \"%s\"", worker->bgw_name)));
857 
859  strcmp(worker->bgw_library_name, "postgres") != 0)
860  {
861  if (!IsUnderPostmaster)
862  ereport(LOG,
863  (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
864  errmsg("background worker \"%s\": must be registered in shared_preload_libraries",
865  worker->bgw_name)));
866  return;
867  }
868 
869  if (!SanityCheckBackgroundWorker(worker, LOG))
870  return;
871 
872  if (worker->bgw_notify_pid != 0)
873  {
874  ereport(LOG,
875  (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
876  errmsg("background worker \"%s\": only dynamic background workers can request notification",
877  worker->bgw_name)));
878  return;
879  }
880 
881  /*
882  * Enforce maximum number of workers. Note this is overly restrictive: we
883  * could allow more non-shmem-connected workers, because these don't count
884  * towards the MAX_BACKENDS limit elsewhere. For now, it doesn't seem
885  * important to relax this restriction.
886  */
887  if (++numworkers > max_worker_processes)
888  {
889  ereport(LOG,
890  (errcode(ERRCODE_CONFIGURATION_LIMIT_EXCEEDED),
891  errmsg("too many background workers"),
892  errdetail_plural("Up to %d background worker can be registered with the current settings.",
893  "Up to %d background workers can be registered with the current settings.",
896  errhint("Consider increasing the configuration parameter \"max_worker_processes\".")));
897  return;
898  }
899 
900  /*
901  * Copy the registration data into the registered workers list.
902  */
903  rw = malloc(sizeof(RegisteredBgWorker));
904  if (rw == NULL)
905  {
906  ereport(LOG,
907  (errcode(ERRCODE_OUT_OF_MEMORY),
908  errmsg("out of memory")));
909  return;
910  }
911 
912  rw->rw_worker = *worker;
913  rw->rw_backend = NULL;
914  rw->rw_pid = 0;
915  rw->rw_child_slot = 0;
916  rw->rw_crashed_at = 0;
917  rw->rw_terminate = false;
918 
920 }
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:1417
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
#define malloc(a)
Definition: header.h:50
slist_head BackgroundWorkerList
Definition: bgworker.c:43
bool IsUnderPostmaster
Definition: globals.c:100
#define ereport(elevel, rest)
Definition: elog.h:122
static bool SanityCheckBackgroundWorker(BackgroundWorker *worker, int elevel)
Definition: bgworker.c:581
#define NULL
Definition: c.h:229
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:98
int max_worker_processes
Definition: globals.c:124
BackgroundWorker rw_worker
char bgw_library_name[BGW_MAXLEN]
Definition: bgworker.h:94
bool RegisterDynamicBackgroundWorker ( BackgroundWorker worker,
BackgroundWorkerHandle **  handle 
)

Definition at line 933 of file bgworker.c.

References Assert, BackgroundWorker::bgw_flags, BGWORKER_CLASS_PARALLEL, ERROR, BackgroundWorkerSlot::generation, BackgroundWorkerSlot::in_use, InvalidPid, IsUnderPostmaster, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), MAX_PARALLEL_WORKER_LIMIT, 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().

935 {
936  int slotno;
937  bool success = false;
938  bool parallel;
939  uint64 generation = 0;
940 
941  /*
942  * We can't register dynamic background workers from the postmaster. If
943  * this is a standalone backend, we're the only process and can't start
944  * any more. In a multi-process environment, it might be theoretically
945  * possible, but we don't currently support it due to locking
946  * considerations; see comments on the BackgroundWorkerSlot data
947  * structure.
948  */
949  if (!IsUnderPostmaster)
950  return false;
951 
952  if (!SanityCheckBackgroundWorker(worker, ERROR))
953  return false;
954 
955  parallel = (worker->bgw_flags & BGWORKER_CLASS_PARALLEL) != 0;
956 
957  LWLockAcquire(BackgroundWorkerLock, LW_EXCLUSIVE);
958 
959  /*
960  * If this is a parallel worker, check whether there are already too many
961  * parallel workers; if so, don't register another one. Our view of
962  * parallel_terminate_count may be slightly stale, but that doesn't really
963  * matter: we would have gotten the same result if we'd arrived here
964  * slightly earlier anyway. There's no help for it, either, since the
965  * postmaster must not take locks; a memory barrier wouldn't guarantee
966  * anything useful.
967  */
971  {
975  LWLockRelease(BackgroundWorkerLock);
976  return false;
977  }
978 
979  /*
980  * Look for an unused slot. If we find one, grab it.
981  */
982  for (slotno = 0; slotno < BackgroundWorkerData->total_slots; ++slotno)
983  {
985 
986  if (!slot->in_use)
987  {
988  memcpy(&slot->worker, worker, sizeof(BackgroundWorker));
989  slot->pid = InvalidPid; /* indicates not started yet */
990  slot->generation++;
991  slot->terminate = false;
992  generation = slot->generation;
993  if (parallel)
995 
996  /*
997  * Make sure postmaster doesn't see the slot as in use before it
998  * sees the new contents.
999  */
1000  pg_write_barrier();
1001 
1002  slot->in_use = true;
1003  success = true;
1004  break;
1005  }
1006  }
1007 
1008  LWLockRelease(BackgroundWorkerLock);
1009 
1010  /* If we found a slot, tell the postmaster to notice the change. */
1011  if (success)
1013 
1014  /*
1015  * If we found a slot and the user has provided a handle, initialize it.
1016  */
1017  if (success && handle)
1018  {
1019  *handle = palloc(sizeof(BackgroundWorkerHandle));
1020  (*handle)->slot = slotno;
1021  (*handle)->generation = generation;
1022  }
1023 
1024  return success;
1025 }
int max_parallel_workers
Definition: globals.c:125
static BackgroundWorkerArray * BackgroundWorkerData
Definition: bgworker.c:111
#define BGWORKER_CLASS_PARALLEL
Definition: bgworker.h:67
void LWLockRelease(LWLock *lock)
Definition: lwlock.c:1715
#define ERROR
Definition: elog.h:43
static bool success
Definition: pg_basebackup.c:96
uint32 parallel_register_count
Definition: bgworker.c:100
bool IsUnderPostmaster
Definition: globals.c:100
static bool SanityCheckBackgroundWorker(BackgroundWorker *worker, int elevel)
Definition: bgworker.c:581
#define Assert(condition)
Definition: c.h:675
BackgroundWorker worker
Definition: bgworker.c:83
bool LWLockAcquire(LWLock *lock, LWLockMode mode)
Definition: lwlock.c:1111
void * palloc(Size size)
Definition: mcxt.c:849
uint32 parallel_terminate_count
Definition: bgworker.c:101
#define pg_write_barrier()
Definition: atomics.h:162
void SendPostmasterSignal(PMSignalReason reason)
Definition: pmsignal.c:113
#define MAX_PARALLEL_WORKER_LIMIT
BackgroundWorkerSlot slot[FLEXIBLE_ARRAY_MEMBER]
Definition: bgworker.c:102
#define InvalidPid
Definition: miscadmin.h:31
void TerminateBackgroundWorker ( BackgroundWorkerHandle handle)

Definition at line 1171 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().

1172 {
1173  BackgroundWorkerSlot *slot;
1174  bool signal_postmaster = false;
1175 
1176  Assert(handle->slot < max_worker_processes);
1177  slot = &BackgroundWorkerData->slot[handle->slot];
1178 
1179  /* Set terminate flag in shared memory, unless slot has been reused. */
1180  LWLockAcquire(BackgroundWorkerLock, LW_EXCLUSIVE);
1181  if (handle->generation == slot->generation)
1182  {
1183  slot->terminate = true;
1184  signal_postmaster = true;
1185  }
1186  LWLockRelease(BackgroundWorkerLock);
1187 
1188  /* Make sure the postmaster notices the change to shared memory. */
1189  if (signal_postmaster)
1191 }
static BackgroundWorkerArray * BackgroundWorkerData
Definition: bgworker.c:111
void LWLockRelease(LWLock *lock)
Definition: lwlock.c:1715
#define Assert(condition)
Definition: c.h:675
bool LWLockAcquire(LWLock *lock, LWLockMode mode)
Definition: lwlock.c:1111
int max_worker_processes
Definition: globals.c:124
void SendPostmasterSignal(PMSignalReason reason)
Definition: pmsignal.c:113
BackgroundWorkerSlot slot[FLEXIBLE_ARRAY_MEMBER]
Definition: bgworker.c:102
BgwHandleStatus WaitForBackgroundWorkerShutdown ( BackgroundWorkerHandle )

Definition at line 1132 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().

1133 {
1135  int rc;
1136 
1137  for (;;)
1138  {
1139  pid_t pid;
1140 
1142 
1143  status = GetBackgroundWorkerPid(handle, &pid);
1144  if (status == BGWH_STOPPED)
1145  break;
1146 
1147  rc = WaitLatch(&MyProc->procLatch,
1150 
1151  if (rc & WL_POSTMASTER_DEATH)
1152  {
1153  status = BGWH_POSTMASTER_DIED;
1154  break;
1155  }
1156 
1158  }
1159 
1160  return status;
1161 }
PGPROC * MyProc
Definition: proc.c:67
void ResetLatch(volatile Latch *latch)
Definition: latch.c:498
Latch procLatch
Definition: proc.h:103
int WaitLatch(volatile Latch *latch, int wakeEvents, long timeout, uint32 wait_event_info)
Definition: latch.c:336
BgwHandleStatus
Definition: bgworker.h:101
#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:224
#define WL_LATCH_SET
Definition: latch.h:124
BgwHandleStatus GetBackgroundWorkerPid(BackgroundWorkerHandle *handle, pid_t *pidp)
Definition: bgworker.c:1041
BgwHandleStatus WaitForBackgroundWorkerStartup ( BackgroundWorkerHandle handle,
pid_t *  pid 
)

Definition at line 1090 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().

1091 {
1093  int rc;
1094 
1095  for (;;)
1096  {
1097  pid_t pid;
1098 
1100 
1101  status = GetBackgroundWorkerPid(handle, &pid);
1102  if (status == BGWH_STARTED)
1103  *pidp = pid;
1104  if (status != BGWH_NOT_YET_STARTED)
1105  break;
1106 
1107  rc = WaitLatch(MyLatch,
1110 
1111  if (rc & WL_POSTMASTER_DEATH)
1112  {
1113  status = BGWH_POSTMASTER_DIED;
1114  break;
1115  }
1116 
1118  }
1119 
1120  return status;
1121 }
void ResetLatch(volatile Latch *latch)
Definition: latch.c:498
int WaitLatch(volatile Latch *latch, int wakeEvents, long timeout, uint32 wait_event_info)
Definition: latch.c:336
BgwHandleStatus
Definition: bgworker.h:101
#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:224
#define WL_LATCH_SET
Definition: latch.h:124
BgwHandleStatus GetBackgroundWorkerPid(BackgroundWorkerHandle *handle, pid_t *pidp)
Definition: bgworker.c:1041

Variable Documentation