CUBRID Engine  latest
connection_support.c File Reference
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <sys/types.h>
#include <assert.h>
#include <sys/time.h>
#include <sys/ioctl.h>
#include <sys/uio.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <unistd.h>
#include <fcntl.h>
#include <poll.h>
#include "porting.h"
#include "error_manager.h"
#include "connection_globals.h"
#include "memory_alloc.h"
#include "environment_variable.h"
#include "system_parameter.h"
#include "boot_sr.h"
#include "tcp.h"
#include "connection_list_cl.h"
#include "connection_cl.h"
#include "storage_common.h"
#include "dbtype.h"
#include "tz_support.h"
#include "db_date.h"
#include "show_scan.h"

Go to the source code of this file.

Macros

#define pthread_mutex_init(a, b)
 
#define pthread_mutex_destroy(a)
 
#define pthread_mutex_lock(b)   0
 
#define pthread_mutex_unlock(a)
 
#define INITIAL_IP_NUM   16
 
#define CSS_TRUNCATE_BUFFER_SIZE   512
 

Functions

static void css_default_server_timeout_fn (void)
 
static bool css_default_check_server_alive_fn (const char *db_name, const char *db_host)
 
static int css_sprintf_conn_infoids (SOCKET fd, const char **client_user_name, const char **client_host_name, int *client_pid)
 
static int css_send_io_vector (CSS_CONN_ENTRY *conn, struct iovec *vec_p, ssize_t total_len, int vector_length, int timeout)
 
static int css_net_send2 (CSS_CONN_ENTRY *conn, const char *buff1, int len1, const char *buff2, int len2)
 
static int css_net_send3 (CSS_CONN_ENTRY *conn, const char *buff1, int len1, const char *buff2, int len2, const char *buff3, int len3)
 
static int css_net_send4 (CSS_CONN_ENTRY *conn, const char *buff1, int len1, const char *buff2, int len2, const char *buff3, int len3, const char *buff4, int len4)
 
static int css_net_send5 (CSS_CONN_ENTRY *conn, const char *buff1, int len1, const char *buff2, int len2, const char *buff3, int len3, const char *buff4, int len4, const char *buff5, int len5)
 
static int css_net_send6 (CSS_CONN_ENTRY *conn, const char *buff1, int len1, const char *buff2, int len2, const char *buff3, int len3, const char *buff4, int len4, const char *buff5, int len5, const char *buff6, int len6)
 
static int css_net_send7 (CSS_CONN_ENTRY *conn, const char *buff1, int len1, const char *buff2, int len2, const char *buff3, int len3, const char *buff4, int len4, const char *buff5, int len5, const char *buff6, int len6, const char *buff7, int len7)
 
static int css_net_send8 (CSS_CONN_ENTRY *conn, const char *buff1, int len1, const char *buff2, int len2, const char *buff3, int len3, const char *buff4, int len4, const char *buff5, int len5, const char *buff6, int len6, const char *buff7, int len7, const char *buff8, int len8)
 
static int css_make_access_status_exist_user (THREAD_ENTRY *thread_p, OID *class_oid, LAST_ACCESS_STATUS **access_status_array, int num_user, SHOWSTMT_ARRAY_CONTEXT *ctx)
 
static LAST_ACCESS_STATUScss_get_access_status_with_name (LAST_ACCESS_STATUS **access_status_array, int num_user, const char *user_name)
 
static LAST_ACCESS_STATUScss_get_unused_access_status (LAST_ACCESS_STATUS **access_status_array, int num_user)
 
static void css_set_networking_error (SOCKET fd)
 
int css_readn (SOCKET fd, char *ptr, int nbytes, int timeout)
 
void css_read_remaining_bytes (SOCKET fd, int len)
 
int css_net_recv (SOCKET fd, char *buffer, int *maxlen, int timeout)
 
int css_vector_send (SOCKET fd, struct iovec *vec[], int *len, int bytes_written, int timeout)
 
