add function sf_global_init
parent
153905dc44
commit
413f6eef76
|
|
@ -293,7 +293,7 @@ int sf_load_global_base_path(IniFullContext *ini_ctx)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int sf_load_global_config_ex(const char *server_name,
|
||||
int sf_load_global_config_ex(const char *log_filename_prefix,
|
||||
IniFullContext *ini_ctx, const bool load_network_params,
|
||||
const char *max_pkg_size_item_nm, const int fixed_buff_size,
|
||||
const int task_buffer_extra_size, const bool need_set_run_by)
|
||||
|
|
@ -402,8 +402,10 @@ int sf_load_global_config_ex(const char *server_name,
|
|||
ini_ctx->section_name = old_section_name;
|
||||
|
||||
load_log_level(ini_ctx->context);
|
||||
if (server_name != NULL) {
|
||||
if ((result=log_set_prefix(SF_G_BASE_PATH_STR, server_name)) != 0) {
|
||||
if (log_filename_prefix != NULL) {
|
||||
if ((result=log_set_prefix(SF_G_BASE_PATH_STR,
|
||||
log_filename_prefix)) != 0)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
@ -411,12 +413,12 @@ int sf_load_global_config_ex(const char *server_name,
|
|||
return 0;
|
||||
}
|
||||
|
||||
int sf_load_config_ex(const char *server_name, SFContextIniConfig *config,
|
||||
const int fixed_buff_size, const int task_buffer_extra_size,
|
||||
const bool need_set_run_by)
|
||||
int sf_load_config_ex(const char *log_filename_prefix,
|
||||
SFContextIniConfig *config, const int fixed_buff_size,
|
||||
const int task_buffer_extra_size, const bool need_set_run_by)
|
||||
{
|
||||
int result;
|
||||
if ((result=sf_load_global_config_ex(server_name, &config->ini_ctx,
|
||||
if ((result=sf_load_global_config_ex(log_filename_prefix, &config->ini_ctx,
|
||||
true, config->max_pkg_size_item_name, fixed_buff_size,
|
||||
task_buffer_extra_size, need_set_run_by)) != 0)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -178,12 +178,12 @@ extern SFContext g_sf_context;
|
|||
pIniContext, section_name, def_inner_port, def_outer_port, \
|
||||
def_work_threads, "max_pkg_size")
|
||||
|
||||
int sf_load_global_config_ex(const char *server_name,
|
||||
int sf_load_global_config_ex(const char *log_filename_prefix,
|
||||
IniFullContext *ini_ctx, const bool load_network_params,
|
||||
const char *max_pkg_size_item_nm, const int fixed_buff_size,
|
||||
const int task_buffer_extra_size, const bool need_set_run_by);
|
||||
|
||||
static inline int sf_load_global_config(const char *server_name,
|
||||
static inline int sf_load_global_config(const char *log_filename_prefix,
|
||||
IniFullContext *ini_ctx)
|
||||
{
|
||||
const bool load_network_params = true;
|
||||
|
|
@ -192,16 +192,16 @@ static inline int sf_load_global_config(const char *server_name,
|
|||
const int task_buffer_extra_size = 0;
|
||||
const bool need_set_run_by = true;
|
||||
|
||||
return sf_load_global_config_ex(server_name, ini_ctx, load_network_params,
|
||||
max_pkg_size_item_nm, fixed_buff_size, task_buffer_extra_size,
|
||||
need_set_run_by);
|
||||
return sf_load_global_config_ex(log_filename_prefix, ini_ctx,
|
||||
load_network_params, max_pkg_size_item_nm, fixed_buff_size,
|
||||
task_buffer_extra_size, need_set_run_by);
|
||||
}
|
||||
|
||||
int sf_load_config_ex(const char *server_name, SFContextIniConfig *config,
|
||||
const int fixed_buff_size, const int task_buffer_extra_size,
|
||||
const bool need_set_run_by);
|
||||
int sf_load_config_ex(const char *log_filename_prefix,
|
||||
SFContextIniConfig *config, const int fixed_buff_size,
|
||||
const int task_buffer_extra_size, const bool need_set_run_by);
|
||||
|
||||
static inline int sf_load_config(const char *server_name,
|
||||
static inline int sf_load_config(const char *log_filename_prefix,
|
||||
const FCCommunicationType comm_type,
|
||||
const char *filename, IniContext *pIniContext,
|
||||
const char *section_name, const int default_inner_port,
|
||||
|
|
@ -214,7 +214,7 @@ static inline int sf_load_config(const char *server_name,
|
|||
SF_SET_CONTEXT_INI_CONFIG(config, comm_type, filename, pIniContext,
|
||||
section_name, default_inner_port, default_outer_port,
|
||||
DEFAULT_WORK_THREADS);
|
||||
return sf_load_config_ex(server_name, &config, fixed_buff_size,
|
||||
return sf_load_config_ex(log_filename_prefix, &config, fixed_buff_size,
|
||||
task_buffer_extra_size, need_set_run_by);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -798,6 +798,12 @@ void sf_set_current_time()
|
|||
srand(g_sf_global_vars.up_time);
|
||||
}
|
||||
|
||||
int sf_global_init(const char *log_filename_prefix)
|
||||
{
|
||||
sf_set_current_time();
|
||||
return log_set_prefix(SF_G_BASE_PATH_STR, log_filename_prefix);
|
||||
}
|
||||
|
||||
void sf_enable_thread_notify_ex(SFContext *sf_context, const bool enabled)
|
||||
{
|
||||
struct nio_thread_data *thread_data;
|
||||
|
|
|
|||
|
|
@ -101,6 +101,7 @@ int sf_startup_schedule(pthread_t *schedule_tid);
|
|||
int sf_add_slow_log_schedule(SFSlowLogContext *slowlog_ctx);
|
||||
|
||||
void sf_set_current_time();
|
||||
int sf_global_init(const char *log_filename_prefix);
|
||||
|
||||
int sf_socket_create_server(SFListener *listener,
|
||||
int af, const char *bind_addr);
|
||||
|
|
|
|||
Loading…
Reference in New Issue