Packet IO dump file mode, automatically exits when all sessions are released

This commit is contained in:
luwenpeng
2024-05-15 18:01:24 +08:00
parent 44c2cf86e4
commit 1ef82a0c6a
2 changed files with 46 additions and 2 deletions

View File

@@ -42,6 +42,27 @@ static void signal_handler(int signo)
}
}
static int all_session_have_freed(void)
{
for (int i = 0; i < config->io_opts.nr_threads; i++)
{
struct session_manager *sess_mgr = runtime->threads[i].sess_mgr;
struct session_manager_stat *sess_stat = session_manager_stat(sess_mgr);
if (ATOMIC_READ(&sess_stat->curr_nr_tcp_sess_used) != 0)
{
return 0;
}
if (ATOMIC_READ(&sess_stat->curr_nr_udp_sess_used) != 0)
{
return 0;
}
}
return 1;
}
int main(int argc, char **argv)
{
timestamp_update();
@@ -116,7 +137,8 @@ int main(int argc, char **argv)
}
usleep(1000); // 1ms
if (packet_io_wait_exit(runtime->packet_io))
// 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())
{
ATOMIC_SET(&runtime->need_exit, 1);
}