CUBRID Engine  latest
master.c File Reference
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <time.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/time.h>
#include <netdb.h>
#include <sys/param.h>
#include <sys/resource.h>
#include <netinet/in.h>
#include <unistd.h>
#include <fcntl.h>
#include <syslog.h>
#include <pthread.h>
#include "utility.h"
#include "porting.h"
#include "error_manager.h"
#include "connection_globals.h"
#include "connection_cl.h"
#include "tcp.h"
#include "master_util.h"
#include "master_request.h"
#include "master_heartbeat.h"
#include "environment_variable.h"
#include "message_catalog.h"
#include "dbi.h"
#include "util_func.h"

Go to the source code of this file.

Functions

static void css_master_error (const char *error_string)
 
static int css_master_timeout (void)
 
static int css_master_init (int cport, SOCKET *clientfd)
 
static void css_reject_client_request (CSS_CONN_ENTRY *conn, unsigned short rid, int reason)
 
static void css_reject_server_request (CSS_CONN_ENTRY *conn, int reason)
 
static void css_accept_server_request (CSS_CONN_ENTRY *conn, int reason)
 
static void css_accept_new_request (CSS_CONN_ENTRY *conn, unsigned short rid, char *server_name, int server_name_length)
 
static void css_accept_old_request (CSS_CONN_ENTRY *conn, unsigned short rid, SOCKET_QUEUE_ENTRY *entry, char *server_name, int server_name_length)
 
static void css_register_new_server (CSS_CONN_ENTRY *conn, unsigned short rid)
 
static void css_register_new_server2 (CSS_CONN_ENTRY *conn, unsigned short rid)
 
static bool css_send_new_request_to_server (SOCKET server_fd, SOCKET client_fd, unsigned short rid, CSS_SERVER_REQUEST request)
 
static void css_send_to_existing_server (CSS_CONN_ENTRY *conn, unsigned short rid, CSS_SERVER_REQUEST request)
 
static void css_process_new_connection (SOCKET fd)
 
static int css_enroll_read_sockets (SOCKET_QUEUE_ENTRY *anchor_p, fd_set *fd_var)
 
static int css_enroll_write_sockets (SOCKET_QUEUE_ENTRY *anchor_p, fd_set *fd_var)
 
static int css_enroll_exception_sockets (SOCKET_QUEUE_ENTRY *anchor_p, fd_set *fd_var)
 
static int css_enroll_master_read_sockets (fd_set *fd_var)
 
static int css_enroll_master_write_sockets (fd_set *fd_var)
 
static int css_enroll_master_exception_sockets (fd_set *fd_var)
 
static void css_master_select_error (void)
 
static void css_check_master_socket_input (int *count, fd_set *fd_var)
 
static void css_check_master_socket_output (void)
 
static int css_check_master_socket_exception (fd_set *fd_var)
 
static void css_master_loop (void)
 
static void css_free_entry (SOCKET_QUEUE_ENTRY *entry_p)
 
static void css_daemon_start (void)
 
void css_master_cleanup (int sig)
 
int main (int argc, char **argv)
 
void css_remove_entry_by_conn (CSS_CONN_ENTRY *conn_p, SOCKET_QUEUE_ENTRY **anchor_p)
 
SOCKET_QUEUE_ENTRYcss_add_request_to_socket_queue (CSS_CONN_ENTRY *conn_p, int info_p, char *name_p, SOCKET fd, int fd_type, int pid, SOCKET_QUEUE_ENTRY **anchor_p)
 
SOCKET_QUEUE_ENTRYcss_return_entry_of_server (char *name_p, SOCKET_QUEUE_ENTRY *anchor_p)
 
SOCKET_QUEUE_ENTRYcss_return_entry_by_conn (CSS_CONN_ENTRY *conn_p, SOCKET_QUEUE_ENTRY **anchor_p)
 

Variables

struct timeval * css_Master_timeout = NULL
 
int css_Master_timeout_value_in_seconds = 4
 
int css_Master_timeout_value_in_microseconds = 500
 
time_t css_Start_time
 
int css_Total_request_count = 0
 
SOCKET css_Master_socket_fd [2] = { INVALID_SOCKET, INVALID_SOCKET }
 
SOCKET_QUEUE_ENTRYcss_Master_socket_anchor = NULL
 
pthread_mutex_t css_Master_socket_anchor_lock
 
pthread_mutex_t css_Master_er_log_lock = PTHREAD_MUTEX_INITIALIZER
 
pthread_mutex_t css_Master_er_log_enable_lock = PTHREAD_MUTEX_INITIALIZER
 
bool css_Master_er_log_enabled = true
 

Function Documentation

static void css_accept_new_request ( CSS_CONN_ENTRY conn,
unsigned short  rid,
char *  server_name,
int  server_name_length 
)
static
static void css_accept_old_request ( CSS_CONN_ENTRY conn,
unsigned short  rid,
SOCKET_QUEUE_ENTRY entry,
char *  server_name,
int  server_name_length 
)
static
static void css_accept_server_request ( CSS_CONN_ENTRY conn,
int  reason 
)
static

Definition at line 309 of file master.c.

