diff --git a/src/broker/cas.c b/src/broker/cas.c index c99e546184..1f35798091 100644 --- a/src/broker/cas.c +++ b/src/broker/cas.c @@ -76,6 +76,7 @@ #include "cas_sql_log2.h" #include "broker_acl.h" #include "dbtype.h" + #if !defined(CAS_FOR_ORACLE) && !defined(CAS_FOR_MYSQL) #include "environment_variable.h" #endif /* !CAS_FOR_ORACLE && !CAS_FOR_MYSQL */ @@ -85,6 +86,8 @@ #if defined (CAS_FOR_CGW) #include "cas_cgw.h" #endif +// XXX: SHOULD BE THE LAST INCLUDE HEADER +#include "memory_wrapper.hpp" static const int DEFAULT_CHECK_INTERVAL = 1; @@ -127,7 +130,6 @@ static void set_db_connection_info (void); static void clear_db_connection_info (void); static bool need_database_reconnect (void); -extern bool db_Keep_session; extern bool ssl_client; extern int cas_init_ssl (int); extern void cas_ssl_close (int client_sock_fd); @@ -1975,13 +1977,13 @@ process_request (SOCKET sock_fd, T_NET_BUF * net_buf, T_REQ_INFO * req_info) cas_log_msg = "RESET"; cas_log_write_and_end (0, true, cas_log_msg); fn_ret = FN_KEEP_SESS; - db_Keep_session = true; + db_set_keep_session (true); } if (as_info->con_status == CON_STATUS_CLOSE_AND_CONNECT) { cas_log_msg = "CHANGE CLIENT"; fn_ret = FN_KEEP_SESS; - db_Keep_session = true; + db_set_keep_session (true); } if (cas_log_msg == NULL) @@ -2175,7 +2177,7 @@ process_request (SOCKET sock_fd, T_NET_BUF * net_buf, T_REQ_INFO * req_info) fn_ret = (*server_fn) (sock_fd, argc, argv, net_buf, req_info); if (fn_ret == FN_KEEP_SESS) { - db_Keep_session = true; + db_set_keep_session (true); } set_hang_check_time (); @@ -2249,7 +2251,7 @@ process_request (SOCKET sock_fd, T_NET_BUF * net_buf, T_REQ_INFO * req_info) else if (restart_is_needed ()) { fn_ret = FN_KEEP_SESS; - db_Keep_session = true; + db_set_keep_session (true); } if (shm_appl->sql_log2 != as_info->cur_sql_log2) { @@ -2360,7 +2362,7 @@ process_request (SOCKET sock_fd, T_NET_BUF * net_buf, T_REQ_INFO * req_info) { cas_log_debug (ARG_FILE_LINE, "process_request: reset_flag && !CON_STATUS_IN_TRAN"); fn_ret = FN_KEEP_SESS; - db_Keep_session = true; + db_set_keep_session (true); goto exit_on_end; } diff --git a/src/communication/network_interface_cl.c b/src/communication/network_interface_cl.c index 2fb0db7156..ffad5f499f 100644 --- a/src/communication/network_interface_cl.c +++ b/src/communication/network_interface_cl.c @@ -101,8 +101,6 @@ static int net_Deferred_end_queries_count = 0; */ unsigned int db_on_server = 0; -extern bool db_Keep_session; - #if defined(CS_MODE) static char *pack_const_string (char *buffer, const char *cstring); static char *pack_string_with_null_padding (char *buffer, const char *stream, int len); @@ -4738,7 +4736,7 @@ csession_find_or_create_session (SESSION_ID * session_id, int *row_count, char * * session_id (in) : the id of the session to end */ int -csession_end_session (SESSION_ID session_id) +csession_end_session (SESSION_ID session_id, bool is_keep_session) { #if defined (CS_MODE) int req_error; @@ -4752,7 +4750,7 @@ csession_end_session (SESSION_ID session_id) request = OR_ALIGNED_BUF_START (a_request); ptr = or_pack_int (request, session_id); - ptr = or_pack_int (ptr, db_Keep_session); + ptr = or_pack_int (ptr, is_keep_session); req_error = net_client_request (NET_SERVER_SES_END_SESSION, request, OR_ALIGNED_BUF_SIZE (a_request), reply, @@ -4768,7 +4766,7 @@ csession_end_session (SESSION_ID session_id) THREAD_ENTRY *thread_p = enter_server (); - result = xsession_end_session (thread_p, session_id, db_Keep_session); + result = xsession_end_session (thread_p, session_id, is_keep_session); exit_server (*thread_p); diff --git a/src/communication/network_interface_cl.h b/src/communication/network_interface_cl.h index 5b268d1872..d927978658 100644 --- a/src/communication/network_interface_cl.h +++ b/src/communication/network_interface_cl.h @@ -406,7 +406,7 @@ extern int boot_get_server_timezone_checksum (char *timezone_checksum); /* session state API */ extern int csession_find_or_create_session (SESSION_ID * session_id, int *row_count, char *server_session_key, const char *db_user, const char *host, const char *program_name); -extern int csession_end_session (SESSION_ID session_id); +extern int csession_end_session (SESSION_ID session_id, bool is_keep_session); extern int csession_set_row_count (int rows); extern int csession_get_row_count (int *rows); extern int csession_get_last_insert_id (DB_VALUE * value, bool update_last_insert_id); diff --git a/src/compat/db.h b/src/compat/db.h index 0354992263..9fb108480b 100644 --- a/src/compat/db.h +++ b/src/compat/db.h @@ -49,6 +49,7 @@ extern int db_Connect_status; extern SESSION_ID db_Session_id; +extern bool db_Keep_session; extern int db_Row_count; diff --git a/src/compat/db_admin.c b/src/compat/db_admin.c index af18c4606e..90c5a0048a 100644 --- a/src/compat/db_admin.c +++ b/src/compat/db_admin.c @@ -101,8 +101,6 @@ struct db_host_status_list The macros for testing this variable were moved to db.h so the query interface functions can use them as well. */ -extern bool db_Keep_session; - char db_Database_name[DB_MAX_IDENTIFIER_LENGTH + 1]; char db_Program_name[PATH_MAX]; char db_Client_ip_addr[16] = { 0 }; @@ -1064,7 +1062,7 @@ db_end_session (void) CHECK_CONNECT_ERROR (); - retval = csession_end_session (db_get_session_id ()); + retval = csession_end_session (db_get_session_id (), db_get_keep_session ()); cubmethod::get_callback_handler ()->free_query_handle_all (true); @@ -3075,6 +3073,26 @@ db_set_session_id (const SESSION_ID session_id) db_Session_id = session_id; } +/* + * db_get_keep_session () - get keep session flag + */ +bool +db_get_keep_session (void) +{ + return db_Keep_session; +} + +/* + * db_set_keep_session () - set keep session flag + * return : void + * keep_session (in): keep session flag + */ +void +db_set_keep_session (const bool keep_session) +{ + db_Keep_session = keep_session; +} + /* * db_find_or_create_session - check if current session is still active * if not, create a new session diff --git a/src/compat/db_macro.c b/src/compat/db_macro.c index f73a2f4387..7126ff1fa6 100644 --- a/src/compat/db_macro.c +++ b/src/compat/db_macro.c @@ -79,6 +79,7 @@ struct valcnv_buffer }; SESSION_ID db_Session_id = DB_EMPTY_SESSION; +bool db_Keep_session = false; int db_Row_count = DB_ROW_COUNT_NOT_SET; @@ -90,7 +91,6 @@ int db_Connect_status = DB_CONNECTION_STATUS_CONNECTED; int db_Connect_status = DB_CONNECTION_STATUS_NOT_CONNECTED; #endif int db_Disable_modifications = 0; -bool db_Keep_session = false; static int transfer_string (char *dst, int *xflen, int *outlen, const int dstlen, const char *src, diff --git a/src/compat/dbi.h b/src/compat/dbi.h index 74f2b077c5..bb45d0844b 100644 --- a/src/compat/dbi.h +++ b/src/compat/dbi.h @@ -77,6 +77,8 @@ extern "C" extern char *db_get_server_session_key (void); extern SESSION_ID db_get_session_id (void); extern void db_set_session_id (const SESSION_ID session_id); + extern bool db_get_keep_session (void); + extern void db_set_keep_session (const bool keep_session); extern int db_end_session (void); extern int db_find_or_create_session (const char *db_user, const char *program_name); extern int db_get_row_count_cache (void); diff --git a/src/compat/dbi_compat.h b/src/compat/dbi_compat.h index ce13ff58e9..e159026d82 100644 --- a/src/compat/dbi_compat.h +++ b/src/compat/dbi_compat.h @@ -150,6 +150,8 @@ extern "C" const char *preferred_hosts, int client_type); extern SESSION_ID db_get_session_id (void); extern void db_set_session_id (const SESSION_ID session_id); + extern bool db_get_keep_session (void); + extern void db_set_keep_session (const bool keep_session); extern int db_find_or_create_session (const char *db_user, const char *program_name); extern int db_get_row_count_cache (void); extern void db_update_row_count_cache (const int row_count);