SoW-2020-0003: Trace Hit Counters
[lttng-tools.git] / src / bin / lttng-sessiond / notification-thread-commands.c
index 7cbd5d509a81a5e1167c8ae00250fd45831cceb0..bc8db39d7e452e14df6053b4116effcbde40415d 100644 (file)
@@ -381,3 +381,71 @@ int notification_thread_client_communication_update(
        cmd.parameters.client_communication_update.status = transmission_status;
        return run_command_no_wait(handle, &cmd);
 }
+
+enum lttng_error_code notification_thread_command_get_trigger(
+               struct notification_thread_handle *handle,
+               const struct lttng_trigger *trigger,
+               struct lttng_trigger **real_trigger)
+{
+       int ret;
+       enum lttng_error_code ret_code;
+       struct notification_thread_command cmd = {};
+
+       init_notification_thread_command(&cmd);
+
+       cmd.type = NOTIFICATION_COMMAND_TYPE_GET_TRIGGER;
+       cmd.parameters.get_trigger.trigger= trigger;
+       ret = run_command_wait(handle, &cmd);
+       if (ret) {
+               ret_code = LTTNG_ERR_UNK;
+               goto end;
+       }
+
+       ret_code = cmd.reply_code;
+       *real_trigger = cmd.reply.get_trigger.trigger;
+
+end:
+       return ret_code;
+}
+
+/*
+ * Takes ownership of the payload if present.
+ */
+LTTNG_HIDDEN
+struct lttng_event_notifier_notification *lttng_event_notifier_notification_create(
+               uint64_t tracer_token,
+               enum lttng_domain_type domain,
+               char *payload,
+               size_t payload_size)
+{
+       struct lttng_event_notifier_notification *notification = NULL;
+
+       assert(domain != LTTNG_DOMAIN_NONE);
+       assert((payload && payload_size) || (!payload && !payload_size));
+
+       notification = zmalloc(sizeof(struct lttng_event_notifier_notification));
+       if (notification == NULL) {
+               ERR("[notification-thread] Error allocating notification");
+               goto end;
+       }
+
+       notification->tracer_token = tracer_token;
+       notification->type = domain;
+       notification->capture_buffer = payload;
+       notification->capture_buf_size = payload_size;
+
+end:
+       return notification;
+}
+
+LTTNG_HIDDEN
+void lttng_event_notifier_notification_destroy(
+               struct lttng_event_notifier_notification *notification)
+{
+       if (!notification) {
+               return;
+       }
+
+       free(notification->capture_buffer);
+       free(notification);
+}
This page took 0.024876 seconds and 5 git commands to generate.