Optimize the output of log and stat

This commit is contained in:
luwenpeng
2024-05-16 11:52:14 +08:00
parent 4c50a6dca7
commit 8d8a266f60
9 changed files with 120 additions and 51 deletions

View File

@@ -63,6 +63,17 @@ static int all_session_have_freed(void)
return 1;
}
static int all_stat_have_output(void)
{
static int count = 0;
if (runtime->stat_last_output_ts == stellar_get_monotonic_time_msec())
{
count++;
}
return count == 2;
}
int main(int argc, char **argv)
{
stellar_update_time_cache();
@@ -138,8 +149,9 @@ int 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())
if (packet_io_wait_exit(runtime->packet_io) && all_session_have_freed() && all_stat_have_output())
{
STELLAR_LOG_STATE("all sessions have been released and all stat have been output, notify threads to exit !!!");
ATOMIC_SET(&runtime->need_exit, 1);
}
}