PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
bgworker_internals.h
Go to the documentation of this file.
1 /*--------------------------------------------------------------------
2  * bgworker_internals.h
3  * POSTGRES pluggable background workers internals
4  *
5  * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group
6  * Portions Copyright (c) 1994, Regents of the University of California
7  *
8  * IDENTIFICATION
9  * src/include/postmaster/bgworker_internals.h
10  *--------------------------------------------------------------------
11  */
12 #ifndef BGWORKER_INTERNALS_H
13 #define BGWORKER_INTERNALS_H
14 
15 #include "datatype/timestamp.h"
16 #include "lib/ilist.h"
17 #include "postmaster/bgworker.h"
18 
19 /* GUC options */
20 
21 /*
22  * Maximum possible value of parallel workers.
23  */
24 #define MAX_PARALLEL_WORKER_LIMIT 1024
25 
26 /*
27  * List of background workers, private to postmaster.
28  *
29  * A worker that requests a database connection during registration will have
30  * rw_backend set, and will be present in BackendList. Note: do not rely on
31  * rw_backend being non-NULL for shmem-connected workers!
32  */
33 typedef struct RegisteredBgWorker
34 {
35  BackgroundWorker rw_worker; /* its registry entry */
36  struct bkend *rw_backend; /* its BackendList entry, or NULL */
37  pid_t rw_pid; /* 0 if not running */
39  TimestampTz rw_crashed_at; /* if not 0, time it last crashed */
42  slist_node rw_lnode; /* list link */
44 
46 
47 extern Size BackgroundWorkerShmemSize(void);
48 extern void BackgroundWorkerShmemInit(void);
49 extern void BackgroundWorkerStateChange(void);
53 extern void BackgroundWorkerStopNotifications(pid_t pid);
54 extern void ResetBackgroundWorkerCrashTimes(void);
55 
56 /* Function to start a background worker, called from postmaster.c */
58 
59 #ifdef EXEC_BACKEND
60 extern BackgroundWorker *BackgroundWorkerEntry(int slotno);
61 #endif
62 
63 #endif /* BGWORKER_INTERNALS_H */
struct bkend * rw_backend
void ForgetBackgroundWorker(slist_mutable_iter *cur)
Definition: bgworker.c:410
int64 TimestampTz
Definition: timestamp.h:39
struct cursor * cur
Definition: ecpg.c:28
slist_head BackgroundWorkerList
Definition: bgworker.c:43
void ReportBackgroundWorkerExit(slist_mutable_iter *cur)
Definition: bgworker.c:457
void BackgroundWorkerShmemInit(void)
Definition: bgworker.c:159
void BackgroundWorkerStopNotifications(pid_t pid)
Definition: bgworker.c:491
void ResetBackgroundWorkerCrashTimes(void)
Definition: bgworker.c:513
void BackgroundWorkerStateChange(void)
Definition: bgworker.c:241
void StartBackgroundWorker(void) pg_attribute_noreturn()
Definition: bgworker.c:700
pid_t pid
Definition: postmaster.c:169
Size BackgroundWorkerShmemSize(void)
Definition: bgworker.c:143
size_t Size
Definition: c.h:356
#define pg_attribute_noreturn()
Definition: c.h:653
struct RegisteredBgWorker RegisteredBgWorker
BackgroundWorker rw_worker
void ReportBackgroundWorkerPID(RegisteredBgWorker *)
Definition: bgworker.c:438