void css_set_io_vector (struct iovec *vec1_p, struct iovec *vec2_p, const char *buff, int len, int *templen)
 
int css_send_io_vector_with_socket (SOCKET &socket, struct iovec *vec_p, ssize_t total_len, int vector_length, int timeout)
 
int css_net_send (CSS_CONN_ENTRY *conn, const char *buff, int len, int timeout)
 
int css_net_send_with_socket (SOCKET &socket, const char *buff, int len, int timeout)
 
int css_net_send3_with_socket (SOCKET &socket, const char *buff1, int len1, const char *buff2, int len2, const char *buff3, int len3)
 
int css_net_send_buffer_only (CSS_CONN_ENTRY *conn, const char *buff, int len, int timeout)
 
int css_net_read_header (SOCKET fd, char *buffer, int *maxlen, int timeout)
 
void css_set_net_header (NET_HEADER *header_p, int type, short function_code, int request_id, int buffer_size, int transaction_id, int invalidate_snapshot, int db_error)
 
int css_send_request_with_data_buffer (CSS_CONN_ENTRY *conn, int request, unsigned short *request_id, const char *arg_buffer, int arg_size, char *reply_buffer, int reply_size)
 
int css_send_request (CSS_CONN_ENTRY *conn, int command, unsigned short *request_id, const char *arg_buffer, int arg_buffer_size)
 
int css_send_request_with_socket (SOCKET &socket, int command, unsigned short *request_id, const char *arg_buffer, int arg_buffer_size)
 
int css_send_data (CSS_CONN_ENTRY *conn, unsigned short rid, const char *buffer, int buffer_size)
 
int css_send_error (CSS_CONN_ENTRY *conn, unsigned short rid, const char *buffer, int buffer_size)
 
void css_register_check_server_alive_fn (CSS_CHECK_SERVER_ALIVE_FN callback_fn)
 
const char * css_ha_server_state_string (HA_SERVER_STATE state)
 
const char * css_ha_applier_state_string (HA_LOG_APPLIER_STATE state)
 
const char * css_ha_mode_string (HA_MODE mode)
 
void css_register_server_timeout_fn (CSS_SERVER_TIMEOUT_FN callback_fn)
 
int css_send_magic (CSS_CONN_ENTRY *conn)
 
int css_send_magic_with_socket (SOCKET &socket)
 
int css_check_magic (CSS_CONN_ENTRY *conn)
 
int css_check_magic_with_socket (SOCKET fd)
 
int css_user_access_status_start_scan (THREAD_ENTRY *thread_p, int type, DB_VALUE **arg_values, int arg_cnt, void **ptr)
 
int css_platform_independent_poll (POLL_FD *fds, int num_of_fds, int timeout)
 

Variables

static int rv
 
static const int CSS_TCP_MIN_NUM_RETRIES = 3
 
static CSS_SERVER_TIMEOUT_FN css_server_timeout_fn = css_default_server_timeout_fn
 
CSS_CHECK_SERVER_ALIVE_FN css_check_server_alive_fn = css_default_check_server_alive_fn
 

Macro Definition Documentation

#define CSS_TRUNCATE_BUFFER_SIZE   512

Definition at line 103 of file connection_support.c.

Referenced by css_read_remaining_bytes().

#define INITIAL_IP_NUM   16

Definition at line 96 of file connection_support.c.

Referenced by css_register_server_timeout_fn().

#define pthread_mutex_destroy (   a)

Definition at line 90 of file connection_support.c.

#define pthread_mutex_init (   a,
 
)

Definition at line 89 of file connection_support.c.

#define pthread_mutex_lock (   b)    0

Definition at line 91 of file connection_support.c.

Referenced by css_net_recv().

#define pthread_mutex_unlock (   a)

Definition at line 92 of file connection_support.c.

Referenced by css_net_recv().

Function Documentation

int css_check_magic ( CSS_CONN_ENTRY conn)

Definition at line 2483 of file connection_support.c.

