From 1dfd9906a04873e9d381bf559eb8551c203c8a2a Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Mon, 21 Sep 2015 16:38:01 -0400 Subject: [PATCH] Fix: Break out of loop when searching for a domain's agent MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The list command never check if a domain's agent has been found and lists the events of every agent. This has two direct effects: 1) Memory leak of all agents' event descriptions, except the last 2) The session daemon lists the wrong agent's events This fix check the agent's domain and breaks out of the loop once one is found. Fixes #906 Signed-off-by: Jérémie Galarneau --- src/bin/lttng-sessiond/cmd.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/bin/lttng-sessiond/cmd.c b/src/bin/lttng-sessiond/cmd.c index 7878a053c..b1d986393 100644 --- a/src/bin/lttng-sessiond/cmd.c +++ b/src/bin/lttng-sessiond/cmd.c @@ -2764,7 +2764,11 @@ ssize_t cmd_list_events(enum lttng_domain_type domain, rcu_read_lock(); cds_lfht_for_each_entry(session->ust_session->agents->ht, &iter.iter, agt, node.node) { - nb_event = list_lttng_agent_events(agt, events); + if (agt->domain == domain) { + nb_event = list_lttng_agent_events( + agt, events); + break; + } } rcu_read_unlock(); } -- 2.34.1