+
+/*
+ * Disable all agent events matching a given name for a given UST session.
+ *
+ * Return LTTNG_OK on success or else a LTTNG_ERR* code.
+ */
+int event_agent_disable(struct ltt_ust_session *usess, struct agent *agt,
+ char *event_name)
+{
+ int ret = LTTNG_OK;
+ struct agent_event *aevent;
+ struct lttng_ht_iter iter;
+ struct lttng_ht_node_str *node;
+
+ assert(agt);
+ assert(usess);
+ assert(event_name);
+
+ DBG("Event agent disabling %s (all loglevels) for session %" PRIu64, event_name, usess->id);
+
+ rcu_read_lock();
+ agent_find_events_by_name(event_name, agt, &iter);
+ node = lttng_ht_iter_get_node_str(&iter);
+
+ if (node == NULL) {
+ DBG2("Event agent NOT found by name %s", event_name);
+ ret = LTTNG_ERR_UST_EVENT_NOT_FOUND;
+ goto end;
+ }
+
+ do {
+ aevent = caa_container_of(node, struct agent_event, node);
+ ret = event_agent_disable_one(usess, agt, aevent);
+
+ if (ret != LTTNG_OK) {
+ goto end;
+ }
+
+ /* Get next duplicate agent event by name. */
+ agent_event_next_duplicate(event_name, agt, &iter);
+ node = lttng_ht_iter_get_node_str(&iter);
+ } while (node);
+end:
+ rcu_read_unlock();
+ return ret;
+}