References css_check_magic_with_socket(), and css_conn_entry::fd.

Referenced by css_process_new_connection().

Here is the caller graph for this function:

int css_check_magic_with_socket ( SOCKET  fd)

Definition at line 2489 of file connection_support.c.

References css_Net_magic, css_readn(), ERROR_ON_READ, ERROR_WHEN_READING_SIZE, i, NO_ERRORS, ntohl(), p, prm_get_integer_value(), PRM_ID_TCP_CONNECTION_TIMEOUT, and WRONG_PACKET_TYPE.

Referenced by css_check_magic().

Here is the caller graph for this function:

static bool css_default_check_server_alive_fn ( const char *  db_name,
const char *  db_host 
)
static

Definition at line 2119 of file connection_support.c.

static void css_default_server_timeout_fn ( void  )
static
static LAST_ACCESS_STATUS * css_get_access_status_with_name ( LAST_ACCESS_STATUS **  access_status_array,
int  num_user,
const char *  user_name 
)
static

Definition at line 2831 of file connection_support.c.

References assert, i, and NULL.

Referenced by css_make_access_status_exist_user().

Here is the caller graph for this function:

static LAST_ACCESS_STATUS * css_get_unused_access_status ( LAST_ACCESS_STATUS **  access_status_array,
int  num_user 
)
static

Definition at line 2865 of file connection_support.c.

References i, and NULL.

Referenced by css_user_access_status_start_scan().

Here is the caller graph for this function:

const char* css_ha_mode_string ( HA_MODE  mode)
int css_net_read_header ( SOCKET  fd,
char *  buffer,
int *  maxlen,
int  timeout 
)

Definition at line 1472 of file connection_support.c.

References css_net_recv().

Referenced by css_read_header(), css_receive_data(), and css_receive_error().

Here is the caller graph for this function:

int css_net_send ( CSS_CONN_ENTRY conn,
const char *  buff,
int  len,
int  timeout 
)

Definition at line 1062 of file connection_support.c.

References css_net_send_with_socket(), and css_conn_entry::fd.

Referenced by css_abort_request(), css_connect_to_master_server(), css_send_close_request(), and css_send_request_with_data_buffer().

Here is the caller graph for this function:

static int css_net_send2 ( CSS_CONN_ENTRY conn,
const char *  buff1,
int  len1,
const char *  buff2,
int  len2 
)
static

Definition at line 1093 of file connection_support.c.

References css_send_io_vector(), and css_set_io_vector().

Referenced by css_send_data(), and css_send_error().

Here is the caller graph for this function:

static int css_net_send3 ( CSS_CONN_ENTRY conn,
const char *  buff1,
int  len1,
const char *  buff2,
int  len2,
const char *  buff3,
int  len3 
)
static

Definition at line 1123 of file connection_support.c.

References css_net_send3_with_socket(), and css_conn_entry::fd.

Referenced by css_send_request_with_data_buffer().

Here is the caller graph for this function:

int css_net_send3_with_socket ( SOCKET socket,
const char *  buff1,
int  len1,
const char *  buff2,
int  len2,
const char *  buff3,
int  len3 
)

Definition at line 1130 of file connection_support.c.

References css_send_io_vector_with_socket(), and css_set_io_vector().

Referenced by css_net_send3(), and css_send_request_with_socket().

Here is the caller graph for this function:

static int css_net_send4 ( CSS_CONN_ENTRY conn,
const char *  buff1,
int  len1,
const char *  buff2,
int  len2,
const char *  buff3,
int  len3,
const char *  buff4,
int  len4 
)
static

Definition at line 1164 of file connection_support.c.

References css_net_send5(), css_send_io_vector(), and css_set_io_vector().

Referenced by css_send_data().

Here is the caller graph for this function:

static int css_net_send5 ( CSS_CONN_ENTRY conn,
const char *  buff1,
int  len1,
const char *  buff2,
int  len2,
const char *  buff3,
int  len3,
const char *  buff4,
int  len4,
const char *  buff5,
int  len5 
)
static

