CUBRID Engine  latest
connection_sr.h File Reference
#include "connection_defs.h"
#include "connection_support.h"
#include "critical_section.h"
#include "error_manager.h"
#include "porting.h"
#include "thread_compat.hpp"
#include <assert.h>
#include <pthread.h>
Include dependency graph for connection_sr.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  ip_info
 

Macros

#define IP_BYTE_COUNT   5
 
#define CSS_RWLOCK_ACTIVE_CONN_ANCHOR   (&css_Rwlock_active_conn_anchor)
 
#define CSS_RWLOCK_ACTIVE_CONN_ANCHOR_NAME   "CSS_RWLOCK_ACTIVE_CONN_ANCHOR"
 
#define START_EXCLUSIVE_ACCESS_ACTIVE_CONN_ANCHOR(r)
 
#define END_EXCLUSIVE_ACCESS_ACTIVE_CONN_ANCHOR(r)
 
#define START_SHARED_ACCESS_ACTIVE_CONN_ANCHOR(r)
 
#define END_SHARED_ACCESS_ACTIVE_CONN_ANCHOR(r)
 
#define CSS_RWLOCK_FREE_CONN_ANCHOR   (&css_Rwlock_free_conn_anchor)
 
#define CSS_RWLOCK_FREE_CONN_ANCHOR_NAME   "CSS_RWLOCK_FREE_CONN_ANCHOR"
 
#define START_EXCLUSIVE_ACCESS_FREE_CONN_ANCHOR(r)
 
#define END_EXCLUSIVE_ACCESS_FREE_CONN_ANCHOR(r)
 
#define START_SHARED_ACCESS_FREE_CONN_ANCHOR(r)
 
#define END_SHARED_ACCESS_FREE_CONN_ANCHOR(r)
 
#define CSS_LOG(msg_arg, ...)   if (prm_get_bool_value (PRM_ID_CONNECTION_LOGGING)) _er_log_debug (ARG_FILE_LINE, msg_arg "\n", __VA_ARGS__)
 
#define CSS_LOG_STACK(msg_arg, ...)   if (prm_get_bool_value (PRM_ID_CONNECTION_LOGGING)) er_print_callstack (ARG_FILE_LINE, msg_arg "\n", __VA_ARGS__)
 

Typedefs

typedef struct ip_info IP_INFO
 
typedef void * CSS_THREAD_ARG
 
typedef int(* CSS_THREAD_FN) (THREAD_ENTRY *thrd, CSS_THREAD_ARG)
 

Functions

int css_initialize_conn (CSS_CONN_ENTRY *conn, SOCKET fd)
 
void css_shutdown_conn (CSS_CONN_ENTRY *conn)
 
int css_init_conn_list (void)
 
void css_final_conn_list (void)
 
CSS_CONN_ENTRYcss_make_conn (SOCKET fd)
 
void css_insert_into_active_conn_list (CSS_CONN_ENTRY *conn)
 
void css_dealloc_conn_rmutex (CSS_CONN_ENTRY *conn)
 
int css_get_num_free_conn (void)
 
int css_increment_num_conn (BOOT_CLIENT_TYPE client_type)
 
void css_decrement_num_conn (BOOT_CLIENT_TYPE client_type)
 
void css_free_conn (CSS_CONN_ENTRY *conn)
 
void css_print_conn_entry_info (CSS_CONN_ENTRY *p)
 
void css_print_conn_list (void)
 
void css_print_free_conn_list (void)
 
CSS_CONN_ENTRYcss_connect_to_master_server (int master_port_id, const char *server_name, int name_length)
 
void css_register_handler_routines (css_error_code(*connect_handler)(CSS_CONN_ENTRY *conn), CSS_THREAD_FN request_handler, CSS_THREAD_FN connection_error_handler)
 
CSS_CONN_ENTRYcss_find_conn_by_tran_index (int tran_index)
 
CSS_CONN_ENTRYcss_find_conn_from_fd (SOCKET fd)
 
int css_get_session_ids_for_active_connections (SESSION_ID **ids, int *count)
 
void css_shutdown_conn_by_tran_index (int tran_index)
 
int css_send_abort_request (CSS_CONN_ENTRY *conn, unsigned short request_id)
 
int css_read_header (CSS_CONN_ENTRY *conn, const NET_HEADER *local_header)
 
int css_receive_request (CSS_CONN_ENTRY *conn, unsigned short *rid, int *request, int *buffer_size)
 
int css_read_and_queue (CSS_CONN_ENTRY *conn, int *type)
 
int css_receive_data (CSS_CONN_ENTRY *conn, unsigned short req_id, char **buffer, int *buffer_size, int timeout)
 
unsigned int css_return_eid_from_conn (CSS_CONN_ENTRY *conn, unsigned short rid)
 
int css_return_queued_data (CSS_CONN_ENTRY *conn, unsigned short rid, char **buffer, int *bufsize, int *rc)
 
int css_return_queued_error (CSS_CONN_ENTRY *conn, unsigned short request_id, char **buffer, int *buffer_size, int *rc)
 
int css_return_queued_request (CSS_CONN_ENTRY *conn, unsigned short *rid, int *request, int *buffer_size)
 
void css_remove_all_unexpected_packets (CSS_CONN_ENTRY *conn)
 
int css_queue_user_data_buffer (CSS_CONN_ENTRY *conn, unsigned short request_id, int size, char *buffer)
 
unsigned short css_get_request_id (CSS_CONN_ENTRY *conn)
 
int css_set_accessible_ip_info (void)
 
int css_free_accessible_ip_info (void)
 
int css_free_ip_info (IP_INFO *ip_info)
 
int css_read_ip_info (IP_INFO **out_ip_info, char *filename)
 
int css_check_ip (IP_INFO *ip_info, unsigned char *address)
 
void css_set_user_access_status (const char *db_user, const char *host, const char *program_name)
 
void css_get_user_access_status (int num_user, LAST_ACCESS_STATUS **access_status_array)
 
void css_free_user_access_status (void)
 

Variables

CSS_CONN_ENTRYcss_Conn_array
 
CSS_CONN_ENTRYcss_Active_conn_anchor
 
SYNC_RWLOCK css_Rwlock_active_conn_anchor
 
SYNC_RWLOCK css_Rwlock_free_conn_anchor
 
int css_Num_access_user
 
css_error_code(* css_Connect_handler )(CSS_CONN_ENTRY *)
 
CSS_THREAD_FN css_Request_handler
 
CSS_THREAD_FN css_Connection_error_handler
 

Macro Definition Documentation

#define CSS_LOG (   msg_arg,
  ... 
)    if (prm_get_bool_value (PRM_ID_CONNECTION_LOGGING)) _er_log_debug (ARG_FILE_LINE, msg_arg "\n", __VA_ARGS__)

Definition at line 136 of file connection_sr.h.

#define CSS_LOG_STACK (   msg_arg,
  ... 
)    if (prm_get_bool_value (PRM_ID_CONNECTION_LOGGING)) er_print_callstack (ARG_FILE_LINE, msg_arg "\n", __VA_ARGS__)
#define CSS_RWLOCK_ACTIVE_CONN_ANCHOR   (&css_Rwlock_active_conn_anchor)

Definition at line 55 of file connection_sr.h.

Referenced by css_final_conn_list(), and css_init_conn_list().

#define CSS_RWLOCK_ACTIVE_CONN_ANCHOR_NAME   "CSS_RWLOCK_ACTIVE_CONN_ANCHOR"

Definition at line 56 of file connection_sr.h.

Referenced by css_init_conn_list().

#define CSS_RWLOCK_FREE_CONN_ANCHOR   (&css_Rwlock_free_conn_anchor)

Definition at line 92 of file connection_sr.h.

Referenced by css_final_conn_list(), and css_init_conn_list().

#define CSS_RWLOCK_FREE_CONN_ANCHOR_NAME   "CSS_RWLOCK_FREE_CONN_ANCHOR"

Definition at line 93 of file connection_sr.h.

Referenced by css_init_conn_list().

#define END_EXCLUSIVE_ACCESS_ACTIVE_CONN_ANCHOR (   r)
Value:
do \
{ \
assert ((r) == NO_ERROR); \
} \
while (0)
#define rwlock_write_unlock(a)
#define NO_ERROR
Definition: error_code.h:46
#define CSS_RWLOCK_ACTIVE_CONN_ANCHOR
Definition: connection_sr.h:55
#define assert(x)
while(1)
Definition: cnvlex.c:816

Definition at line 66 of file connection_sr.h.

Referenced by css_block_all_active_conn(), css_free_conn(), css_insert_into_active_conn_list(), and css_shutdown_conn_by_tran_index().

#define END_EXCLUSIVE_ACCESS_FREE_CONN_ANCHOR (   r)
Value:
do \
{ \
assert ((r) == NO_ERROR); \
} \
while (0)
#define rwlock_write_unlock(a)
#define NO_ERROR
Definition: error_code.h:46
#define assert(x)
#define CSS_RWLOCK_FREE_CONN_ANCHOR
Definition: connection_sr.h:92
while(1)
Definition: cnvlex.c:816

Definition at line 103 of file connection_sr.h.

Referenced by css_dealloc_conn(), and css_make_conn().

#define END_SHARED_ACCESS_ACTIVE_CONN_ANCHOR (   r)
Value:
do \
{ \
assert ((r) == NO_ERROR); \
} \
while (0)
#define NO_ERROR
Definition: error_code.h:46
#define CSS_RWLOCK_ACTIVE_CONN_ANCHOR
Definition: connection_sr.h:55
#define assert(x)
while(1)
Definition: cnvlex.c:816
#define rwlock_read_unlock(a)

Definition at line 82 of file connection_sr.h.

Referenced by css_find_conn_by_tran_index(), css_find_conn_from_fd(), css_get_session_ids_for_active_connections(), css_print_conn_list(), and session_get_session_tz_region().

#define END_SHARED_ACCESS_FREE_CONN_ANCHOR (   r)
Value:
do \
{ \
assert ((r) == NO_ERROR); \
} \
while (0)
#define NO_ERROR
Definition: error_code.h:46
#define assert(x)
#define CSS_RWLOCK_FREE_CONN_ANCHOR
Definition: connection_sr.h:92
while(1)
Definition: cnvlex.c:816
#define rwlock_read_unlock(a)

Definition at line 119 of file connection_sr.h.

Referenced by css_print_free_conn_list().

#define IP_BYTE_COUNT   5

Definition at line 41 of file connection_sr.h.

#define START_EXCLUSIVE_ACCESS_ACTIVE_CONN_ANCHOR (   r)
Value:
do \
{ \
assert ((r) == NO_ERROR); \
} \
while (0)
#define NO_ERROR
Definition: error_code.h:46
#define CSS_RWLOCK_ACTIVE_CONN_ANCHOR
Definition: connection_sr.h:55
#define assert(x)
#define rwlock_write_lock(a)
while(1)
Definition: cnvlex.c:816

Definition at line 58 of file connection_sr.h.

Referenced by css_block_all_active_conn(), css_free_conn(), css_insert_into_active_conn_list(), and css_shutdown_conn_by_tran_index().

#define START_EXCLUSIVE_ACCESS_FREE_CONN_ANCHOR (   r)
Value:
do \
{ \
assert ((r) == NO_ERROR); \
} \
while (0)
#define NO_ERROR
Definition: error_code.h:46
#define assert(x)
#define rwlock_write_lock(a)
#define CSS_RWLOCK_FREE_CONN_ANCHOR
Definition: connection_sr.h:92
while(1)
Definition: cnvlex.c:816

Definition at line 95 of file connection_sr.h.

