X-Git-Url: https://git.liburcu.org/?a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Fnotification-thread-commands.c;h=2908ccb76d3cdee0ade33cee9ccbd9b2c5d9e850;hb=3a5f70173aa04d11ccb22694d5d31a702cad33ab;hp=7d47b77459d3aa4f149e2df52e5b4aa81c6ceb07;hpb=d02d7404fac685cd836b53e121afc64af71af140;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 7d47b7745..2908ccb76 100644 --- a/src/bin/lttng-sessiond/notification-thread-commands.c +++ b/src/bin/lttng-sessiond/notification-thread-commands.c @@ -111,18 +111,21 @@ error: enum lttng_error_code notification_thread_command_register_trigger( struct notification_thread_handle *handle, - struct lttng_trigger *trigger) + struct lttng_trigger *trigger, + bool is_trigger_anonymous) { int ret; enum lttng_error_code ret_code; struct notification_thread_command cmd = {}; - assert(trigger); + LTTNG_ASSERT(trigger); init_notification_thread_command(&cmd); cmd.type = NOTIFICATION_COMMAND_TYPE_REGISTER_TRIGGER; lttng_trigger_get(trigger); - cmd.parameters.trigger = trigger; + cmd.parameters.register_trigger.trigger = trigger; + cmd.parameters.register_trigger.is_trigger_anonymous = + is_trigger_anonymous; ret = run_command_wait(handle, &cmd); if (ret) { @@ -136,7 +139,7 @@ end: enum lttng_error_code notification_thread_command_unregister_trigger( struct notification_thread_handle *handle, - struct lttng_trigger *trigger) + const struct lttng_trigger *trigger) { int ret; enum lttng_error_code ret_code; @@ -145,7 +148,7 @@ enum lttng_error_code notification_thread_command_unregister_trigger( init_notification_thread_command(&cmd); cmd.type = NOTIFICATION_COMMAND_TYPE_UNREGISTER_TRIGGER; - cmd.parameters.trigger = trigger; + cmd.parameters.unregister_trigger.trigger = trigger; ret = run_command_wait(handle, &cmd); if (ret) { @@ -279,7 +282,7 @@ enum lttng_error_code notification_thread_command_add_tracer_event_source( enum lttng_error_code ret_code; struct notification_thread_command cmd = {}; - assert(tracer_event_source_fd >= 0); + LTTNG_ASSERT(tracer_event_source_fd >= 0); init_notification_thread_command(&cmd); @@ -333,8 +336,8 @@ enum lttng_error_code notification_thread_command_list_triggers( enum lttng_error_code ret_code; struct notification_thread_command cmd = {}; - assert(handle); - assert(triggers); + LTTNG_ASSERT(handle); + LTTNG_ASSERT(triggers); init_notification_thread_command(&cmd); @@ -364,7 +367,7 @@ void notification_thread_command_quit( cmd.type = NOTIFICATION_COMMAND_TYPE_QUIT; ret = run_command_wait(handle, &cmd); - assert(!ret && cmd.reply_code == LTTNG_OK); + LTTNG_ASSERT(!ret && cmd.reply_code == LTTNG_OK); } int notification_thread_client_communication_update( @@ -381,3 +384,69 @@ 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. + */ +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; + + LTTNG_ASSERT(domain != LTTNG_DOMAIN_NONE); + LTTNG_ASSERT((payload && payload_size) || (!payload && !payload_size)); + + notification = zmalloc(sizeof(struct lttng_event_notifier_notification)); + if (notification == NULL) { + ERR("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; +} + +void lttng_event_notifier_notification_destroy( + struct lttng_event_notifier_notification *notification) +{ + if (!notification) { + return; + } + + free(notification->capture_buffer); + free(notification); +}