X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fcommon%2Factions%2Fnotify.c;h=c34f3845f7423725f5f0c5a83e5be0f9bb7c3bf3;hb=7966af5763c4aaca39df9bbfa9277ff15715c720;hp=0ab88be44fe6397ab7351dc058a3057dfef2c8a2;hpb=7f4d5b07cf7be895b38b69073389a4fcc318ec29;p=lttng-tools.git diff --git a/src/common/actions/notify.c b/src/common/actions/notify.c index 0ab88be44..c34f3845f 100644 --- a/src/common/actions/notify.c +++ b/src/common/actions/notify.c @@ -5,12 +5,13 @@ * */ -#include #include #include +#include #include #include #include +#include #define IS_NOTIFY_ACTION(action) \ (lttng_action_get_type(action) == LTTNG_ACTION_TYPE_NOTIFY) @@ -18,7 +19,7 @@ static struct lttng_action_notify *action_notify_from_action( struct lttng_action *action) { - assert(action); + LTTNG_ASSERT(action); return container_of(action, struct lttng_action_notify, parent); } @@ -26,7 +27,7 @@ static struct lttng_action_notify *action_notify_from_action( static const struct lttng_action_notify *action_notify_from_action_const( const struct lttng_action *action) { - assert(action); + LTTNG_ASSERT(action); return container_of(action, struct lttng_action_notify, parent); } @@ -82,6 +83,49 @@ lttng_action_notify_internal_get_rate_policy(const struct lttng_action *action) return _action->policy; } +static enum lttng_error_code lttng_action_notify_mi_serialize( + const struct lttng_action *action, struct mi_writer *writer) +{ + int ret; + enum lttng_action_status status; + enum lttng_error_code ret_code; + const struct lttng_rate_policy *policy = NULL; + + LTTNG_ASSERT(action); + LTTNG_ASSERT(IS_NOTIFY_ACTION(action)); + LTTNG_ASSERT(writer); + + status = lttng_action_notify_get_rate_policy(action, &policy); + LTTNG_ASSERT(status == LTTNG_ACTION_STATUS_OK); + LTTNG_ASSERT(policy != NULL); + + /* Open action notify. */ + ret = mi_lttng_writer_open_element( + writer, mi_lttng_element_action_notify); + if (ret) { + goto mi_error; + } + + ret_code = lttng_rate_policy_mi_serialize(policy, writer); + if (ret_code != LTTNG_OK) { + goto end; + } + + /* Close action notify element. */ + ret = mi_lttng_writer_close_element(writer); + if (ret) { + goto mi_error; + } + + ret_code = LTTNG_OK; + goto end; + +mi_error: + ret_code = LTTNG_ERR_MI_IO_FAIL; +end: + return ret_code; +} + struct lttng_action *lttng_action_notify_create(void) { struct lttng_rate_policy *policy = NULL; @@ -103,7 +147,9 @@ struct lttng_action *lttng_action_notify_create(void) lttng_action_notify_serialize, lttng_action_notify_is_equal, lttng_action_notify_destroy, - lttng_action_notify_internal_get_rate_policy); + lttng_action_notify_internal_get_rate_policy, + lttng_action_generic_add_error_query_results, + lttng_action_notify_mi_serialize); notify->policy = policy; policy = NULL;