Referenced by css_dealloc_conn(), and css_make_conn().

#define START_SHARED_ACCESS_ACTIVE_CONN_ANCHOR (   r)
Value:
do \
{ \
assert ((r) == NO_ERROR); \
} \
while (0)
#define NO_ERROR
Definition: error_code.h:46
#define CSS_RWLOCK_ACTIVE_CONN_ANCHOR
Definition: connection_sr.h:55
#define assert(x)
#define rwlock_read_lock(a)
while(1)
Definition: cnvlex.c:816

Definition at line 74 of file connection_sr.h.

Referenced by css_find_conn_by_tran_index(), css_find_conn_from_fd(), css_get_session_ids_for_active_connections(), css_print_conn_list(), and session_get_session_tz_region().

#define START_SHARED_ACCESS_FREE_CONN_ANCHOR (   r)
Value:
do \
{ \
assert ((r) == NO_ERROR); \
} \
while (0)
#define NO_ERROR
Definition: error_code.h:46
#define assert(x)
#define rwlock_read_lock(a)
#define CSS_RWLOCK_FREE_CONN_ANCHOR
Definition: connection_sr.h:92
while(1)
Definition: cnvlex.c:816

Definition at line 111 of file connection_sr.h.

Referenced by css_print_free_conn_list().

Typedef Documentation

typedef void* CSS_THREAD_ARG

Definition at line 129 of file connection_sr.h.

typedef int(* CSS_THREAD_FN) (THREAD_ENTRY *thrd, CSS_THREAD_ARG)

Definition at line 130 of file connection_sr.h.

typedef struct ip_info IP_INFO

Definition at line 43 of file connection_sr.h.

Function Documentation

int css_check_ip ( IP_INFO ip_info,
unsigned char *  address 
)

Referenced by css_notify_ha_log_applier_state(), and css_register_server_timeout_fn().

Here is the caller graph for this function:

CSS_CONN_ENTRY* css_connect_to_master_server ( int  master_port_id,
const char *  server_name,
int  name_length 
)

Definition at line 861 of file connection_cl.c.

void css_dealloc_conn_rmutex ( CSS_CONN_ENTRY conn)

Definition at line 640 of file connection_sr.c.

References rmutex_finalize.

Referenced by css_refuse_connection_request().

Here is the caller graph for this function:

void css_decrement_num_conn ( BOOT_CLIENT_TYPE  client_type)

Definition at line 843 of file connection_sr.c.

References css_Conn_rule_lock, css_Conn_rules, css_Conn_rules_size, css_decrement_num_conn_internal(), DB_CLIENT_TYPE_UNKNOWN, i, pthread_mutex_lock, and pthread_mutex_unlock.

Referenced by css_free_conn().

Here is the caller graph for this function:

CSS_CONN_ENTRY* css_find_conn_by_tran_index ( int  tran_index)
CSS_CONN_ENTRY* css_find_conn_from_fd ( SOCKET  fd)
int css_free_accessible_ip_info ( void  )

Referenced by boot_server_all_finalize(), and css_notify_ha_log_applier_state().

Here is the caller graph for this function:

int css_free_ip_info ( IP_INFO ip_info)

Referenced by css_notify_ha_log_applier_state(), and css_register_server_timeout_fn().

Here is the caller graph for this function:

void css_free_user_access_status ( void  )

Definition at line 3082 of file connection_sr.c.

References CSECT_ACCESS_STATUS, csect_enter, csect_exit, css_Access_status_anchor, css_Num_access_user, free_and_init, INF_WAIT, last_access_status::next, and NULL.

Referenced by net_server_start().

Here is the caller graph for this function:

int css_get_num_free_conn ( void  )

Definition at line 674 of file connection_sr.c.

References css_Num_free_conn.

unsigned short css_get_request_id ( CSS_CONN_ENTRY conn)
int css_get_session_ids_for_active_connections ( SESSION_ID **  ids,
int *  count 
)
void css_get_user_access_status ( int  num_user,
LAST_ACCESS_STATUS **  access_status_array 
)

