In packet I/O dump file mode, force refresh stat before program exit

This commit is contained in:
luwenpeng
2024-05-29 18:12:46 +08:00
parent 963aa259b1
commit fb700b43e4

View File

@@ -327,17 +327,6 @@ static int all_session_have_freed(struct stellar_runtime *runtime, struct stella
return 1;
}
static int all_stat_have_output(struct stellar_runtime *runtime, struct stellar_config *config)
{
static int count = 0;
if (runtime->stat_last_output_ts == stellar_get_monotonic_time_msec())
{
count++;
}
return count == 2;
}
static int stellar_thread_init(struct stellar_runtime *runtime, struct stellar_config *config)
{
uint64_t now = stellar_get_monotonic_time_msec();
@@ -487,10 +476,11 @@ int stellar_main(int argc, char **argv)
}
usleep(1000); // 1ms
// Only available in dump file mode, automatically exits when all sessions have been released
if (packet_io_wait_exit(runtime->packet_io) && all_session_have_freed(runtime, config) && all_stat_have_output(runtime, config))
// only available in dump file mode, automatically exits when all sessions have been released
if (packet_io_wait_exit(runtime->packet_io) && all_session_have_freed(runtime, config))
{
STELLAR_LOG_STATE("all sessions have been released and all stat have been output, notify threads to exit !!!");
stellar_stat_output(runtime->stat); // flush stat
STELLAR_LOG_STATE("all sessions have been released, notify threads to exit !!!");
ATOMIC_SET(&need_exit, 1);
}
}