0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2025-01-03 07:31:54 +00:00

Fix of failing show threads command

This commit is contained in:
Maria Matejka 2023-04-24 11:35:05 +02:00
parent db2b67268c
commit 19e79eb8ad

View File

@ -930,6 +930,7 @@ struct bird_thread_show_data {
DOMAIN(control) lock; DOMAIN(control) lock;
uint total; uint total;
uint done; uint done;
event finish_event;
u8 show_loops; u8 show_loops;
}; };
@ -977,11 +978,15 @@ bird_thread_show(void *data)
else else
cli_printf(tsd->cli, (last ? 1 : -1) * 1026, "Thread %p time %t", this_thread, total_time_ns NS); cli_printf(tsd->cli, (last ? 1 : -1) * 1026, "Thread %p time %t", this_thread, total_time_ns NS);
UNLOCK_DOMAIN(control, tsd->lock); ev_send(&global_event_list, &tsd->finish_event);
if (last) UNLOCK_DOMAIN(control, tsd->lock);
{ }
the_bird_lock();
static void
bird_thread_show_finish(void *data)
{
struct bird_thread_show_data *tsd = data;
for (int i=0; i<2; i++) for (int i=0; i<2; i++)
{ {
@ -992,6 +997,8 @@ bird_thread_show(void *data)
if (tsd->show_loops) if (tsd->show_loops)
{ {
cli_printf(tsd->cli, -1026, "Unassigned loops"); cli_printf(tsd->cli, -1026, "Unassigned loops");
struct birdloop *loop;
WALK_LIST(loop, group->loops) WALK_LIST(loop, group->loops)
cli_printf(tsd->cli, -1026, " Loop %s time: %t", domain_name(loop->time.domain), loop->total_time_spent_ns NS); cli_printf(tsd->cli, -1026, " Loop %s time: %t", domain_name(loop->time.domain), loop->total_time_spent_ns NS);
} }
@ -999,6 +1006,7 @@ bird_thread_show(void *data)
{ {
uint count = 0; uint count = 0;
u64 total_time_ns = 0; u64 total_time_ns = 0;
struct birdloop *loop;
WALK_LIST(loop, group->loops) WALK_LIST(loop, group->loops)
{ {
count++; count++;
@ -1010,18 +1018,19 @@ bird_thread_show(void *data)
} }
cli_write_trigger(tsd->cli); cli_write_trigger(tsd->cli);
DOMAIN_FREE(control, tsd->lock);
DOMAIN(control) lock = tsd->lock;
LOCK_DOMAIN(control, lock);
rp_free(tsd->pool); rp_free(tsd->pool);
UNLOCK_DOMAIN(control, lock);
the_bird_unlock(); DOMAIN_FREE(control, lock);
}
} }
void void
cmd_show_threads(int show_loops) cmd_show_threads(int show_loops)
{ {
DOMAIN(control) lock = DOMAIN_NEW(control, "Show Threads"); DOMAIN(control) lock = DOMAIN_NEW(control, "Show Threads");
LOCK_DOMAIN(control, lock);
pool *p = rp_new(&root_pool, lock.control, "Show Threads"); pool *p = rp_new(&root_pool, lock.control, "Show Threads");
struct bird_thread_show_data *tsd = mb_allocz(p, sizeof(struct bird_thread_show_data)); struct bird_thread_show_data *tsd = mb_allocz(p, sizeof(struct bird_thread_show_data));
@ -1029,6 +1038,10 @@ cmd_show_threads(int show_loops)
tsd->pool = p; tsd->pool = p;
tsd->lock = lock; tsd->lock = lock;
tsd->show_loops = show_loops; tsd->show_loops = show_loops;
tsd->finish_event = (event) {
.hook = bird_thread_show_finish,
.data = tsd,
};
this_cli->cont = bird_thread_show_cli_cont; this_cli->cont = bird_thread_show_cli_cont;
this_cli->cleanup = bird_thread_show_cli_cleanup; this_cli->cleanup = bird_thread_show_cli_cleanup;
@ -1037,7 +1050,6 @@ cmd_show_threads(int show_loops)
{ {
struct birdloop_pickup_group *group = &pickup_groups[i]; struct birdloop_pickup_group *group = &pickup_groups[i];
LOCK_DOMAIN(control, tsd->lock);
LOCK_DOMAIN(resource, group->domain); LOCK_DOMAIN(resource, group->domain);
struct bird_thread *thr; struct bird_thread *thr;
@ -1049,8 +1061,9 @@ cmd_show_threads(int show_loops)
} }
UNLOCK_DOMAIN(resource, group->domain); UNLOCK_DOMAIN(resource, group->domain);
UNLOCK_DOMAIN(control, tsd->lock);
} }
UNLOCK_DOMAIN(control, lock);
} }
/* /*