CUBRID Engine
latest
|
#include "config.h"
#include <stdio.h>
#include <string.h>
#include <signal.h>
#include <assert.h>
#include <chrono>
#include <time.h>
#include <stdarg.h>
#include <sys/timeb.h>
#include <sys/time.h>
#include "util_func.h"
#include "porting.h"
#include "error_code.h"
#include "utility.h"
#include "system_parameter.h"
#include "environment_variable.h"
Go to the source code of this file.
Macros | |
#define | UTIL_LOG_MAX_HEADER_LEN (40) |
#define | UTIL_LOG_MAX_MSG_SIZE (1024) |
#define | UTIL_LOG_BUFFER_SIZE (UTIL_LOG_MAX_MSG_SIZE + UTIL_LOG_MAX_HEADER_LEN) |
#define | UTIL_LOG_FILENAME "cubrid_utility.log" |
#define | MAX_RETRY_COUNT 10 |
Functions | |
static FILE * | util_log_file_backup (FILE *fp, const char *path) |
static FILE * | util_log_file_fopen (const char *path) |
static FILE * | fopen_and_lock (const char *path) |
static int | util_log_header (char *buf, size_t buf_len) |
static int | util_log_write_internal (const char *msg, const char *prefix_str) |
template<typename Duration > | |
static void | util_get_seconds_and_rest_since_epoch (std::chrono::seconds &secs, Duration &rest) |
unsigned int | hashpjw (const char *s) |
int | util_compare_filepath (const char *file1, const char *file2) |
static void | system_interrupt_handler (int sig) |
static void | system_quit_handler (int sig) |
void | util_disarm_signal_handlers (void) |
void | util_arm_signal_handlers (SIG_HANDLER sigint_handler, SIG_HANDLER sigquit_handler) |
char ** | util_split_string (const char *str, const char *delim) |
void | util_free_string_array (char **array) |
time_t | util_str_to_time_since_epoch (char *str) |
void | util_shuffle_string_array (char **array, int count) |
int | util_log_write_result (int error) |
int | util_log_write_errid (int message_id,...) |
int | util_log_write_errstr (const char *format,...) |
int | util_log_write_warnstr (const char *format,...) |
int | util_log_write_command (int argc, char *argv[]) |
int | util_bsearch (const void *key, const void *base, int n_elems, unsigned int sizeof_elem, int(*func_compare)(const void *, const void *), bool *out_found) |
template<typename Duration > | |
void | util_get_seconds_and_rest_since_epoch (std::chrono::seconds &secs, Duration &rest) |
void | util_get_second_and_ms_since_epoch (time_t *secs, int *msec) |
Variables | |
static char * | util_Log_filename = NULL |
static char | util_Log_filename_buf [PATH_MAX] |
static char | util_Log_buffer [UTIL_LOG_BUFFER_SIZE] |
static SIG_HANDLER | user_interrupt_handler = NULL |
static SIG_HANDLER | user_quit_handler = NULL |
#define MAX_RETRY_COUNT 10 |
Referenced by fopen_and_lock().
#define UTIL_LOG_BUFFER_SIZE (UTIL_LOG_MAX_MSG_SIZE + UTIL_LOG_MAX_HEADER_LEN) |
Definition at line 49 of file util_func.c.
Referenced by util_log_write_internal().
#define UTIL_LOG_FILENAME "cubrid_utility.log" |
Definition at line 52 of file util_func.c.
Referenced by util_log_write_internal().
#define UTIL_LOG_MAX_HEADER_LEN (40) |
Definition at line 47 of file util_func.c.
Referenced by util_log_header().
#define UTIL_LOG_MAX_MSG_SIZE (1024) |
Definition at line 48 of file util_func.c.
Referenced by util_log_write_command(), util_log_write_errid(), util_log_write_errstr(), and util_log_write_warnstr().
|
static |
Definition at line 719 of file util_func.c.
References MAX_RETRY_COUNT, NULL, and SLEEP_MILISEC.
Referenced by util_log_file_backup(), and util_log_file_fopen().
unsigned int hashpjw | ( | const char * | s | ) |
Definition at line 83 of file util_func.c.
Referenced by dl_validate_candidates(), pp_generic_case_hash(), and pp_generic_hash().
|
static |
Definition at line 159 of file util_func.c.
References NULL, os_set_signal_handler(), and user_interrupt_handler.
Referenced by util_arm_signal_handlers(), and util_compare_filepath().
|
static |
Definition at line 177 of file util_func.c.
References NULL, os_set_signal_handler(), and user_quit_handler.
Referenced by util_arm_signal_handlers(), and util_compare_filepath().
void util_arm_signal_handlers | ( | SIG_HANDLER | sigint_handler, |
SIG_HANDLER | sigquit_handler | ||
) |
Definition at line 222 of file util_func.c.
References NULL, os_set_signal_handler(), system_interrupt_handler(), system_quit_handler(), user_interrupt_handler, user_quit_handler, and util_disarm_signal_handlers().
Referenced by ldr_exec_query_from_file(), ldr_sa_load(), and register_signal_handlers().
int util_bsearch | ( | const void * | key, |
const void * | base, | ||
int | n_elems, | ||
unsigned int | sizeof_elem, | ||
int(*)(const void *, const void *) | func_compare, | ||
bool * | out_found | ||
) |
Definition at line 764 of file util_func.c.
Referenced by file_extdata_find_ordered(), and vacuum_add_dropped_file().
Definition at line 111 of file util_func.c.
References p, system_interrupt_handler(), and system_quit_handler().
Referenced by boot_check_permanent_volumes(), boot_mount(), fileio_is_system_volume_label_equal(), fileio_is_volume_label_equal(), and logpb_next_where_path().
void util_disarm_signal_handlers | ( | void | ) |
Definition at line 192 of file util_func.c.
References NULL, os_set_signal_handler(), user_interrupt_handler, and user_quit_handler.
Referenced by util_arm_signal_handlers().
void util_free_string_array | ( | char ** | array | ) |
Definition at line 292 of file util_func.c.
Referenced by boot_restart_client(), server_monitor_thr_f(), util_free_ha_conf(), util_get_num_of_ha_nodes(), util_is_replica_node(), and util_make_ha_conf().
void util_get_second_and_ms_since_epoch | ( | time_t * | secs, |
int * | msec | ||
) |
Definition at line 829 of file util_func.c.
Referenced by db_calculate_current_time(), db_sys_date_and_epoch_time(), db_sys_datetime(), fetch_peek_arith(), logddl_get_time_string(), qexec_execute_query(), ut_time_string(), and util_log_header().
|
static |
Definition at line 818 of file util_func.c.
void util_get_seconds_and_rest_since_epoch | ( | std::chrono::seconds & | secs, |
Duration & | rest | ||
) |
Definition at line 818 of file util_func.c.
|
static |
Definition at line 698 of file util_func.c.
References assert, fopen_and_lock(), and NULL.
Referenced by util_log_file_fopen().
|
static |
Definition at line 672 of file util_func.c.
References assert, fopen_and_lock(), NULL, prm_get_integer_value(), PRM_ID_ER_LOG_SIZE, and util_log_file_backup().
Referenced by util_log_write_internal().
|
static |
Definition at line 634 of file util_func.c.
References assert, envvar_get(), NULL, p, pid, util_get_second_and_ms_since_epoch(), UTIL_LOG_MAX_HEADER_LEN, and UTIL_PID_ENVVAR_NAME.
Referenced by util_log_write_internal().
int util_log_write_command | ( | int | argc, |
char * | argv[] | ||
) |
Definition at line 540 of file util_func.c.
References i, NULL, p, strlen, UTIL_LOG_MAX_MSG_SIZE, and util_log_write_internal().
Referenced by main().
int util_log_write_errid | ( | int | message_id, |
... | |||
) |
Definition at line 468 of file util_func.c.
References UTIL_LOG_MAX_MSG_SIZE, util_log_write_internal(), and utility_get_generic_message().
Referenced by addvoldb(), alterdbhost(), applyinfo(), applylogdb(), backupdb(), changemode(), checkdb(), checksumdb(), compact_usage(), compactdb_usage(), copydb(), copylogdb(), createdb(), deletedb(), diagdb(), dumplocale(), genlocale(), installdb(), killtran(), ldr_validate_object_file(), lockdb(), main(), optimizedb(), paramdump(), plandump(), process_broker(), process_heartbeat(), process_heartbeat_deregister(), process_heartbeat_reload(), process_heartbeat_replication(), process_heartbeat_start(), process_heartbeat_stop(), process_javasp(), process_javasp_start(), process_javasp_status(), process_javasp_stop(), process_manager(), process_master(), process_server(), process_service(), renamedb(), restoredb(), restoreslave(), spacedb(), statdump(), synccolldb(), tde(), tranlist(), unload_usage(), unloaddb(), us_hb_applylogdb_start(), us_hb_applylogdb_stop(), us_hb_copylogdb_start(), us_hb_copylogdb_stop(), us_hb_server_start(), us_hb_server_stop(), us_hb_status_get_options(), us_hb_stop_get_options(), us_hb_util_get_options(), util_get_class_oids_and_index_btid(), util_get_table_list_from_file(), and vacuumdb().
int util_log_write_errstr | ( | const char * | format, |
... | |||
) |
Definition at line 493 of file util_func.c.
References UTIL_LOG_MAX_MSG_SIZE, and util_log_write_internal().
Referenced by applylogdb(), checkdb(), compactdb(), copylogdb(), createdb(), hb_master_init(), killtran(), ldr_check_file(), ldr_sa_load(), loaddb_internal(), main(), process_javasp_start(), process_master(), tranlist(), unloaddb(), and vacuumdb().
Definition at line 587 of file util_func.c.
References envvar_logdir_file(), NULL, p, util_Log_buffer, UTIL_LOG_BUFFER_SIZE, util_log_file_fopen(), UTIL_LOG_FILENAME, util_Log_filename, util_Log_filename_buf, and util_log_header().
Referenced by util_log_write_command(), util_log_write_errid(), util_log_write_errstr(), util_log_write_result(), and util_log_write_warnstr().
int util_log_write_result | ( | int | error | ) |
Definition at line 448 of file util_func.c.
References NO_ERROR, NULL, and util_log_write_internal().
Referenced by main().
int util_log_write_warnstr | ( | const char * | format, |
... | |||
) |
Definition at line 516 of file util_func.c.
References UTIL_LOG_MAX_MSG_SIZE, and util_log_write_internal().
Referenced by backupdb().
void util_shuffle_string_array | ( | char ** | array, |
int | count | ||
) |
Definition at line 412 of file util_func.c.
Referenced by boot_client_all_finalize().
Definition at line 247 of file util_func.c.
References cubregex::count(), NULL, and strdup().
Referenced by boot_restart_client(), server_monitor_thr_f(), util_split_ha_db(), util_split_ha_node(), and util_split_ha_sync().
time_t util_str_to_time_since_epoch | ( | char * | str | ) |
Definition at line 310 of file util_func.c.
References ER_GENERIC_ERROR, NO_ERROR, NULL, and strdup().
Referenced by applyinfo(), applylogdb(), and la_delay_replica().
|
static |
Definition at line 148 of file util_func.c.
Referenced by system_interrupt_handler(), util_arm_signal_handlers(), and util_disarm_signal_handlers().
|
static |
Definition at line 149 of file util_func.c.
Referenced by system_quit_handler(), util_arm_signal_handlers(), and util_disarm_signal_handlers().
|
static |
Definition at line 56 of file util_func.c.
Referenced by util_log_write_internal().
|
static |
Definition at line 54 of file util_func.c.
Referenced by util_log_write_internal().
|
static |
Definition at line 55 of file util_func.c.
Referenced by util_log_write_internal().