Referenced by css_net_send4(), and css_send_request_with_data_buffer().

Here is the caller graph for this function:

static int css_net_send6 ( CSS_CONN_ENTRY conn,
const char *  buff1,
int  len1,
const char *  buff2,
int  len2,
const char *  buff3,
int  len3,
const char *  buff4,
int  len4,
const char *  buff5,
int  len5,
const char *  buff6,
int  len6 
)
static

Definition at line 1232 of file connection_support.c.

References css_net_send7(), css_send_io_vector(), and css_set_io_vector().

Referenced by css_send_data().

Here is the caller graph for this function:

static int css_net_send7 ( CSS_CONN_ENTRY conn,
const char *  buff1,
int  len1,
const char *  buff2,
int  len2,
const char *  buff3,
int  len3,
const char *  buff4,
int  len4,
const char *  buff5,
int  len5,
const char *  buff6,
int  len6,
const char *  buff7,
int  len7 
)
static

Referenced by css_net_send6(), and css_send_request_with_data_buffer().

Here is the caller graph for this function:

static int css_net_send8 ( CSS_CONN_ENTRY conn,
const char *  buff1,
int  len1,
const char *  buff2,
int  len2,
const char *  buff3,
int  len3,
const char *  buff4,
int  len4,
const char *  buff5,
int  len5,
const char *  buff6,
int  len6,
const char *  buff7,
int  len7,
const char *  buff8,
int  len8 
)
static

Definition at line 1309 of file connection_support.c.

References CANT_ALLOC_BUFFER, css_send_io_vector(), css_set_io_vector(), i, ntohl(), NULL, and rc.

Referenced by css_send_data().

Here is the caller graph for this function:

int css_net_send_buffer_only ( CSS_CONN_ENTRY conn,
const char *  buff,
int  len,
int  timeout 
)

Definition at line 1453 of file connection_support.c.

References css_send_io_vector().

int css_net_send_with_socket ( SOCKET socket,
const char *  buff,
int  len,
int  timeout 
)

Definition at line 1068 of file connection_support.c.

References css_send_io_vector_with_socket(), and css_set_io_vector().

Referenced by css_net_send(), css_send_magic_with_socket(), and css_send_request_with_socket().

Here is the caller graph for this function:

int css_platform_independent_poll ( POLL_FD fds,
int  num_of_fds,
int  timeout 
)

Definition at line 2891 of file connection_support.c.

References assert, LOG_SYSTEM_TRAN_INDEX, NULL_TRAN_INDEX, rc, and css_conn_entry::transaction_id.

Referenced by hb_process_master_request().

Here is the caller graph for this function:

void css_read_remaining_bytes ( SOCKET  fd,
int  len 
)

Definition at line 489 of file connection_support.c.

References css_readn(), and CSS_TRUNCATE_BUFFER_SIZE.

Referenced by css_net_recv(), css_queue_data_packet(), css_queue_error_packet(), css_receive_data(), and css_receive_error().

Here is the caller graph for this function:

void css_register_check_server_alive_fn ( CSS_CHECK_SERVER_ALIVE_FN  callback_fn)

Definition at line 2131 of file connection_support.c.

References css_check_server_alive_fn.

Referenced by cas_init().

Here is the caller graph for this function:

int css_send_data ( CSS_CONN_ENTRY conn,
unsigned short  rid,
const char *  buffer,
int  buffer_size 
)
static int css_send_io_vector ( CSS_CONN_ENTRY conn,
struct iovec *  vec_p,
ssize_t  total_len,
int  vector_length,
int  timeout 
)
static

Definition at line 1013 of file connection_support.c.

References css_send_io_vector_with_socket(), css_shutdown_conn(), css_conn_entry::fd, NO_ERRORS, and rc.

Referenced by css_net_send2(), css_net_send4(), css_net_send6(), css_net_send8(), and css_net_send_buffer_only().

