MySQL  8.0.20
Source Code Documentation
xcom_transport.h File Reference

Go to the source code of this file.

Classes

struct  envelope
 

Macros

#define XDR_INT_SIZE   4
 
#define MSG_HDR_SIZE   (3 * XDR_INT_SIZE)
 
#define SERIALIZED_BUFLEN(x)   ((x) + MSG_HDR_SIZE)
 
#define VERS_PTR(buf)   (buf)
 
#define LENGTH_PTR(buf)   &((buf)[XDR_INT_SIZE])
 
#define X_TYPE   (2 * XDR_INT_SIZE)
 
#define X_TAG   (X_TYPE + 1)
 
#define X_TAG_PTR(buf)   &((buf)[X_TAG])
 
#define MSG_PTR(buf)   &((buf)[MSG_HDR_SIZE])
 
#define IP_MAX_SIZE   512
 
#define INITIAL_CONNECT_WAIT   0.1
 
#define MAX_CONNECT_WAIT   1.0
 
#define CONNECT_WAIT_INCREASE   1.1
 

Typedefs

typedef enum x_msg_type x_msg_type
 
typedef struct envelope envelope
 

Enumerations

enum  x_msg_type { x_normal = 0, x_version_req = 1, x_version_reply = 2 }
 

Functions

int check_protoversion (xcom_proto x_proto, xcom_proto negotiated)
 
int flush_srv_buf (server *s, int64_t *ret)
 
int buffered_read_msg (connection_descriptor *rfd, srv_buf *buf, pax_msg *p, server *s, int64_t *ret)
 Reads message from connection rfd with buffering reads. More...
 
int read_msg (connection_descriptor *rfd, pax_msg *p, server *s, int64_t *ret)
 Reads message from connection rfd without buffering reads. More...
 
int send_to_acceptors (pax_msg *p, const char *dbg)
 
int send_to_all (pax_msg *p, const char *dbg)
 
int send_to_all_site (site_def const *s, pax_msg *p, const char *dbg)
 
int send_to_others (site_def const *s, pax_msg *p, const char *dbg)
 
int send_to_someone (site_def const *s, pax_msg *p, const char *dbg)
 
int send_to_self_site (site_def const *s, pax_msg *p)
 
int sender_task (task_arg arg)
 
int local_sender_task (task_arg arg)
 
int shutdown_servers ()
 
int srv_ref (server *s)
 
int srv_unref (server *s)
 
int tcp_reaper_task (task_arg arg)
 
int tcp_server (task_arg arg)
 
uint32_t crc32c_hash (char *buf, char *end)
 
int apply_xdr (xcom_proto x_proto, void *buff, uint32_t bufflen, xdrproc_t xdrfunc, void *xdrdata, enum xdr_op op)
 
void init_crc32c ()
 
void init_xcom_transport (xcom_port listen_port)
 
void reset_srv_buf (srv_buf *sb)
 
char * xcom_get_name (char *a)
 
xcom_port xcom_get_port (char *a)
 
int send_server_msg (site_def const *s, node_no i, pax_msg *p)
 
double server_active (site_def const *s, node_no i)
 
void update_servers (site_def *s, cargo_type operation)
 
void garbage_collect_servers ()
 
int client_task (task_arg arg)
 
int send_msg (server *s, node_no from, node_no to, uint32_t group_id, pax_msg *p)
 
void server_detected (server *s)
 Updates timestamp of server. More...
 
void invalidate_servers (const site_def *old_site_def, const site_def *new_site_def)
 
void shutdown_connection (connection_descriptor *con)
 
void reset_connection (connection_descriptor *con)
 
void close_connection (connection_descriptor *con)
 
void ssl_free_con (connection_descriptor *con)
 
void ssl_shutdown_con (connection_descriptor *con)
 
char const * xcom_proto_name (xcom_proto proto_vers)
 
xcom_proto negotiate_protocol (xcom_proto proto_vers)
 
void get_header_1_0 (unsigned char header_buf[], uint32_t *msgsize, x_msg_type *x_type, unsigned int *tag)
 
void put_header_1_0 (unsigned char header_buf[], uint32_t msgsize, x_msg_type x_type, unsigned int tag)
 
int send_proto (connection_descriptor *con, xcom_proto x_proto, x_msg_type x_type, unsigned int tag, int64_t *ret)
 
int recv_proto (connection_descriptor const *rfd, xcom_proto *x_proto, x_msg_type *x_type, unsigned int *tag, int64_t *ret)
 
void write_protoversion (unsigned char *buf, xcom_proto proto_vers)
 
xcom_proto read_protoversion (unsigned char *p)
 
int serialize_msg (pax_msg *p, xcom_proto x_proto, uint32_t *buflen, char **buf)
 
int deserialize_msg (pax_msg *p, xcom_proto x_proto, char *buf, uint32_t buflen)
 
