PostgreSQL Source Code  git master
backend_startup.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  BackendStartupData
 

Typedefs

typedef enum CAC_state CAC_state
 
typedef struct BackendStartupData BackendStartupData
 

Enumerations

enum  CAC_state {
  CAC_OK , CAC_STARTUP , CAC_SHUTDOWN , CAC_RECOVERY ,
  CAC_NOTCONSISTENT , CAC_TOOMANY
}
 

Functions

void BackendMain (char *startup_data, size_t startup_data_len) pg_attribute_noreturn()
 

Typedef Documentation

◆ BackendStartupData

◆ CAC_state

typedef enum CAC_state CAC_state

Enumeration Type Documentation

◆ CAC_state

enum CAC_state
Enumerator
CAC_OK 
CAC_STARTUP 
CAC_SHUTDOWN 
CAC_RECOVERY 
CAC_NOTCONSISTENT 
CAC_TOOMANY 

Definition at line 23 of file backend_startup.h.

24 {
25  CAC_OK,
31 } CAC_state;
CAC_state
@ CAC_TOOMANY
@ CAC_OK
@ CAC_RECOVERY
@ CAC_NOTCONSISTENT
@ CAC_STARTUP
@ CAC_SHUTDOWN

Function Documentation

◆ BackendMain()

void BackendMain ( char *  startup_data,
size_t  startup_data_len 
)

Definition at line 57 of file backend_startup.c.

58 {
59  BackendStartupData *bsdata = (BackendStartupData *) startup_data;
60 
61  Assert(startup_data_len == sizeof(BackendStartupData));
62  Assert(MyClientSocket != NULL);
63 
64 #ifdef EXEC_BACKEND
65 
66  /*
67  * Need to reinitialize the SSL library in the backend, since the context
68  * structures contain function pointers and cannot be passed through the
69  * parameter file.
70  *
71  * If for some reason reload fails (maybe the user installed broken key
72  * files), soldier on without SSL; that's better than all connections
73  * becoming impossible.
74  *
75  * XXX should we do this in all child processes? For the moment it's
76  * enough to do it in backend children.
77  */
78 #ifdef USE_SSL
79  if (EnableSSL)
80  {
81  if (secure_initialize(false) == 0)
82  LoadedSSL = true;
83  else
84  ereport(LOG,
85  (errmsg("SSL configuration could not be loaded in child process")));
86  }
87 #endif
88 #endif
89 
90  /* Perform additional initialization and collect startup packet */
92 
93  /*
94  * Create a per-backend PGPROC struct in shared memory. We must do this
95  * before we can use LWLocks or access any shared memory.
96  */
97  InitProcess();
98 
99  /*
100  * Make sure we aren't in PostmasterContext anymore. (We can't delete it
101  * just yet, though, because InitPostgres will need the HBA data.)
102  */
104 
106 }
static void BackendInitialize(ClientSocket *client_sock, CAC_state cac)
int secure_initialize(bool isServerStart)
Definition: be-secure.c:73
#define Assert(condition)
Definition: c.h:858
int errmsg(const char *fmt,...)
Definition: elog.c:1070
#define LOG
Definition: elog.h:31
#define ereport(elevel,...)
Definition: elog.h:149
struct ClientSocket * MyClientSocket
Definition: globals.c:48
struct Port * MyProcPort
Definition: globals.c:49
MemoryContext TopMemoryContext
Definition: mcxt.c:149
void PostgresMain(const char *dbname, const char *username)
Definition: postgres.c:4152
bool EnableSSL
Definition: postmaster.c:225
PGDLLIMPORT bool LoadedSSL
MemoryContextSwitchTo(old_ctx)
void InitProcess(void)
Definition: proc.c:296
CAC_state canAcceptConnections
char * user_name
Definition: libpq-be.h:152
char * database_name
Definition: libpq-be.h:151

References Assert, BackendInitialize(), BackendStartupData::canAcceptConnections, Port::database_name, EnableSSL, ereport, errmsg(), InitProcess(), LoadedSSL, LOG, MemoryContextSwitchTo(), MyClientSocket, MyProcPort, PostgresMain(), secure_initialize(), TopMemoryContext, and Port::user_name.