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

Variables

PGDLLIMPORT bool Trace_connection_negotiation
 

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 26 of file backend_startup.h.

27 {
28  CAC_OK,
34 } 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 58 of file backend_startup.c.

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

Variable Documentation

◆ Trace_connection_negotiation

PGDLLIMPORT bool Trace_connection_negotiation
extern

Definition at line 42 of file backend_startup.c.

Referenced by ProcessSSLStartup(), and ProcessStartupPacket().