xcom_proto common_xcom_version (site_def const *site)
 
xcom_proto get_latest_common_proto ()
 
xcom_proto set_latest_common_proto (xcom_proto x_proto)
 
xcom_proto minimum_ipv6_version ()
 Returns the version from which nodes are able to speak IPv6. More...
 
int get_ip_and_port (char *address, char ip[IP_MAX_SIZE], xcom_port *port)
 Get the ip and port object from a given address in the authorized input format. More...
 
int is_new_node_eligible_for_ipv6 (xcom_proto incoming_proto, const site_def *current_site_def)
 Checks if an incoming node is eligible to enter the group. More...
 

Macro Definition Documentation

◆ CONNECT_WAIT_INCREASE

#define CONNECT_WAIT_INCREASE   1.1

◆ INITIAL_CONNECT_WAIT

#define INITIAL_CONNECT_WAIT   0.1

◆ IP_MAX_SIZE

#define IP_MAX_SIZE   512

◆ LENGTH_PTR

#define LENGTH_PTR (   buf)    &((buf)[XDR_INT_SIZE])

◆ MAX_CONNECT_WAIT

#define MAX_CONNECT_WAIT   1.0

◆ MSG_HDR_SIZE

#define MSG_HDR_SIZE   (3 * XDR_INT_SIZE)

◆ MSG_PTR

#define MSG_PTR (   buf)    &((buf)[MSG_HDR_SIZE])

◆ SERIALIZED_BUFLEN

#define SERIALIZED_BUFLEN (   x)    ((x) + MSG_HDR_SIZE)

◆ VERS_PTR

#define VERS_PTR (   buf)    (buf)

◆ X_TAG

#define X_TAG   (X_TYPE + 1)

◆ X_TAG_PTR

#define X_TAG_PTR (   buf)    &((buf)[X_TAG])

◆ X_TYPE

#define X_TYPE   (2 * XDR_INT_SIZE)

◆ XDR_INT_SIZE

#define XDR_INT_SIZE   4

Typedef Documentation

◆ envelope

typedef struct envelope envelope

◆ x_msg_type

typedef enum x_msg_type x_msg_type

Enumeration Type Documentation

◆ x_msg_type

enum x_msg_type
Enumerator
x_normal 
x_version_req 
x_version_reply 

Function Documentation

◆ apply_xdr()

int apply_xdr ( xcom_proto  x_proto,
void *  buff,
uint32_t  bufflen,
xdrproc_t  xdrfunc,
void *  xdrdata,
enum xdr_op  op 
)

◆ buffered_read_msg()

int buffered_read_msg ( connection_descriptor rfd,
srv_buf buf,
pax_msg *  p,
server s,
int64_t *  ret 
)

Reads message from connection rfd with buffering reads.

Parameters
[in]rfdPointer to open connection.
[in,out]bufUsed for buffering reads.
[out]pOutput buffer.
[out]sPointer to server. Server timestamp updated if not 0.
[out]retNumber of bytes read, or -1 if failure.
Return values
0if task should terminate.
1if it should continue.

◆ check_protoversion()

int check_protoversion ( xcom_proto  x_proto,
xcom_proto  negotiated 
)

◆ client_task()

int client_task ( task_arg  arg)

◆ close_connection()

void close_connection ( connection_descriptor con)

◆ common_xcom_version()

xcom_proto common_xcom_version ( site_def const *  site)

◆ crc32c_hash()

uint32_t crc32c_hash ( char *  buf,
char *  end 
)

◆ deserialize_msg()

int deserialize_msg ( pax_msg *  p,
xcom_proto  x_proto,
char *  buf,
uint32_t  buflen 
)

◆ flush_srv_buf()

int flush_srv_buf ( server s,
int64_t *  ret 
)

◆ garbage_collect_servers()

void garbage_collect_servers ( )

◆ get_header_1_0()

void get_header_1_0 ( unsigned char  header_buf[],
uint32_t *  msgsize,
x_msg_type x_type,
unsigned int *  tag 
)

◆ get_ip_and_port()

int get_ip_and_port ( char *  address,
char  ip[IP_MAX_SIZE],
xcom_port port 
)

Get the ip and port object from a given address in the authorized input format.

For IP v4 is IP (or) NAME:PORT and for IPv6 is [IP (or) NAME]:PORT

Parameters
addressinput address to parse
ipthe resulting IP or Name
portthe resulting port
Returns
int true (1) in case of parse error

◆ get_latest_common_proto()

xcom_proto get_latest_common_proto ( )

◆ init_crc32c()

void init_crc32c ( )

◆ init_xcom_transport()

void init_xcom_transport ( xcom_port  listen_port)

◆ invalidate_servers()

void invalidate_servers ( const site_def old_site_def,
const site_def new_site_def 
)

