X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fcommon%2Fnotification.c;h=be09c1fcc66249e34f66d16ac3de7212de360f29;hb=37ccf8ecee70257a97ab6939e5dcb0112826f409;hp=a4e971bd572c159b4a54d90643965dd1479b937d;hpb=7c920b632d63ffd82074430d77862176e0fc477c;p=lttng-tools.git diff --git a/src/common/notification.c b/src/common/notification.c index a4e971bd5..be09c1fcc 100644 --- a/src/common/notification.c +++ b/src/common/notification.c @@ -10,18 +10,19 @@ #include #include #include +#include #include #include #include LTTNG_HIDDEN struct lttng_notification *lttng_notification_create( - struct lttng_condition *condition, + struct lttng_trigger *trigger, struct lttng_evaluation *evaluation) { struct lttng_notification *notification = NULL; - if (!condition || !evaluation) { + if (!trigger || !evaluation) { goto end; } @@ -30,7 +31,7 @@ struct lttng_notification *lttng_notification_create( goto end; } - notification->condition = condition; + notification->trigger = trigger; notification->evaluation = evaluation; end: return notification; @@ -53,7 +54,7 @@ int lttng_notification_serialize(const struct lttng_notification *notification, } size_before_payload = payload->buffer.size; - ret = lttng_condition_serialize(notification->condition, + ret = lttng_trigger_serialize(notification->trigger, payload); if (ret) { goto end; @@ -77,9 +78,9 @@ ssize_t lttng_notification_create_from_payload( struct lttng_payload_view *src_view, struct lttng_notification **notification) { - ssize_t ret, notification_size = 0, condition_size, evaluation_size; - struct lttng_condition *condition; - struct lttng_evaluation *evaluation; + ssize_t ret, notification_size = 0, trigger_size, evaluation_size; + struct lttng_trigger *trigger = NULL; + struct lttng_evaluation *evaluation = NULL; const struct lttng_notification_comm *notification_comm; const struct lttng_payload_view notification_comm_view = lttng_payload_view_from_view( @@ -87,13 +88,13 @@ ssize_t lttng_notification_create_from_payload( if (!src_view || !notification) { ret = -1; - goto end; + goto error; } if (!lttng_payload_view_is_valid(¬ification_comm_view)) { /* Payload not large enough to contain the header. */ ret = -1; - goto end; + goto error; } notification_comm = (typeof(notification_comm)) notification_comm_view.buffer.data; @@ -104,16 +105,16 @@ ssize_t lttng_notification_create_from_payload( lttng_payload_view_from_view(src_view, notification_size, -1); - condition_size = lttng_condition_create_from_payload( - &condition_view, &condition); + trigger_size = lttng_trigger_create_from_payload( + &condition_view, &trigger); } - if (condition_size < 0) { - ret = condition_size; - goto end; + if (trigger_size < 0) { + ret = trigger_size; + goto error; } - notification_size += condition_size; + notification_size += trigger_size; { /* struct lttng_evaluation */ @@ -122,33 +123,35 @@ ssize_t lttng_notification_create_from_payload( notification_size, -1); evaluation_size = lttng_evaluation_create_from_payload( - condition, &evaluation_view, &evaluation); + lttng_trigger_get_const_condition(trigger), + &evaluation_view, &evaluation); } if (evaluation_size < 0) { ret = evaluation_size; - goto end; + goto error; } notification_size += evaluation_size; /* Unexpected size of inner-elements; the buffer is corrupted. */ if ((ssize_t) notification_comm->length != - condition_size + evaluation_size) { + trigger_size + evaluation_size) { ret = -1; goto error; } - *notification = lttng_notification_create(condition, evaluation); + *notification = lttng_notification_create(trigger, evaluation); if (!*notification) { ret = -1; goto error; } + ret = notification_size; -end: return ret; + error: - lttng_condition_destroy(condition); + lttng_trigger_destroy(trigger); lttng_evaluation_destroy(evaluation); return ret; } @@ -159,7 +162,7 @@ void lttng_notification_destroy(struct lttng_notification *notification) return; } - lttng_condition_destroy(notification->condition); + lttng_trigger_destroy(notification->trigger); lttng_evaluation_destroy(notification->evaluation); free(notification); } @@ -167,7 +170,7 @@ void lttng_notification_destroy(struct lttng_notification *notification) const struct lttng_condition *lttng_notification_get_condition( struct lttng_notification *notification) { - return notification ? notification->condition : NULL; + return notification ? lttng_trigger_get_const_condition(notification->trigger) : NULL; } const struct lttng_evaluation *lttng_notification_get_evaluation( @@ -175,3 +178,9 @@ const struct lttng_evaluation *lttng_notification_get_evaluation( { return notification ? notification->evaluation : NULL; } + +const struct lttng_trigger *lttng_notification_get_trigger( + struct lttng_notification *notification) +{ + return notification ? notification->trigger : NULL; +}