Definition at line 3060 of file connection_sr.c.

References CSECT_ACCESS_STATUS, csect_enter_as_reader, csect_exit, i, INF_WAIT, last_access_status::next, and NULL.

Referenced by css_user_access_status_start_scan().

Here is the caller graph for this function:

int css_increment_num_conn ( BOOT_CLIENT_TYPE  client_type)

Definition at line 817 of file connection_sr.c.

References css_Conn_rule_lock, css_Conn_rules, css_Conn_rules_size, css_increment_num_conn_internal(), error(), i, NO_ERROR, pthread_mutex_lock, and pthread_mutex_unlock.

Referenced by server_ping_with_handshake().

Here is the caller graph for this function:

void css_print_conn_entry_info ( CSS_CONN_ENTRY p)

Definition at line 928 of file connection_sr.c.

References css_conn_entry::client_id, css_conn_entry::fd, css_conn_entry::next, and css_conn_entry::request_id.

Referenced by css_print_conn_list(), and css_print_free_conn_list().

Here is the caller graph for this function:

int css_read_and_queue ( CSS_CONN_ENTRY conn,
int *  type 
)
int css_read_ip_info ( IP_INFO **  out_ip_info,
char *  filename 
)

Referenced by css_notify_ha_log_applier_state(), and css_register_server_timeout_fn().

Here is the caller graph for this function:

int css_receive_request ( CSS_CONN_ENTRY conn,
unsigned short *  rid,
int *  request,
int *  buffer_size 
)

Definition at line 455 of file connection_cl.c.

References css_read_one_request(), css_return_queued_request(), rc, TRACE, and WRONG_PACKET_TYPE.

Referenced by css_internal_request_handler(), css_process_info_request(), and css_process_new_connection().

Here is the caller graph for this function:

void css_register_handler_routines ( css_error_code(*)(CSS_CONN_ENTRY *conn)  connect_handler,
CSS_THREAD_FN  request_handler,
CSS_THREAD_FN  connection_error_handler 
)

Definition at line 1022 of file connection_sr.c.

References css_Connect_handler, css_Connection_error_handler, and css_Request_handler.

Referenced by css_initialize_server_interfaces().

Here is the caller graph for this function:

unsigned int css_return_eid_from_conn ( CSS_CONN_ENTRY conn,
unsigned short  rid 
)

Definition at line 1596 of file connection_sr.c.

References css_make_eid().

int css_return_queued_data ( CSS_CONN_ENTRY conn,
unsigned short  rid,
char **  buffer,
int *  bufsize,
int *  rc 
)

Definition at line 2832 of file connection_sr.c.

References css_return_queued_data_timeout().

int css_send_abort_request ( CSS_CONN_ENTRY conn,
unsigned short  request_id 
)
int css_set_accessible_ip_info ( void  )

Referenced by boot_restart_server(), css_notify_ha_log_applier_state(), and sysprm_change_parameter_values().

Here is the caller graph for this function:

void css_set_user_access_status ( const char *  db_user,
const char *  host,
const char *  program_name 
)
void css_shutdown_conn ( CSS_CONN_ENTRY conn)

Definition at line 127 of file connection_cl.c.

void css_shutdown_conn_by_tran_index ( int  tran_index)

Variable Documentation

CSS_CONN_ENTRY* css_Conn_array
CSS_THREAD_FN css_Connection_error_handler

Definition at line 150 of file connection_sr.c.

Referenced by css_register_handler_routines().

int css_Num_access_user
CSS_THREAD_FN css_Request_handler

Definition at line 147 of file connection_sr.c.

Referenced by css_register_handler_routines().

SYNC_RWLOCK css_Rwlock_active_conn_anchor

Definition at line 137 of file connection_sr.c.

SYNC_RWLOCK css_Rwlock_free_conn_anchor

Definition at line 138 of file connection_sr.c.