◆ is_new_node_eligible_for_ipv6()

int is_new_node_eligible_for_ipv6 ( xcom_proto  incoming_proto,
const site_def current_site_def 
)

Checks if an incoming node is eligible to enter the group.

This function checks if a new node entering the group is able to be part of it. This is needed duw to downgrade procedures to server versions that do not speak IPv6. One wil check if:

  • Our server is being contacted by a server that has a lower version than the IPv6 baseline
  • Check if the current configuration is all reachable by an IPv4 node

If all of the above hold true we are able to proceed and add the node. Else, we must fail.

Return values
1in case of success.

◆ local_sender_task()

int local_sender_task ( task_arg  arg)

◆ minimum_ipv6_version()

xcom_proto minimum_ipv6_version ( )

Returns the version from which nodes are able to speak IPv6.

Returns
xcom_proto the version from which nodes are able to speak IPv6

◆ negotiate_protocol()

xcom_proto negotiate_protocol ( xcom_proto  proto_vers)

◆ put_header_1_0()

void put_header_1_0 ( unsigned char  header_buf[],
uint32_t  msgsize,
x_msg_type  x_type,
unsigned int  tag 
)

◆ read_msg()

int read_msg ( connection_descriptor rfd,
pax_msg *  p,
server s,
int64_t *  ret 
)

Reads message from connection rfd without buffering reads.

Parameters
[in]rfdPointer to open connection.
[out]pOutput buffer.
[in,out]sPointer to server. Server timestamp updated if not 0.
[in,out]retNumber of bytes read, or -1 if failure.
Return values
0if task should terminate.
1if it should continue.

◆ read_protoversion()

xcom_proto read_protoversion ( unsigned char *  p)

◆ recv_proto()

int recv_proto ( connection_descriptor const *  rfd,
xcom_proto x_proto,
x_msg_type x_type,
unsigned int *  tag,
int64_t *  ret 
)

◆ reset_connection()

void reset_connection ( connection_descriptor con)

◆ reset_srv_buf()

void reset_srv_buf ( srv_buf sb)

◆ send_msg()

int send_msg ( server s,
node_no  from,
node_no  to,
uint32_t  group_id,
pax_msg *  p 
)

◆ send_proto()

int send_proto ( connection_descriptor con,
xcom_proto  x_proto,
x_msg_type  x_type,
unsigned int  tag,
int64_t *  ret 
)

◆ send_server_msg()

int send_server_msg ( site_def const *  s,
node_no  i,
pax_msg *  p 
)

◆ send_to_acceptors()

int send_to_acceptors ( pax_msg *  p,
const char *  dbg 
)

◆ send_to_all()

int send_to_all ( pax_msg *  p,
const char *  dbg 
)

◆ send_to_all_site()

int send_to_all_site ( site_def const *  s,
pax_msg *  p,
const char *  dbg 
)

◆ send_to_others()

int send_to_others ( site_def const *  s,
pax_msg *  p,
const char *  dbg 
)

◆ send_to_self_site()

int send_to_self_site ( site_def const *  s,
pax_msg *  p 
)

◆ send_to_someone()

int send_to_someone ( site_def const *  s,
pax_msg *  p,
const char *  dbg 
)

◆ sender_task()

int sender_task ( task_arg  arg)

◆ serialize_msg()

int serialize_msg ( pax_msg *  p,
xcom_proto  x_proto,
uint32_t *  buflen,
char **  buf 
)

◆ server_active()

double server_active ( site_def const *  s,
node_no  i 
)

◆ server_detected()

void server_detected ( server s)

Updates timestamp of server.

Parameters
[in]sPointer to server.

◆ set_latest_common_proto()

xcom_proto set_latest_common_proto ( xcom_proto  x_proto)

◆ shutdown_connection()

void shutdown_connection ( connection_descriptor con)

◆ shutdown_servers()

int shutdown_servers ( )

◆ srv_ref()

int srv_ref ( server s)

◆ srv_unref()

int srv_unref ( server s)

◆ ssl_free_con()

void ssl_free_con ( connection_descriptor con)

◆ ssl_shutdown_con()

void ssl_shutdown_con ( connection_descriptor con)

◆ tcp_reaper_task()

int tcp_reaper_task ( task_arg  arg)

◆ tcp_server()

int tcp_server ( task_arg  arg)

◆ update_servers()

void update_servers ( site_def s,
cargo_type  operation 
)

◆ write_protoversion()

void write_protoversion ( unsigned char *  buf,
xcom_proto  proto_vers 
)

◆ xcom_get_name()

char* xcom_get_name ( char *  a)

◆ xcom_get_port()

xcom_port xcom_get_port ( char *  a)

◆ xcom_proto_name()

char const* xcom_proto_name ( xcom_proto  proto_vers)