#include <common/macros.h>
#include <lttng/condition/condition.h>
#include <lttng/action/action-internal.h>
#include <common/macros.h>
#include <lttng/condition/condition.h>
#include <lttng/action/action-internal.h>
#include <lttng/domain-internal.h>
#include <lttng/notification/notification-internal.h>
#include <lttng/condition/condition-internal.h>
#include <lttng/condition/buffer-usage-internal.h>
#include <lttng/condition/session-consumed-size-internal.h>
#include <lttng/condition/session-rotation-internal.h>
#include <lttng/domain-internal.h>
#include <lttng/notification/notification-internal.h>
#include <lttng/condition/condition-internal.h>
#include <lttng/condition/buffer-usage-internal.h>
#include <lttng/condition/session-consumed-size-internal.h>
#include <lttng/condition/session-rotation-internal.h>
#include <lttng/domain-internal.h>
#include <lttng/notification/channel-internal.h>
#include <lttng/trigger/trigger-internal.h>
#include <lttng/domain-internal.h>
#include <lttng/notification/channel-internal.h>
#include <lttng/trigger/trigger-internal.h>
- status = lttng_trigger_get_name(trigger_ht_element->trigger, &name);
- assert(status == LTTNG_TRIGGER_STATUS_OK);
+ status = lttng_trigger_get_name(trigger_ht_element->trigger,
+ &element_trigger_name);
+ element_trigger_name = status == LTTNG_TRIGGER_STATUS_OK ?
+ element_trigger_name : NULL;
- /* Compare the names. */
- if (strcmp(name, key_name) != 0) {
+ /*
+ * Compare the names.
+ * Consider null names as not equal. This is to maintain backwards
+ * compatibility with pre-2.13 anonymous triggers. Multiples anonymous
+ * triggers are allowed for a given user.
+ */
+ if (!element_trigger_name || !key_name) {
+ goto end;
+ }
+
+ if (strcmp(element_trigger_name, key_name) != 0) {
case LTTNG_CONDITION_TYPE_SESSION_ROTATION_ONGOING:
case LTTNG_CONDITION_TYPE_SESSION_ROTATION_COMPLETED:
return LTTNG_OBJECT_TYPE_SESSION;
case LTTNG_CONDITION_TYPE_SESSION_ROTATION_ONGOING:
case LTTNG_CONDITION_TYPE_SESSION_ROTATION_COMPLETED:
return LTTNG_OBJECT_TYPE_SESSION;
if (session_info->channel_infos_ht) {
ret = cds_lfht_destroy(session_info->channel_infos_ht, NULL);
if (ret) {
if (session_info->channel_infos_ht) {
ret = cds_lfht_destroy(session_info->channel_infos_ht, NULL);
if (ret) {
&evaluation, &object_uid, &object_gid);
break;
case LTTNG_OBJECT_TYPE_NONE:
&evaluation, &object_uid, &object_gid);
break;
case LTTNG_OBJECT_TYPE_NONE:
cds_list_add(&client_list_element.node, &client_list.clients_list);
/* Send evaluation result to the newly-subscribed client. */
cds_list_add(&client_list_element.node, &client_list.clients_list);
/* Send evaluation result to the newly-subscribed client. */
ret = send_evaluation_to_clients(trigger, evaluation, &client_list,
state, object_uid, object_gid);
ret = send_evaluation_to_clients(trigger, evaluation, &client_list,
state, object_uid, object_gid);
pthread_mutex_lock(&client_list->lock);
cds_list_for_each_entry(trigger_ht_element,
&client_list->triggers_list, client_list_trigger_node) {
pthread_mutex_lock(&client_list->lock);
cds_list_for_each_entry(trigger_ht_element,
&client_list->triggers_list, client_list_trigger_node) {
* Not an error, the list of triggers applying to that session
* will be initialized when the session is created.
*/
* Not an error, the list of triggers applying to that session
* will be initialized when the session is created.
*/
condition_status = lttng_condition_session_rotation_get_session_name(
condition, &condition_session_name);
if (condition_status != LTTNG_CONDITION_STATUS_OK) {
condition_status = lttng_condition_session_rotation_get_session_name(
condition, &condition_session_name);
if (condition_status != LTTNG_CONDITION_STATUS_OK) {
session = session_info_create(name, uid, gid, trigger_list,
state->sessions_ht);
if (!session) {
session = session_info_create(name, uid, gid, trigger_list,
state->sessions_ht);
if (!session) {
channel_name, session_name, channel_key_int,
lttng_domain_type_str(channel_domain));
channel_name, session_name, channel_key_int,
lttng_domain_type_str(channel_domain));
struct channel_key key = { .key = channel_key, .domain = domain };
struct channel_info *channel_info;
struct channel_key key = { .key = channel_key, .domain = domain };
struct channel_info *channel_info;
session_info->rotation.id = trace_archive_chunk_id;
trigger_list = get_session_trigger_list(state, session_name);
if (!trigger_list) {
session_info->rotation.id = trace_archive_chunk_id;
trigger_list = get_session_trigger_list(state, session_name);
if (!trigger_list) {
- DBG3("[notification-thread] Adding tracer event source fd to poll set: tracer_event_source_fd = %d, domain = '%s'",
+ DBG3("Adding tracer event source fd to poll set: tracer_event_source_fd = %d, domain = '%s'",
tracer_event_source_fd,
lttng_domain_type_str(domain_type));
/* Adding the read side pipe to the event poll. */
ret = lttng_poll_add(&state->events, tracer_event_source_fd, LPOLLIN | LPOLLERR);
if (ret < 0) {
tracer_event_source_fd,
lttng_domain_type_str(domain_type));
/* Adding the read side pipe to the event poll. */
ret = lttng_poll_add(&state->events, tracer_event_source_fd, LPOLLIN | LPOLLERR);
if (ret < 0) {
- ERR("[notification-thread] Failed to add tracer event source to poll set: tracer_event_source_fd = %d, domain = '%s'",
+ ERR("Failed to add tracer event source to poll set: tracer_event_source_fd = %d, domain = '%s'",
- DBG("[notification-thread] Removed tracer event source from poll set: tracer_event_source_fd = %d, domain = '%s'",
+ DBG("Removed tracer event source from poll set: tracer_event_source_fd = %d, domain = '%s'",
- DBG3("[notification-thread] Removing tracer event source from poll set: tracer_event_source_fd = %d, domain = '%s'",
+ DBG3("Removing tracer event source from poll set: tracer_event_source_fd = %d, domain = '%s'",
tracer_event_source_fd,
lttng_domain_type_str(source_element->domain));
/* Removing the fd from the event poll set. */
ret = lttng_poll_del(&state->events, tracer_event_source_fd);
if (ret < 0) {
tracer_event_source_fd,
lttng_domain_type_str(source_element->domain));
/* Removing the fd from the event poll set. */
ret = lttng_poll_del(&state->events, tracer_event_source_fd);
if (ret < 0) {
- ERR("[notification-thread] Failed to remove tracer event source from poll set: tracer_event_source_fd = %d, domain = '%s'",
+ ERR("Failed to remove tracer event source from poll set: tracer_event_source_fd = %d, domain = '%s'",
- ERR("[notification-thread] Error draining event notifier notification: tracer_event_source_fd = %d, domain = %s",
+ ERR("Error draining event notifier notification: tracer_event_source_fd = %d, domain = %s",
/* Not a fatal error if the trigger is not found. */
get_trigger_info_for_log(trigger, &trigger_name, &trigger_owner_uid);
/* Not a fatal error if the trigger is not found. */
get_trigger_info_for_log(trigger, &trigger_name, &trigger_owner_uid);
- ERR("Failed to retrieve registered version of trigger: trigger name = '%s', trigger owner uid = %d",
+ DBG("Failed to retrieve registered version of trigger: trigger name = '%s', trigger owner uid = %d",
{
const struct lttng_event_rule *event_rule;
enum lttng_domain_type domain;
const enum lttng_condition_status status =
{
const struct lttng_event_rule *event_rule;
enum lttng_domain_type domain;
const enum lttng_condition_status status =
status = lttng_condition_session_rotation_get_session_name(
condition, &session_name);
if (status != LTTNG_CONDITION_STATUS_OK) {
status = lttng_condition_session_rotation_get_session_name(
condition, &session_name);
if (status != LTTNG_CONDITION_STATUS_OK) {
CDS_INIT_LIST_HEAD(&trigger_list_element->node);
trigger_list_element->trigger = trigger;
cds_list_add(&trigger_list_element->node, &trigger_list->list);
CDS_INIT_LIST_HEAD(&trigger_list_element->node);
trigger_list_element->trigger = trigger;
cds_list_add(&trigger_list_element->node, &trigger_list->list);
assert(action_status == LTTNG_ACTION_STATUS_OK);
for (i = 0; i < count; i++) {
const struct lttng_action *inner_action =
assert(action_status == LTTNG_ACTION_STATUS_OK);
for (i = 0; i < count; i++) {
const struct lttng_action *inner_action =
trigger, &error_counter_index);
if (error_accounting_status != EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_OK) {
if (error_accounting_status == EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_NO_INDEX_AVAILABLE) {
trigger, &error_counter_index);
if (error_accounting_status != EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_OK) {
if (error_accounting_status == EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_NO_INDEX_AVAILABLE) {
ret = LTTNG_ERR_EVENT_NOTIFIER_ERROR_ACCOUNTING_FULL;
} else {
ERR("Error registering trigger for error accounting");
ret = LTTNG_ERR_EVENT_NOTIFIER_ERROR_ACCOUNTING_FULL;
} else {
ERR("Error registering trigger for error accounting");
int handle_notification_thread_command_register_trigger(
struct notification_thread_state *state,
struct lttng_trigger *trigger,
int handle_notification_thread_command_register_trigger(
struct notification_thread_state *state,
struct lttng_trigger *trigger,
/* Set the trigger's tracer token. */
lttng_trigger_set_tracer_token(trigger, trigger_tracer_token);
/* Set the trigger's tracer token. */
lttng_trigger_set_tracer_token(trigger, trigger_tracer_token);
- if (lttng_trigger_get_name(trigger, &trigger_name) ==
- LTTNG_TRIGGER_STATUS_UNSET) {
- const enum lttng_error_code ret_code = generate_trigger_name(
- state, trigger, &trigger_name);
+ if (!is_trigger_anonymous) {
+ if (lttng_trigger_get_name(trigger, &trigger_name) ==
+ LTTNG_TRIGGER_STATUS_UNSET) {
+ const enum lttng_error_code ret_code =
+ generate_trigger_name(state, trigger,
+ &trigger_name);
- if (ret_code != LTTNG_OK) {
- /* Fatal error. */
- ret = -1;
- *cmd_result = ret_code;
+ if (ret_code != LTTNG_OK) {
+ /* Fatal error. */
+ ret = -1;
+ *cmd_result = ret_code;
+ goto error;
+ }
+ } else if (trigger_name_taken(state, trigger)) {
+ /* Not a fatal error. */
+ *cmd_result = LTTNG_ERR_TRIGGER_EXISTS;
+ ret = 0;
- } else if (trigger_name_taken(state, trigger)) {
- /* Not a fatal error. */
- *cmd_result = LTTNG_ERR_TRIGGER_EXISTS;
- ret = 0;
- goto error;
+ } else {
+ trigger_name = "(anonymous)";
- /* Not a fatal error, simply report it to the client. */
- cds_lfht_del(state->triggers_ht, &trigger_ht_element->node);
- *cmd_result = LTTNG_ERR_TRIGGER_EXISTS;
+ /* Internal error: add to triggers_ht should have failed. */
+ ret = -1;
cds_lfht_del(state->trigger_tokens_ht,
&trigger_tokens_ht_element->node);
cds_lfht_del(state->trigger_tokens_ht,
&trigger_tokens_ht_element->node);
notification_command_type_str(cmd->type));
switch (cmd->type) {
case NOTIFICATION_COMMAND_TYPE_REGISTER_TRIGGER:
ret = handle_notification_thread_command_register_trigger(state,
cmd->parameters.register_trigger.trigger,
notification_command_type_str(cmd->type));
switch (cmd->type) {
case NOTIFICATION_COMMAND_TYPE_REGISTER_TRIGGER:
ret = handle_notification_thread_command_register_trigger(state,
cmd->parameters.register_trigger.trigger,
client_socket);
client = get_client_from_socket(client_socket, state);
if (!client) {
/* Internal state corruption, fatal error. */
client_socket);
client = get_client_from_socket(client_socket, state);
if (!client) {
/* Internal state corruption, fatal error. */
cds_lfht_for_each_entry(state->client_socket_ht, &iter, client,
client_socket_ht_node) {
int ret;
cds_lfht_for_each_entry(state->client_socket_ht, &iter, client,
client_socket_ht_node) {
int ret;
client->socket);
ret = lttcomm_send_unix_sock_non_block(client->socket,
pv.buffer.data,
to_send_count);
if ((ret >= 0 && ret < to_send_count)) {
client->socket);
ret = lttcomm_send_unix_sock_non_block(client->socket,
pv.buffer.data,
to_send_count);
if ((ret >= 0 && ret < to_send_count)) {
memcpy(buffer, &msg, sizeof(msg));
memcpy(buffer + sizeof(msg), &reply, sizeof(reply));
memcpy(buffer, &msg, sizeof(msg));
memcpy(buffer + sizeof(msg), &reply, sizeof(reply));
client->major = handshake_client->major;
client->minor = handshake_client->minor;
if (!client->communication.inbound.creds_received) {
client->major = handshake_client->major;
client->minor = handshake_client->minor;
if (!client->communication.inbound.creds_received) {
&client->communication.inbound.creds);
client->gid = LTTNG_SOCK_GET_GID_CRED(
&client->communication.inbound.creds);
&client->communication.inbound.creds);
client->gid = LTTNG_SOCK_GET_GID_CRED(
&client->communication.inbound.creds);
client->uid, client->gid, (int) client->major,
(int) client->minor);
client->uid, client->gid, (int) client->major,
(int) client->minor);
/* Set reception state to receive the next message header. */
ret = client_reset_inbound_state(client);
if (ret) {
/* Set reception state to receive the next message header. */
ret = client_reset_inbound_state(client);
if (ret) {
goto end;
}
/* Flushes the outgoing queue. */
ret = client_send_command_reply(client, state, status);
if (ret) {
goto end;
}
/* Flushes the outgoing queue. */
ret = client_send_command_reply(client, state, status);
if (ret) {
expected_condition_size = client->communication.inbound.payload.buffer.size;
ret = lttng_condition_create_from_payload(&condition_view, &condition);
if (ret != expected_condition_size) {
expected_condition_size = client->communication.inbound.payload.buffer.size;
ret = lttng_condition_create_from_payload(&condition_view, &condition);
if (ret != expected_condition_size) {
if (msg_type == LTTNG_NOTIFICATION_CHANNEL_MESSAGE_TYPE_SUBSCRIBE) {
ret = notification_thread_client_subscribe(
client, condition, state, &status);
if (msg_type == LTTNG_NOTIFICATION_CHANNEL_MESSAGE_TYPE_SUBSCRIBE) {
ret = notification_thread_client_subscribe(
client, condition, state, &status);
/* Set reception state to receive the next message header. */
ret = client_reset_inbound_state(client);
if (ret) {
/* Set reception state to receive the next message header. */
ret = client_reset_inbound_state(client);
if (ret) {
offset = client->communication.inbound.payload.buffer.size -
client->communication.inbound.bytes_to_receive;
if (client->communication.inbound.expect_creds) {
offset = client->communication.inbound.payload.buffer.size -
client->communication.inbound.bytes_to_receive;
if (client->communication.inbound.expect_creds) {
condition_type = lttng_condition_get_type(condition);
if (condition_type == LTTNG_CONDITION_TYPE_BUFFER_USAGE_LOW) {
condition_type = lttng_condition_get_type(condition);
if (condition_type == LTTNG_CONDITION_TYPE_BUFFER_USAGE_LOW) {
- DBG("[notification-thread] Low buffer usage condition being evaluated: threshold = %" PRIu64 ", highest usage = %" PRIu64,
+ DBG("Low buffer usage condition being evaluated: threshold = %" PRIu64 ", highest usage = %" PRIu64,
- DBG("[notification-thread] High buffer usage condition being evaluated: threshold = %" PRIu64 ", highest usage = %" PRIu64,
+ DBG("High buffer usage condition being evaluated: threshold = %" PRIu64 ", highest usage = %" PRIu64,
- DBG("[notification-thread] Session consumed size condition being evaluated: threshold = %" PRIu64 ", current size = %" PRIu64,
+ DBG("Session consumed size condition being evaluated: threshold = %" PRIu64 ", current size = %" PRIu64,
threshold, session_consumed_size);
return session_consumed_size >= threshold;
}
threshold, session_consumed_size);
return session_consumed_size >= threshold;
}
client->socket, msg_payload.buffer.size);
if (client_has_outbound_data_left(client)) {
client->socket, msg_payload.buffer.size);
if (client_has_outbound_data_left(client)) {
- ERR("[notification-thread] Event notifier has a capture payload size which exceeds the maximum allowed size: capture_payload_size = %zu bytes, max allowed size = %d bytes",
+ ERR("Event notifier has a capture payload size which exceeds the maximum allowed size: capture_payload_size = %zu bytes, max allowed size = %d bytes",
capture_buffer_size, MAX_CAPTURE_SIZE);
goto end;
}
capture_buffer = zmalloc(capture_buffer_size);
if (!capture_buffer) {
capture_buffer_size, MAX_CAPTURE_SIZE);
goto end;
}
capture_buffer = zmalloc(capture_buffer_size);
if (!capture_buffer) {
goto end;
}
/* Fetch additional payload (capture). */
ret = lttng_read(notification_pipe_read_fd, capture_buffer, capture_buffer_size);
if (ret != capture_buffer_size) {
goto end;
}
/* Fetch additional payload (capture). */
ret = lttng_read(notification_pipe_read_fd, capture_buffer, capture_buffer_size);
if (ret != capture_buffer_size) {
struct cds_lfht_node *node;
struct cds_lfht_iter iter;
struct notification_trigger_tokens_ht_element *element;
struct cds_lfht_node *node;
struct cds_lfht_iter iter;
struct notification_trigger_tokens_ht_element *element;
struct lttng_evaluation *evaluation = NULL;
enum action_executor_status executor_status;
struct notification_client_list *client_list = NULL;
struct lttng_evaluation *evaluation = NULL;
enum action_executor_status executor_status;
struct notification_client_list *client_list = NULL;
- trigger_status = lttng_trigger_get_name(element->trigger, &trigger_name);
- assert(trigger_status == LTTNG_TRIGGER_STATUS_OK);
-
- if (lttng_condition_on_event_get_capture_descriptor_count(
+ if (lttng_condition_event_rule_matches_get_capture_descriptor_count(
lttng_trigger_get_const_condition(element->trigger),
&capture_count) != LTTNG_CONDITION_STATUS_OK) {
ERR("Failed to get capture count");
lttng_trigger_get_const_condition(element->trigger),
&capture_count) != LTTNG_CONDITION_STATUS_OK) {
ERR("Failed to get capture count");
parent),
notification->capture_buffer,
notification->capture_buf_size, false);
if (evaluation == NULL) {
parent),
notification->capture_buffer,
notification->capture_buf_size, false);
if (evaluation == NULL) {
client_list = get_client_list_from_condition(state,
lttng_trigger_get_const_condition(element->trigger));
executor_status = action_executor_enqueue_trigger(state->executor,
client_list = get_client_list_from_condition(state,
lttng_trigger_get_const_condition(element->trigger));
executor_status = action_executor_enqueue_trigger(state->executor,
notification = recv_one_event_notifier_notification(pipe, domain);
if (notification == NULL) {
/* Reception failed, don't consider it fatal. */
notification = recv_one_event_notifier_notification(pipe, domain);
if (notification == NULL) {
/* Reception failed, don't consider it fatal. */
- ERR("[notification-thread] Error receiving an event notifier notification from tracer: fd = %i, domain = %s",
+ ERR("Error receiving an event notifier notification from tracer: fd = %i, domain = %s",
pipe, lttng_domain_type_str(domain));
goto end;
}
ret = dispatch_one_event_notifier_notification(state, notification);
if (ret) {
pipe, lttng_domain_type_str(domain));
goto end;
}
ret = dispatch_one_event_notifier_notification(state, notification);
if (ret) {
- ERR("[notification-thread] Error dispatching an event notifier notification from tracer: fd = %i, domain = %s",
+ ERR("Error dispatching an event notifier notification from tracer: fd = %i, domain = %s",
*/
ret = lttng_read(pipe, &sample_msg, sizeof(sample_msg));
if (ret != sizeof(sample_msg)) {
*/
ret = lttng_read(pipe, &sample_msg, sizeof(sample_msg));
if (ret != sizeof(sample_msg)) {
- DBG("[notification-thread] Received a sample for an unknown channel from consumerd, key = %" PRIu64 " in %s domain",
+ DBG("Received a sample for an unknown channel from consumerd, key = %" PRIu64 " in %s domain",
latest_sample.key.key,
lttng_domain_type_str(domain));
goto end_unlock;
}
channel_info = caa_container_of(node, struct channel_info,
channels_ht_node);
latest_sample.key.key,
lttng_domain_type_str(domain));
goto end_unlock;
}
channel_info = caa_container_of(node, struct channel_info,
channels_ht_node);
- DBG("[notification-thread] Handling channel sample for channel %s (key = %" PRIu64 ") in session %s (highest usage = %" PRIu64 ", lowest usage = %" PRIu64", total consumed = %" PRIu64")",
+ DBG("Handling channel sample for channel %s (key = %" PRIu64 ") in session %s (highest usage = %" PRIu64 ", lowest usage = %" PRIu64", total consumed = %" PRIu64")",