Skip to content

Instantly share code, notes, and snippets.

@fdr
Created October 8, 2011 18:52
Show Gist options
  • Save fdr/1272695 to your computer and use it in GitHub Desktop.
Save fdr/1272695 to your computer and use it in GitHub Desktop.
port data structure from febe
typedef struct Port
{
pgsocket sock; /* File descriptor */
bool noblock; /* is the socket in non-blocking mode? */
ProtocolVersion proto; /* FE/BE protocol version */
SockAddr laddr; /* local addr (postmaster) */
SockAddr raddr; /* remote addr (client) */
char *remote_host; /* name (or ip addr) of remote host */
char *remote_hostname;/* name (not ip addr) of remote host, if
* available */
int remote_hostname_resolv; /* +1 = remote_hostname is known to
* resolve to client's IP address; -1
* = remote_hostname is known NOT to
* resolve to client's IP address; 0 =
* we have not done the forward DNS
* lookup yet */
char *remote_port; /* text rep of remote port */
CAC_state canAcceptConnections; /* postmaster connection status */
/*
* Information that needs to be saved from the startup packet and passed
* into backend execution. "char *" fields are NULL if not set.
* guc_options points to a List of alternating option names and values.
*/
char *database_name;
char *user_name;
char *cmdline_options;
List *guc_options;
/*
* Information that needs to be held during the authentication cycle.
*/
HbaLine *hba;
char md5Salt[4]; /* Password salt */
/*
* Information that really has no business at all being in struct Port,
* but since it gets used by elog.c in the same way as database_name and
* other members of this struct, we may as well keep it here.
*/
TimestampTz SessionStartTime; /* backend start time */
/*
* TCP keepalive settings.
*
* default values are 0 if AF_UNIX or not yet known; current values are 0
* if AF_UNIX or using the default. Also, -1 in a default value means we
* were unable to find out the default (getsockopt failed).
*/
int default_keepalives_idle;
int default_keepalives_interval;
int default_keepalives_count;
int keepalives_idle;
int keepalives_interval;
int keepalives_count;
#if defined(ENABLE_GSS) || defined(ENABLE_SSPI)
/*
* If GSSAPI is supported, store GSSAPI information. Oterwise, store a
* NULL pointer to make sure offsets in the struct remain the same.
*/
pg_gssinfo *gss;
#else
void *gss;
#endif
/*
* SSL structures (keep these last so that USE_SSL doesn't affect
* locations of other fields)
*/
#ifdef USE_SSL
SSL *ssl;
X509 *peer;
char peer_dn[128 + 1];
char peer_cn[SM_USER + 1];
unsigned long count;
#endif
} Port;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment