CUBRID Engine  latest
shard_proxy_io.h File Reference
#include <fcntl.h>
#include <netdb.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <sys/time.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include "broker_recv_fd.h"
#include "cas_network.h"
#include "shard_proxy_common.h"
#include "shard_metadata.h"
Include dependency graph for shard_proxy_io.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define CLOSESOCKET(fd)   close(fd)
 
#define READSOCKET(fd, buf, len)   read(fd, buf, (size_t)len)
 
#define WRITESOCKET(fd, buf, len)   write(fd, buf, (size_t)len)
 
#define DEFAULT_POLL_INTERVAL   1
 
#define PROTOCOL_SIZE   sizeof(int)
 
#define PROXY_CONNECTION_REPLY_SIZE(con_reply_size)   (PROTOCOL_SIZE + CAS_INFO_SIZE + (con_reply_size))
 
#define SHARD_TEMPORARY_UNAVAILABLE   (-1)
 
#define PROXY_IO_FROM_CAS   (true)
 
#define PROXY_IO_FROM_CLIENT   (false)
 
#define PROXY_CONV_ERR_TO_NEW   (true)
 
#define PROXY_CONV_ERR_TO_OLD   (false)
 

Functions

void set_data_length (char *buffer, int length)
 
int get_data_length (char *buffer)
 
int get_msg_length (char *buffer)
 
char * proxy_dup_msg (char *msg)
 
void proxy_set_con_status_in_tran (char *msg)
 
void proxy_set_con_status_out_tran (char *msg)
 
void proxy_set_force_out_tran (char *msg)
 
void proxy_unset_force_out_tran (char *msg)
 
int proxy_make_net_buf (T_NET_BUF *net_buf, int size, T_BROKER_VERSION client_version)
 
int proxy_io_make_error_msg (char *driver_info, char **buffer, int error_ind, int error_code, const char *error_msg, char is_in_tran)
 
int proxy_io_make_no_error (char *driver_info, char **buffer)
 
int proxy_io_make_con_close_ok (char *driver_info, char **buffer)
 
int proxy_io_make_end_tran_ok (char *driver_info, char **buffer)
 
int proxy_io_make_check_cas_ok (char *driver_info, char **buffer)
 
int proxy_io_make_set_db_parameter_ok (char *driver_info, char **buffer)
 
int proxy_io_make_ex_get_isolation_level (char *driver_info, char **buffer, void *argv)
 
int proxy_io_make_ex_get_lock_timeout (char *driver_info, char **buffer, void *argv)
 
int proxy_io_make_end_tran_request (char *driver_info, char **buffer, bool commit)
 
int proxy_io_make_end_tran_abort (char *driver_info, char **buffer)
 
int proxy_io_make_close_req_handle_ok (char *driver_info, char **buffer, bool is_in_tran)
 
int proxy_io_make_close_req_handle_out_tran_ok (char *driver_info, char **buffer)
 
int proxy_io_make_cursor_close_out_tran_ok (char *driver_info, char **buffer)
 
int proxy_io_make_get_db_version (char *driver_info, char **buffer)
 
int proxy_io_make_client_conn_ok (char *driver_info, char **buffer)
 
int proxy_io_make_client_proxy_alive (char *driver_info, char **buffer)
 
int proxy_io_make_client_dbinfo_ok (char *driver_info, char **buffer)
 
int proxy_io_make_client_acl_fail (char *driver_info, char **buffer)
 
int proxy_io_make_shard_info (char *driver_info, char **buffer)
 
int proxy_io_make_check_cas (char *driver_info, char **buffer)
 
int proxy_socket_set_write_event (T_SOCKET_IO *sock_io_p, T_PROXY_EVENT *event_p)
 
void proxy_io_buffer_clear (T_IO_BUFFER *io_buffer)
 
void proxy_socket_io_print (bool print_all)
 
void proxy_client_io_print (bool print_all)
 
char * proxy_str_client_io (T_CLIENT_IO *cli_io_p)
 
void proxy_shard_io_print (bool print_all)
 
char * proxy_str_cas_io (T_CAS_IO *cas_io_p)
 
void proxy_client_io_free (T_CLIENT_IO *cli_io_p)
 
void proxy_client_io_free_by_ctx (int client_id, int ctx_cid, int ctx_uid)
 
