enhance: add configuration items to adjust the scheduling parameters of the main loop
This commit is contained in:
@@ -405,6 +405,114 @@ static int parse_session_manager_section(toml_table_t *root, struct session_mana
|
||||
return 0;
|
||||
}
|
||||
|
||||
// return 0: success
|
||||
// retuun -1: failed
|
||||
static int parse_schedule_options(toml_table_t *root, struct schedule_options *opts)
|
||||
{
|
||||
const char *ptr;
|
||||
toml_table_t *table;
|
||||
|
||||
table = toml_table_in(root, "schedule");
|
||||
if (table == NULL)
|
||||
{
|
||||
CONFIG_LOG_ERROR("config file missing schedule section");
|
||||
return -1;
|
||||
}
|
||||
|
||||
ptr = toml_raw_in(table, "free_expired_session_interval");
|
||||
if (ptr == NULL)
|
||||
{
|
||||
CONFIG_LOG_ERROR("config file missing schedule->free_expired_session_interval");
|
||||
return -1;
|
||||
}
|
||||
opts->free_expired_session_interval = atoll(ptr);
|
||||
if (opts->free_expired_session_interval < 1 || opts->free_expired_session_interval > 60000)
|
||||
{
|
||||
CONFIG_LOG_ERROR("config file invalid schedule->free_expired_session_interval %ld, range [1, 60000]", opts->free_expired_session_interval);
|
||||
return -1;
|
||||
}
|
||||
|
||||
ptr = toml_raw_in(table, "free_expired_session_batch");
|
||||
if (ptr == NULL)
|
||||
{
|
||||
CONFIG_LOG_ERROR("config file missing schedule->free_expired_session_batch");
|
||||
return -1;
|
||||
}
|
||||
opts->free_expired_session_batch = atoll(ptr);
|
||||
if (opts->free_expired_session_batch < 1 || opts->free_expired_session_batch > 60000)
|
||||
{
|
||||
CONFIG_LOG_ERROR("config file invalid schedule->free_expired_session_batch %ld, range [1, 60000]", opts->free_expired_session_batch);
|
||||
return -1;
|
||||
}
|
||||
|
||||
ptr = toml_raw_in(table, "free_expired_ip_frag_interval");
|
||||
if (ptr == NULL)
|
||||
{
|
||||
CONFIG_LOG_ERROR("config file missing schedule->free_expired_ip_frag_interval");
|
||||
return -1;
|
||||
}
|
||||
opts->free_expired_ip_frag_interval = atoll(ptr);
|
||||
if (opts->free_expired_ip_frag_interval < 1 || opts->free_expired_ip_frag_interval > 60000)
|
||||
{
|
||||
CONFIG_LOG_ERROR("config file invalid schedule->free_expired_ip_frag_interval %ld, range [1, 60000]", opts->free_expired_ip_frag_interval);
|
||||
return -1;
|
||||
}
|
||||
|
||||
ptr = toml_raw_in(table, "free_expired_ip_frag_batch");
|
||||
if (ptr == NULL)
|
||||
{
|
||||
CONFIG_LOG_ERROR("config file missing schedule->free_expired_ip_frag_batch");
|
||||
return -1;
|
||||
}
|
||||
opts->free_expired_ip_frag_batch = atoll(ptr);
|
||||
if (opts->free_expired_ip_frag_batch < 1 || opts->free_expired_ip_frag_batch > 60000)
|
||||
{
|
||||
CONFIG_LOG_ERROR("config file invalid schedule->free_expired_ip_frag_batch %ld, range [1, 60000]", opts->free_expired_ip_frag_batch);
|
||||
return -1;
|
||||
}
|
||||
|
||||
ptr = toml_raw_in(table, "merge_stat_interval");
|
||||
if (ptr == NULL)
|
||||
{
|
||||
CONFIG_LOG_ERROR("config file missing schedule->merge_stat_interval");
|
||||
return -1;
|
||||
}
|
||||
opts->merge_stat_interval = atoll(ptr);
|
||||
if (opts->merge_stat_interval < 1 || opts->merge_stat_interval > 60000)
|
||||
{
|
||||
CONFIG_LOG_ERROR("config file invalid schedule->merge_stat_interval %ld, range [1, 60000]", opts->merge_stat_interval);
|
||||
return -1;
|
||||
}
|
||||
|
||||
ptr = toml_raw_in(table, "output_stat_interval");
|
||||
if (ptr == NULL)
|
||||
{
|
||||
CONFIG_LOG_ERROR("config file missing schedule->output_stat_interval");
|
||||
return -1;
|
||||
}
|
||||
opts->output_stat_interval = atoll(ptr);
|
||||
if (opts->output_stat_interval < 1 || opts->output_stat_interval > 60000)
|
||||
{
|
||||
CONFIG_LOG_ERROR("config file invalid schedule->output_stat_interval %ld, range [1, 60000]", opts->output_stat_interval);
|
||||
return -1;
|
||||
}
|
||||
|
||||
ptr = toml_raw_in(table, "packet_io_yield_interval");
|
||||
if (ptr == NULL)
|
||||
{
|
||||
CONFIG_LOG_ERROR("config file missing schedule->packet_io_yield_interval");
|
||||
return -1;
|
||||
}
|
||||
opts->packet_io_yield_interval = atoll(ptr);
|
||||
if (opts->packet_io_yield_interval < 1 || opts->packet_io_yield_interval > 60000)
|
||||
{
|
||||
CONFIG_LOG_ERROR("config file invalid schedule->packet_io_yield_interval %ld, range [1, 60000]", opts->packet_io_yield_interval);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// return 0: success
|
||||
// retuun -1: failed
|
||||
int stellar_config_load(struct stellar_config *config, const char *file)
|
||||
@@ -448,6 +556,11 @@ int stellar_config_load(struct stellar_config *config, const char *file)
|
||||
goto error_out;
|
||||
}
|
||||
|
||||
if (parse_schedule_options(table, &config->sched_opts) != 0)
|
||||
{
|
||||
goto error_out;
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
|
||||
error_out:
|
||||
@@ -538,4 +651,13 @@ void stellar_config_print(const struct stellar_config *config)
|
||||
CONFIG_LOG_DEBUG("session_manager->tcp_reassembly_enable : %d", sess_mgr_opts->tcp_reassembly_enable);
|
||||
CONFIG_LOG_DEBUG("session_manager->tcp_reassembly_max_timeout : %d", sess_mgr_opts->tcp_reassembly_max_timeout);
|
||||
CONFIG_LOG_DEBUG("session_manager->tcp_reassembly_max_segments : %d", sess_mgr_opts->tcp_reassembly_max_segments);
|
||||
|
||||
// schedule config
|
||||
CONFIG_LOG_DEBUG("schedule->free_expired_session_interval : %ld", config->sched_opts.free_expired_session_interval);
|
||||
CONFIG_LOG_DEBUG("schedule->free_expired_session_batch : %ld", config->sched_opts.free_expired_session_batch);
|
||||
CONFIG_LOG_DEBUG("schedule->free_expired_ip_frag_interval : %ld", config->sched_opts.free_expired_ip_frag_interval);
|
||||
CONFIG_LOG_DEBUG("schedule->free_expired_ip_frag_batch : %ld", config->sched_opts.free_expired_ip_frag_batch);
|
||||
CONFIG_LOG_DEBUG("schedule->merge_stat_interval : %ld", config->sched_opts.merge_stat_interval);
|
||||
CONFIG_LOG_DEBUG("schedule->output_stat_interval : %ld", config->sched_opts.output_stat_interval);
|
||||
CONFIG_LOG_DEBUG("schedule->packet_io_yield_interval : %ld", config->sched_opts.packet_io_yield_interval);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user