References css_conn_entry::fd, and htonl().

Referenced by css_accept_new_request(), css_accept_old_request(), css_register_new_server(), and css_register_new_server2().

Here is the caller graph for this function:

static void css_check_master_socket_input ( int *  count,
fd_set *  fd_var 
)
static
static void css_check_master_socket_output ( void  )
static

Definition at line 1004 of file master.c.

Referenced by css_master_loop().

Here is the caller graph for this function:

static void css_daemon_start ( void  )
static

Definition at line 1453 of file master.c.

References ARG_FILE_LINE, css_get_max_socket_fds(), ER_WARNING_SEVERITY, ERR_CSS_CANNOT_FORK, MASTER_ER_SET, and os_set_signal_handler().

Referenced by main().

Here is the caller graph for this function:

static int css_enroll_exception_sockets ( SOCKET_QUEUE_ENTRY anchor_p,
fd_set *  fd_var 
)
static

Definition at line 854 of file master.c.

References socket_queue_entry::fd, IS_INVALID_SOCKET, and socket_queue_entry::next.

Referenced by css_enroll_master_exception_sockets().

Here is the caller graph for this function:

static int css_enroll_master_exception_sockets ( fd_set *  fd_var)
static

Definition at line 881 of file master.c.

References css_enroll_exception_sockets().

Referenced by css_master_loop().

Here is the caller graph for this function:

static int css_enroll_master_read_sockets ( fd_set *  fd_var)
static

Definition at line 813 of file master.c.

References css_enroll_read_sockets().

Referenced by css_master_loop().

Here is the caller graph for this function:

static int css_enroll_master_write_sockets ( fd_set *  fd_var)
static

Definition at line 840 of file master.c.

References css_enroll_write_sockets().

Referenced by css_master_loop().

Here is the caller graph for this function:

static int css_enroll_read_sockets ( SOCKET_QUEUE_ENTRY anchor_p,
fd_set *  fd_var 
)
static

Definition at line 785 of file master.c.

References socket_queue_entry::fd, socket_queue_entry::fd_type, IS_INVALID_SOCKET, socket_queue_entry::next, and WRITE_ONLY.

Referenced by css_enroll_master_read_sockets().

Here is the caller graph for this function:

static int css_enroll_write_sockets ( SOCKET_QUEUE_ENTRY anchor_p,
fd_set *  fd_var 
)
static

Definition at line 827 of file master.c.

Referenced by css_enroll_master_write_sockets().

Here is the caller graph for this function:

static void css_free_entry ( SOCKET_QUEUE_ENTRY entry_p)
static
static void css_master_error ( const char *  error_string)
static

Definition at line 141 of file master.c.

Referenced by main().

Here is the caller graph for this function:

static int css_master_init ( int  cport,
SOCKET clientfd 
)
static
static void css_reject_client_request ( CSS_CONN_ENTRY conn,
unsigned short  rid,
int  reason 
)
static

Definition at line 278 of file master.c.

References css_send_data(), and htonl().

Referenced by css_send_to_existing_server().

Here is the caller graph for this function:

static void css_reject_server_request ( CSS_CONN_ENTRY conn,
int  reason 
)
static

Definition at line 293 of file master.c.

References css_conn_entry::fd, and htonl().

Referenced by css_register_new_server(), and css_register_new_server2().

Here is the caller graph for this function:

SOCKET_QUEUE_ENTRY* css_return_entry_by_conn ( CSS_CONN_ENTRY conn_p,
SOCKET_QUEUE_ENTRY **  anchor_p 
)
SOCKET_QUEUE_ENTRY* css_return_entry_of_server ( char *  name_p,
SOCKET_QUEUE_ENTRY anchor_p 
)
static bool css_send_new_request_to_server ( SOCKET  server_fd,
SOCKET  client_fd,
unsigned short  rid,
CSS_SERVER_REQUEST  request 
)
static

Definition at line 612 of file master.c.

References css_transfer_fd().

Referenced by css_send_to_existing_server().

Here is the caller graph for this function:

Variable Documentation

pthread_mutex_t css_Master_er_log_enable_lock = PTHREAD_MUTEX_INITIALIZER

Definition at line 130 of file master.c.

Referenced by hb_disable_er_log(), hb_enable_er_log(), and hb_get_admin_info_string().

bool css_Master_er_log_enabled = true

Definition at line 131 of file master.c.

Referenced by hb_disable_er_log(), hb_enable_er_log(), and hb_get_admin_info_string().

pthread_mutex_t css_Master_er_log_lock = PTHREAD_MUTEX_INITIALIZER

Definition at line 129 of file master.c.

struct timeval* css_Master_timeout = NULL
int css_Master_timeout_value_in_microseconds = 500

Definition at line 113 of file master.c.

Referenced by css_master_loop().

int css_Master_timeout_value_in_seconds = 4

Definition at line 112 of file master.c.

Referenced by css_master_loop().

time_t css_Start_time

Definition at line 118 of file master.c.

Referenced by css_process_start_time_info(), and main().

int css_Total_request_count = 0

Definition at line 119 of file master.c.

Referenced by css_process_new_connection(), and css_process_request_count_info().