T_CLIENT_IOproxy_client_io_find_by_ctx (int client_id, int ctx_cid, unsigned int ctx_uid)
 
T_CLIENT_IOproxy_client_io_find_by_fd (int client_id, SOCKET fd)
 
int proxy_client_io_write (T_CLIENT_IO *cli_io_p, T_PROXY_EVENT *event_p)
 
void proxy_cas_io_free_by_ctx (int shard_id, int cas_id, int ctx_cid, unsigned int ctx_uid)
 
T_CAS_IOproxy_cas_find_io_by_ctx (int shard_id, int cas_id, int ctx_cid, unsigned int ctx_uid)
 
T_CAS_IOproxy_cas_alloc_by_ctx (int client_id, int shard_id, int cas_id, int ctx_cid, unsigned int ctx_uid, int timeout, int func_code)
 
void proxy_cas_release_by_ctx (int shard_id, int cas_id, int ctx_cid, unsigned int ctx_uid)
 
int proxy_cas_io_write (T_CAS_IO *cas_io_p, T_PROXY_EVENT *event_p)
 
int proxy_io_close_all_fd (void)
 
int proxy_io_process (void)
 
int proxy_io_initialize (void)
 
void proxy_io_destroy (void)
 
int proxy_socket_io_delete (SOCKET fd)
 
int proxy_io_set_established_by_ctx (T_PROXY_CONTEXT *ctx_p)
 
char * proxy_get_driver_info_by_ctx (T_PROXY_CONTEXT *ctx_p)
 
char * proxy_get_driver_info_by_fd (T_SOCKET_IO *sock_io_p)
 
void proxy_available_cas_wait_timer (void)
 
int proxy_convert_error_code (int error_ind, int error_code, char *driver_info, T_BROKER_VERSION client_version, bool to_new)
 

Variables

fd_set rset
 
fd_set wset
 
fd_set allset
 
fd_set wnewset
 
fd_set wallset
 
int maxfd
 
T_CLIENT_IO_GLOBAL proxy_Client_io
 
T_SHARD_IO_GLOBAL proxy_Shard_io
 

Macro Definition Documentation

#define CLOSESOCKET (   fd)    close(fd)
#define DEFAULT_POLL_INTERVAL   1

Definition at line 54 of file shard_proxy_io.h.

#define PROTOCOL_SIZE   sizeof(int)

Definition at line 64 of file shard_proxy_io.h.

Referenced by proxy_io_make_client_dbinfo_ok().

#define PROXY_CONNECTION_REPLY_SIZE (   con_reply_size)    (PROTOCOL_SIZE + CAS_INFO_SIZE + (con_reply_size))

Definition at line 65 of file shard_proxy_io.h.

Referenced by proxy_io_make_client_dbinfo_ok().

#define PROXY_CONV_ERR_TO_NEW   (true)

Definition at line 71 of file shard_proxy_io.h.

Referenced by proxy_convert_error_code(), and proxy_is_invalid_statement().

#define PROXY_CONV_ERR_TO_OLD   (false)

Definition at line 72 of file shard_proxy_io.h.

Referenced by proxy_io_make_error_msg().

#define PROXY_IO_FROM_CAS   (true)

Definition at line 69 of file shard_proxy_io.h.

Referenced by proxy_io_process().

#define PROXY_IO_FROM_CLIENT   (false)

Definition at line 70 of file shard_proxy_io.h.

Referenced by proxy_socket_io_new_client().

#define READSOCKET (   fd,
  buf,
  len 
)    read(fd, buf, (size_t)len)

Definition at line 50 of file shard_proxy_io.h.

Referenced by proxy_socket_io_read_internal().

#define WRITESOCKET (   fd,
  buf,
  len 
)    write(fd, buf, (size_t)len)

Function Documentation

int get_data_length ( char *  buffer)

Definition at line 238 of file shard_proxy_io.c.

References assert, and ntohl().

Referenced by get_msg_length(), and proxy_handler_process_client_request().

Here is the caller graph for this function:

void proxy_available_cas_wait_timer ( void  )
T_CAS_IO* proxy_cas_find_io_by_ctx ( int  shard_id,
int  cas_id,
int  ctx_cid,
unsigned int  ctx_uid 
)
void proxy_cas_io_free_by_ctx ( int  shard_id,
int  cas_id,
int  ctx_cid,
unsigned int  ctx_uid 
)
T_CLIENT_IO* proxy_client_io_find_by_ctx ( int  client_id,
int  ctx_cid,
unsigned int  ctx_uid 
)
T_CLIENT_IO* proxy_client_io_find_by_fd ( int  client_id,
SOCKET  fd 
)
void proxy_client_io_free_by_ctx ( int  client_id,
int  ctx_cid,
int  ctx_uid 
)

Definition at line 3083 of file shard_proxy_io.c.

References NULL, proxy_client_io_find_by_ctx(), and proxy_client_io_free().

Referenced by proxy_context_free_client().

Here is the caller graph for this function:

void proxy_client_io_print ( bool  print_all)

Referenced by proxy_client_io_destroy(), and proxy_client_io_new().

Here is the caller graph for this function:

int proxy_client_io_write ( T_CLIENT_IO cli_io_p,
T_PROXY_EVENT event_p 
)
char* proxy_dup_msg ( char *  msg)

Definition at line 440 of file shard_proxy_io.c.

References get_msg_length(), and p.

Referenced by fn_proxy_cas_prepare(), proxy_client_execute_internal(), proxy_send_prepared_stmt_to_client(), and shard_stmt_save_prepare_request().

Here is the caller graph for this function:

void proxy_io_buffer_clear ( T_IO_BUFFER io_buffer)

Definition at line 1123 of file shard_proxy_io.c.

References assert, t_io_buffer::data, FREE_MEM, t_io_buffer::length, and t_io_buffer::offset.

Referenced by proxy_event_free().

Here is the caller graph for this function:

int proxy_io_close_all_fd ( void  )

Definition at line 4254 of file shard_proxy_io.c.

References broker_conn_fd, cas_lsnr_fd, CLOSE_SOCKET, t_socket_io_global::ent, t_socket_io::fd, i, INVALID_SOCKET, and t_socket_io_global::max_socket.

Referenced by proxy_io_destroy().

Here is the caller graph for this function:

void proxy_io_destroy ( void  )

Definition at line 4239 of file shard_proxy_io.c.

References FREE_MEM, proxy_client_io_destroy(), proxy_io_close_all_fd(), proxy_shard_io_destroy(), and proxy_socket_io_destroy().

Referenced by proxy_term().

Here is the caller graph for this function:

int proxy_io_make_check_cas ( char *  driver_info,
char **  buffer 
)
int proxy_io_make_check_cas_ok ( char *  driver_info,
char **  buffer 
)

Definition at line 682 of file shard_proxy_io.c.

References proxy_io_make_no_error().

Referenced by fn_proxy_client_check_cas().

Here is the caller graph for this function:

int proxy_io_make_client_acl_fail ( char *  driver_info,
char **  buffer 
)
int proxy_io_make_client_conn_ok ( char *  driver_info,
char **  buffer 
)

Definition at line 878 of file shard_proxy_io.c.

References NULL.

Referenced by proxy_socket_io_new_client().

Here is the caller graph for this function:

int proxy_io_make_client_proxy_alive ( char *  driver_info,
char **  buffer 
)
int proxy_io_make_close_req_handle_out_tran_ok ( char *  driver_info,
char **  buffer 
)

Definition at line 820 of file shard_proxy_io.c.

References proxy_io_make_close_req_handle_ok().

Referenced by fn_proxy_client_close_req_handle().

Here is the caller graph for this function:

int proxy_io_make_con_close_ok ( char *  driver_info,
char **  buffer 
)

Definition at line 670 of file shard_proxy_io.c.

References proxy_io_make_no_error().

Referenced by fn_proxy_cas_end_tran(), and fn_proxy_client_con_close().

Here is the caller graph for this function:

int proxy_io_make_cursor_close_out_tran_ok ( char *  driver_info,
char **  buffer 
)

Definition at line 826 of file shard_proxy_io.c.

References proxy_io_make_close_req_handle_ok().

Referenced by fn_proxy_client_cursor_close().

Here is the caller graph for this function:

int proxy_io_make_end_tran_abort ( char *  driver_info,
char **  buffer 
)

Definition at line 759 of file shard_proxy_io.c.

References proxy_io_make_end_tran_request().

Referenced by fn_proxy_client_con_close(), and fn_proxy_client_conn_error().

