#include <lttng/trigger/trigger-internal.h>
#include <lttng/condition/condition-internal.h>
#include <lttng/action/action-internal.h>
-#include <common/sessiond-comm/payload.h>
-#include <common/sessiond-comm/payload-view.h>
+#include <common/credentials.h>
+#include <common/payload.h>
+#include <common/payload-view.h>
#include <common/error.h>
+#include <common/optional.h>
#include <assert.h>
LTTNG_HIDDEN
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;
}
end:
return ret;
}
+
+LTTNG_HIDDEN
+const struct lttng_credentials *lttng_trigger_get_credentials(
+ const struct lttng_trigger *trigger)
+{
+ return LTTNG_OPTIONAL_GET_PTR(trigger->creds);
+}
+
+LTTNG_HIDDEN
+void lttng_trigger_set_credentials(
+ struct lttng_trigger *trigger,
+ const struct lttng_credentials *creds)
+{
+ assert(creds);
+ LTTNG_OPTIONAL_SET(&trigger->creds, *creds);
+}