From d8366880cdb6583ca6c9a04fd022abbca26ff09a 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 660cd0ca8..4391b6a58 100644 --- a/src/bin/lttng-sessiond/cmd.c +++ b/src/bin/lttng-sessiond/cmd.c @@ -2748,7 +2748,11 @@ ssize_t cmd_list_events(int domain, struct ltt_session *session, 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