[lttng-dev] [lttng-tools PATCH] Fix UST channel error handling
David Goulet
dgoulet at efficios.com
Thu Feb 23 15:57:12 EST 2012
When an application registers, if an ust app channel failed to get
created on the tracer, it was *not* removed from the ust app session
hash table and thus creating a segfault on start trace.
Adds a safe_delete_ust_app_channel function which deletes the channel
object from the session hash table and free() the memory safely using an
RCU call.
Commit fixes #89
Signed-off-by: David Goulet <dgoulet at efficios.com>
---
src/bin/lttng-sessiond/ust-app.c | 43 ++++++++++++++++++++++++++++++++++++-
1 files changed, 41 insertions(+), 2 deletions(-)
diff --git a/src/bin/lttng-sessiond/ust-app.c b/src/bin/lttng-sessiond/ust-app.c
index 0303582..3d4132d 100644
--- a/src/bin/lttng-sessiond/ust-app.c
+++ b/src/bin/lttng-sessiond/ust-app.c
@@ -207,6 +207,20 @@ void delete_ust_app(struct ust_app *app)
}
/*
+ * Safe RCU protected for freeing ust app channel memory.
+ */
+static void delete_ust_app_channel_rcu(struct rcu_head *head)
+{
+ struct lttng_ht_node_str *node =
+ caa_container_of(head, struct lttng_ht_node_str, head);
+ struct ust_app_channel *ua_chan =
+ caa_container_of(node, struct ust_app_channel, node);
+
+ DBG3("Call RCU deleting app channel %s", ua_chan->name);
+ delete_ust_app_channel(-1, ua_chan);
+}
+
+/*
* URCU intermediate call to delete an UST app.
*/
static
@@ -222,6 +236,26 @@ void delete_ust_app_rcu(struct rcu_head *head)
}
/*
+ * Safely remove a ust app channel from the ust app session channel hash table
+ * and free the memory inside a RCU call.
+ */
+static void safe_delete_ust_app_channel(struct ust_app_session *ua_sess,
+ struct ust_app_channel *ua_chan)
+{
+ struct lttng_ht_node_str *node;
+ struct lttng_ht_iter iter;
+
+ lttng_ht_lookup(ua_sess->channels, (void *) ua_chan->name, &iter);
+ node = lttng_ht_iter_get_node_str(&iter);
+ if (node == NULL) {
+ return;
+ }
+
+ lttng_ht_del(ua_sess->channels, &iter);
+ call_rcu(&node->head, delete_ust_app_channel_rcu);
+}
+
+/*
* Alloc new UST app session.
*/
static
@@ -2257,7 +2291,13 @@ void ust_app_global_update(struct ltt_ust_session *usess, int sock)
node.node) {
ret = create_ust_channel(app, ua_sess, ua_chan);
if (ret < 0) {
- /* FIXME: Should we quit here or continue... */
+ /*
+ * This means that something went wrong with what we've passed to
+ * the tracer so we must destroy this object from the ust app
+ * session since it's not valid anymore. This fix is related to
+ * issue #89
+ */
+ safe_delete_ust_app_channel(ua_sess, ua_chan);
continue;
}
@@ -2270,7 +2310,6 @@ void ust_app_global_update(struct ltt_ust_session *usess, int sock)
}
}
-
/* For each events */
cds_lfht_for_each_entry(ua_chan->events->ht, &uiter.iter, ua_event,
node.node) {
--
1.7.9
More information about the lttng-dev
mailing list