1 /*--------------------------------------------------------------------
3 * POSTGRES pluggable background workers internals
5 * Portions Copyright (c) 1996-2013, PostgreSQL Global Development Group
6 * Portions Copyright (c) 1994, Regents of the University of California
9 * src/include/postmaster/bgworker_internals.h
10 *--------------------------------------------------------------------
12 #ifndef BGWORKER_INTERNALS_H
13 #define BGWORKER_INTERNALS_H
15 #include "datatype/timestamp.h"
16 #include "lib/ilist.h"
17 #include "postmaster/bgworker.h"
20 * List of background workers, private to postmaster.
22 * A worker that requests a database connection during registration will have
23 * rw_backend set, and will be present in BackendList. Note: do not rely on
24 * rw_backend being non-NULL for shmem-connected workers!
26 typedef struct RegisteredBgWorker
28 BackgroundWorker rw_worker; /* its registry entry */
29 struct bkend *rw_backend; /* its BackendList entry, or NULL */
30 pid_t rw_pid; /* 0 if not running */
32 TimestampTz rw_crashed_at; /* if not 0, time it last crashed */
34 slist_node rw_lnode; /* list link */
37 extern slist_head BackgroundWorkerList;
39 extern Size BackgroundWorkerShmemSize(void);
40 extern void BackgroundWorkerShmemInit(void);
41 extern void BackgroundWorkerStateChange(void);
42 extern void ForgetBackgroundWorker(slist_mutable_iter *cur);
44 /* Function to start a background worker, called from postmaster.c */
45 extern void StartBackgroundWorker(void);
48 extern BackgroundWorker *BackgroundWorkerEntry(int slotno);
51 #endif /* BGWORKER_INTERNALS_H */