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 /*
20  * List of background workers, private to postmaster.
21  *
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!
25  */
26 typedef struct RegisteredBgWorker
27 {
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 */
35  slist_node rw_lnode; /* list link */
37 
39 
40 extern Size BackgroundWorkerShmemSize(void);
41 extern void BackgroundWorkerShmemInit(void);
42 extern void BackgroundWorkerStateChange(void);
45 extern void BackgroundWorkerStopNotifications(pid_t pid);
46 extern void ResetBackgroundWorkerCrashTimes(void);
47 
48 /* Function to start a background worker, called from postmaster.c */
50 
51 #ifdef EXEC_BACKEND
52 extern BackgroundWorker *BackgroundWorkerEntry(int slotno);
53 #endif
54 
55 #endif /* BGWORKER_INTERNALS_H */
struct bkend * rw_backend
void ForgetBackgroundWorker(slist_mutable_iter *cur)
Definition: bgworker.c:392
struct cursor * cur
Definition: ecpg.c:28
slist_head BackgroundWorkerList
Definition: bgworker.c:41
#define pg_attribute_noreturn()
Definition: c.h:648
double TimestampTz
Definition: timestamp.h:51
void BackgroundWorkerShmemInit(void)
Definition: bgworker.c:140
void BackgroundWorkerStopNotifications(pid_t pid)
Definition: bgworker.c:438
void ResetBackgroundWorkerCrashTimes(void)
Definition: bgworker.c:460
void BackgroundWorkerStateChange(void)
Definition: bgworker.c:222
void StartBackgroundWorker(void) pg_attribute_noreturn()
Definition: bgworker.c:611
pid_t pid
Definition: postmaster.c:168
Size BackgroundWorkerShmemSize(void)
Definition: bgworker.c:124
size_t Size
Definition: c.h:352
struct RegisteredBgWorker RegisteredBgWorker
BackgroundWorker rw_worker
void ReportBackgroundWorkerPID(RegisteredBgWorker *)
Definition: bgworker.c:420