Here is the caller graph for this function:

int css_send_io_vector_with_socket ( SOCKET socket,
struct iovec *  vec_p,
ssize_t  total_len,
int  vector_length,
int  timeout 
)

Definition at line 1027 of file connection_support.c.

References css_shutdown_socket(), css_vector_send(), ERROR_ON_WRITE, INVALID_SOCKET, IS_INVALID_SOCKET, NO_ERRORS, and rc.

Referenced by css_net_send3_with_socket(), css_net_send_with_socket(), and css_send_io_vector().

Here is the caller graph for this function:

int css_send_magic ( CSS_CONN_ENTRY conn)

Definition at line 2460 of file connection_support.c.

References css_send_magic_with_socket(), and css_conn_entry::fd.

Referenced by css_common_connect().

Here is the caller graph for this function:

int css_send_magic_with_socket ( SOCKET socket)

Definition at line 2466 of file connection_support.c.

References css_Net_magic, and css_net_send_with_socket().

Referenced by css_send_magic().

Here is the caller graph for this function:

int css_send_request ( CSS_CONN_ENTRY conn,
int  command,
unsigned short *  request_id,
const char *  arg_buffer,
int  arg_buffer_size 
)
int css_send_request_with_data_buffer ( CSS_CONN_ENTRY conn,
int  request,
unsigned short *  request_id,
const char *  arg_buffer,
int  arg_size,
char *  reply_buffer,
int  reply_size 
)
int css_send_request_with_socket ( SOCKET socket,
int  command,
unsigned short *  request_id,
const char *  arg_buffer,
int  arg_buffer_size 
)
void css_set_io_vector ( struct iovec *  vec1_p,
struct iovec *  vec2_p,
const char *  buff,
int  len,
int *  templen 
)

Definition at line 994 of file connection_support.c.

References htonl().

Referenced by css_net_send2(), css_net_send3_with_socket(), css_net_send4(), css_net_send6(), css_net_send8(), and css_net_send_with_socket().

Here is the caller graph for this function:

void css_set_net_header ( NET_HEADER header_p,
int  type,
short  function_code,
int  request_id,
int  buffer_size,
int  transaction_id,
int  invalidate_snapshot,
int  db_error 
)
static void css_set_networking_error ( SOCKET  fd)
static

Definition at line 249 of file connection_support.c.

References ARG_FILE_LINE, css_sprintf_conn_infoids(), ER_CSS_RECV_OR_SEND, ER_ERROR_SEVERITY, er_set_with_oserror(), ERROR_ON_WRITE, NO_ERRORS, and rc.

Referenced by css_net_recv(), css_readn(), and css_vector_send().

Here is the caller graph for this function:

static int css_sprintf_conn_infoids ( SOCKET  fd,
const char **  client_user_name,
const char **  client_host_name,
int *  client_pid 
)
static

Definition at line 173 of file connection_support.c.

References css_find_conn_from_fd(), CUB_MAXHOSTNAMELEN, GETHOSTNAME, getuserid(), L_cuserid, NULL, and pid.

Referenced by css_default_server_timeout_fn(), and css_set_networking_error().

Here is the caller graph for this function:

int css_vector_send ( SOCKET  fd,
struct iovec *  vec[],
int *  len,
int  bytes_written,
int  timeout 
)

Definition at line 893 of file connection_support.c.

References ARG_FILE_LINE, css_set_networking_error(), er_log_debug, and i.

Referenced by css_net_recv(), and css_send_io_vector_with_socket().

Here is the caller graph for this function:

Variable Documentation

CSS_SERVER_TIMEOUT_FN css_server_timeout_fn = css_default_server_timeout_fn
static

Definition at line 107 of file connection_support.c.

Referenced by css_readn(), and css_register_server_timeout_fn().

const int CSS_TCP_MIN_NUM_RETRIES = 3
static

Definition at line 102 of file connection_support.c.

int rv
static

Definition at line 93 of file connection_support.c.