Avoid dead loop startup

This commit is contained in:
lazio579 2018-11-08 11:05:56 +08:00
parent c9984f6b8f
commit 6d999df4ca
2 changed files with 22 additions and 1 deletions

View File

@ -164,7 +164,26 @@ cetus_master_process_cycle(cetus_cycle_t *cycle)
if (cetus_reap) {
g_message("%s: cetus_reap is true", G_STRLOC);
cetus_reap = 0;
live = cetus_reap_children(cycle);
cycle->current_time = time(0);
if (cycle->child_exit_time == 0) {
cycle->child_exit_time = cycle->current_time;
cycle->child_instant_exit_times = 1;
} else {
cycle->child_instant_exit_times++;
int diff = cycle->current_time - cycle->child_exit_time;
if (diff > 1) {
cycle->child_exit_time = 0;
g_message("%s: reset child_exit_time to zero", G_STRLOC);
} else {
if (cycle->child_instant_exit_times >= cetus_last_process) {
cetus_terminate = 1;
g_message("%s: set cetus_terminate is true", G_STRLOC);
}
}
}
if (!cetus_terminate) {
live = cetus_reap_children(cycle);
}
}
}

View File

@ -156,6 +156,7 @@ struct chassis {
int worker_processes;
int cpus;
int child_instant_exit_times;
int max_alive_time;
int merged_output_size;
@ -188,6 +189,7 @@ struct chassis {
struct incremental_guid_state_t guid_state;
#endif
time_t startup_time;
time_t child_exit_time;
time_t current_time;
struct chassis_options_t *options;
chassis_config_t *config_manager;