free(trigger_ht_element);
error:
if (free_trigger) {
- struct lttng_action *action = lttng_trigger_get_action(trigger);
-
- lttng_condition_destroy(condition);
- lttng_action_destroy(action);
lttng_trigger_destroy(trigger);
}
rcu_read_unlock();
struct lttng_trigger_ht_element *trigger_ht_element = NULL;
struct lttng_condition *condition = lttng_trigger_get_condition(
trigger);
- struct lttng_action *action;
enum lttng_error_code cmd_reply;
rcu_read_lock();
struct lttng_trigger_ht_element, node);
cds_lfht_del(state->triggers_ht, triggers_ht_node);
- condition = lttng_trigger_get_condition(trigger_ht_element->trigger);
- lttng_condition_destroy(condition);
- action = lttng_trigger_get_action(trigger_ht_element->trigger);
- lttng_action_destroy(action);
+ /* Release the ownership of the trigger. */
lttng_trigger_destroy(trigger_ht_element->trigger);
call_rcu(&trigger_ht_element->rcu_node, free_lttng_trigger_ht_element_rcu);
end:
goto end;
}
+ lttng_condition_get(condition);
trigger->condition = condition;
+
+ lttng_action_get(action);
trigger->action = action;
end:
return trigger;
}
+/*
+ * Note: the lack of reference counting 'get' on the condition object is normal.
+ * This API was exposed as such in 2.11. The client is not expected to call
+ * lttng_condition_destroy on the returned object.
+ */
struct lttng_condition *lttng_trigger_get_condition(
struct lttng_trigger *trigger)
{
return trigger->condition;
}
+
+/*
+ * Note: the lack of reference counting 'get' on the action object is normal.
+ * This API was exposed as such in 2.11. The client is not expected to call
+ * lttng_action_destroy on the returned object.
+ */
struct lttng_action *lttng_trigger_get_action(
struct lttng_trigger *trigger)
{
void lttng_trigger_destroy(struct lttng_trigger *trigger)
{
+ struct lttng_action *action = lttng_trigger_get_action(trigger);
+ struct lttng_condition *condition =
+ lttng_trigger_get_condition(trigger);
+
if (!trigger) {
return;
}
+ assert(action);
+ assert(condition);
+
+ /* Release ownership. */
+ lttng_action_put(action);
+ lttng_condition_put(condition);
+
free(trigger);
}
goto error;
}
+ /*
+ * The trigger object owns references to the action and condition
+ * objects.
+ */
+ lttng_condition_put(condition);
+ condition = NULL;
+
+ lttng_action_put(action);
+ action = NULL;
+
ret = offset;
-end:
- return ret;
+
error:
lttng_condition_destroy(condition);
lttng_action_destroy(action);
+end:
return ret;
}