X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Fnotification-thread-commands.c;h=b1b33343ba5da6ec663a981d944e70f9256861c6;hb=c0e2990d32d1e55c783c7eb3299f23a7ce062270;hp=7cbd5d509a81a5e1167c8ae00250fd45831cceb0;hpb=ac16173e318279dee29504820e3c2ad8ea597712;p=lttng-tools.git diff --git a/src/bin/lttng-sessiond/notification-thread-commands.c b/src/bin/lttng-sessiond/notification-thread-commands.c index 7cbd5d509..b1b33343b 100644 --- a/src/bin/lttng-sessiond/notification-thread-commands.c +++ b/src/bin/lttng-sessiond/notification-thread-commands.c @@ -381,3 +381,45 @@ int notification_thread_client_communication_update( cmd.parameters.client_communication_update.status = transmission_status; return run_command_no_wait(handle, &cmd); } + +/* + * 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); +}