struct lttng_notification {
struct lttng_condition *condition;
struct lttng_evaluation *evaluation;
- /*
- * The ownership of the notification's inner-elements depends
- * on the way it was created. The notification owns both
- * the condition and evaluation if it was obtained from a notification
- * channel (i.e. created using lttng_notification_create_from_buffer)
- * as the user may never access the condition and evaluation,
- * thus never getting a chance to free them.
- *
- * However, when the _private_ lttng_notification_create() function
- * is used, no ownership of condition and evaluation is assumed by
- * the notification object. The main reason for this change in
- * behavior is that internal users of this API only use the object
- * to use its serialization facilities.
- */
- bool owns_elements;
};
struct lttng_notification_comm {
struct lttng_evaluation *evaluation);
LTTNG_HIDDEN
-int lttng_notification_serialize(struct lttng_notification *notification,
+int lttng_notification_serialize(const struct lttng_notification *notification,
struct lttng_dynamic_buffer *buf);
LTTNG_HIDDEN
#include <common/sessiond-comm/sessiond-comm.h>
#include <common/macros.h>
#include <lttng/condition/condition.h>
-#include <lttng/action/action.h>
+#include <lttng/action/action-internal.h>
#include <lttng/notification/notification-internal.h>
#include <lttng/condition/condition-internal.h>
#include <lttng/condition/buffer-usage-internal.h>
uint64_t latest_session_consumed_total,
struct channel_info *channel_info);
static
-int send_evaluation_to_clients(struct lttng_trigger *trigger,
- struct lttng_evaluation *evaluation,
+int send_evaluation_to_clients(const struct lttng_trigger *trigger,
+ const struct lttng_evaluation *evaluation,
struct notification_client_list *client_list,
struct notification_thread_state *state,
uid_t channel_uid, gid_t channel_gid);
static
unsigned long lttng_condition_buffer_usage_hash(
- struct lttng_condition *_condition)
+ const struct lttng_condition *_condition)
{
unsigned long hash = 0;
struct lttng_condition_buffer_usage *condition;
static
unsigned long lttng_condition_session_consumed_size_hash(
- struct lttng_condition *_condition)
+ const struct lttng_condition *_condition)
{
unsigned long hash = 0;
struct lttng_condition_session_consumed_size *condition;
* don't want to link in liblttng-ctl.
*/
static
-unsigned long lttng_condition_hash(struct lttng_condition *condition)
+unsigned long lttng_condition_hash(const struct lttng_condition *condition)
{
switch (condition->type) {
case LTTNG_CONDITION_TYPE_BUFFER_USAGE_LOW:
struct lttng_trigger_list_element *element;
cds_list_for_each_entry(element, &channel_trigger_list->list, node) {
- struct lttng_condition *current_condition =
- lttng_trigger_get_condition(
+ const struct lttng_condition *current_condition =
+ lttng_trigger_get_const_condition(
element->trigger);
assert(current_condition);
}
cds_lfht_add(state->sessions_ht, hash_key_str(name, lttng_ht_seed),
- &sessions->sessions_ht_node);
+ &session->sessions_ht_node);
end:
rcu_read_unlock();
return session;
cds_list_for_each_entry_safe(trigger_element, tmp,
&trigger_list->list, node) {
- struct lttng_condition *current_condition =
- lttng_trigger_get_condition(
+ const struct lttng_condition *current_condition =
+ lttng_trigger_get_const_condition(
trigger_element->trigger);
assert(current_condition);
}
static
-int send_evaluation_to_clients(struct lttng_trigger *trigger,
- struct lttng_evaluation *evaluation,
+int send_evaluation_to_clients(const struct lttng_trigger *trigger,
+ const struct lttng_evaluation *evaluation,
struct notification_client_list* client_list,
struct notification_thread_state *state,
uid_t channel_uid, gid_t channel_gid)
int ret = 0;
struct lttng_dynamic_buffer msg_buffer;
struct notification_client_list_element *client_list_element, *tmp;
- struct lttng_notification *notification;
- struct lttng_condition *condition;
+ const struct lttng_notification notification = {
+ .condition = (struct lttng_condition *) lttng_trigger_get_const_condition(trigger),
+ .evaluation = (struct lttng_evaluation *) evaluation,
+ };
struct lttng_notification_channel_message msg_header = {
.type = (int8_t) LTTNG_NOTIFICATION_CHANNEL_MESSAGE_TYPE_NOTIFICATION,
};
lttng_dynamic_buffer_init(&msg_buffer);
- condition = lttng_trigger_get_condition(trigger);
- assert(condition);
-
- notification = lttng_notification_create(condition, evaluation);
- if (!notification) {
- ret = -1;
- goto end;
- }
-
ret = lttng_dynamic_buffer_append(&msg_buffer, &msg_header,
sizeof(msg_header));
if (ret) {
goto end;
}
- ret = lttng_notification_serialize(notification, &msg_buffer);
+ ret = lttng_notification_serialize(¬ification, &msg_buffer);
if (ret) {
ERR("[notification-thread] Failed to serialize notification");
ret = -1;
}
ret = 0;
end:
- lttng_notification_destroy(notification);
lttng_dynamic_buffer_reset(&msg_buffer);
return ret;
}
channel_triggers_ht_node);
cds_list_for_each_entry(trigger_list_element, &trigger_list->list,
node) {
- struct lttng_condition *condition;
- struct lttng_action *action;
- struct lttng_trigger *trigger;
+ const struct lttng_condition *condition;
+ const struct lttng_action *action;
+ const struct lttng_trigger *trigger;
struct notification_client_list *client_list;
struct lttng_evaluation *evaluation = NULL;
trigger = trigger_list_element->trigger;
- condition = lttng_trigger_get_condition(trigger);
+ condition = lttng_trigger_get_const_condition(trigger);
assert(condition);
- action = lttng_trigger_get_action(trigger);
+ action = lttng_trigger_get_const_action(trigger);
/* Notify actions are the only type currently supported. */
- assert(lttng_action_get_type(action) ==
+ assert(lttng_action_get_type_const(action) ==
LTTNG_ACTION_TYPE_NOTIFY);
/*