Here is the caller graph for this function:

int proxy_io_make_end_tran_ok ( char *  driver_info,
char **  buffer 
)

Definition at line 676 of file shard_proxy_io.c.

References proxy_io_make_no_error().

Referenced by fn_proxy_client_end_tran().

Here is the caller graph for this function:

int proxy_io_make_ex_get_isolation_level ( char *  driver_info,
char **  buffer,
void *  argv 
)

Definition at line 694 of file shard_proxy_io.c.

References proxy_io_make_ex_get_int().

Referenced by fn_proxy_client_get_db_parameter().

Here is the caller graph for this function:

int proxy_io_make_ex_get_lock_timeout ( char *  driver_info,
char **  buffer,
void *  argv 
)

Definition at line 700 of file shard_proxy_io.c.

References proxy_io_make_ex_get_int().

Referenced by fn_proxy_client_get_db_parameter().

Here is the caller graph for this function:

int proxy_io_make_get_db_version ( char *  driver_info,
char **  buffer 
)
int proxy_io_make_no_error ( char *  driver_info,
char **  buffer 
)

Definition at line 664 of file shard_proxy_io.c.

References CAS_NO_ERROR, NULL, and proxy_io_make_error_msg().

Referenced by proxy_io_make_check_cas_ok(), proxy_io_make_con_close_ok(), proxy_io_make_end_tran_ok(), and proxy_io_make_set_db_parameter_ok().

Here is the caller graph for this function:

int proxy_io_make_set_db_parameter_ok ( char *  driver_info,
char **  buffer 
)

Definition at line 688 of file shard_proxy_io.c.

References proxy_io_make_no_error().

Referenced by fn_proxy_client_set_db_parameter().

Here is the caller graph for this function:

void proxy_set_con_status_in_tran ( char *  msg)

Definition at line 457 of file shard_proxy_io.c.

References assert, CAS_INFO_STATUS, CAS_INFO_STATUS_ACTIVE, and MSG_HEADER_INFO_SIZE.

Referenced by fn_proxy_cas_prepare(), fn_proxy_client_check_cas(), and proxy_io_make_error_msg().

Here is the caller graph for this function:

void proxy_set_con_status_out_tran ( char *  msg)
void proxy_set_force_out_tran ( char *  msg)

Definition at line 485 of file shard_proxy_io.c.

References assert, CAS_INFO_ADDITIONAL_FLAG, CAS_INFO_FLAG_MASK_FORCE_OUT_TRAN, and MSG_HEADER_INFO_SIZE.

Referenced by fn_proxy_client_check_cas(), fn_proxy_client_prepare(), and proxy_io_make_check_cas().

Here is the caller graph for this function:

void proxy_shard_io_print ( bool  print_all)

Referenced by proxy_cas_io_new(), and proxy_shard_io_destroy().

Here is the caller graph for this function:

void proxy_socket_io_print ( bool  print_all)

Referenced by proxy_socket_io_add(), and proxy_socket_io_destroy().

Here is the caller graph for this function:

int proxy_socket_set_write_event ( T_SOCKET_IO sock_io_p,
T_PROXY_EVENT event_p 
)
char* proxy_str_client_io ( T_CLIENT_IO cli_io_p)
void proxy_unset_force_out_tran ( char *  msg)

Definition at line 499 of file shard_proxy_io.c.

References assert, CAS_INFO_ADDITIONAL_FLAG, CAS_INFO_FLAG_MASK_FORCE_OUT_TRAN, and MSG_HEADER_INFO_SIZE.

Referenced by proxy_client_execute_internal(), and proxy_handler_process_client_request().

Here is the caller graph for this function:

Variable Documentation

T_CLIENT_IO_GLOBAL proxy_Client_io

Definition at line 204 of file shard_proxy_io.c.

T_SHARD_IO_GLOBAL proxy_Shard_io

Definition at line 205 of file shard_proxy_io.c.

fd_set rset

Definition at line 191 of file shard_proxy_io.c.

Referenced by proxy_io_process(), and proxy_listener_thr_f().

fd_set wallset

Definition at line 191 of file shard_proxy_io.c.

Referenced by proxy_io_process().

fd_set wset

Definition at line 191 of file shard_proxy_io.c.

Referenced by proxy_io_process().