#include <lttng/condition/condition.h>
#include <lttng/action/action.h>
#include <lttng/channel-internal.h>
+#include <common/string-utils/string-utils.h>
#include "channel.h"
#include "consumer.h"
static pthread_mutex_t relayd_net_seq_idx_lock = PTHREAD_MUTEX_INITIALIZER;
static uint64_t relayd_net_seq_idx;
-static int validate_event_name(const char *);
static int validate_ust_event_name(const char *);
static int cmd_enable_event_internal(struct ltt_session *session,
struct lttng_domain *domain,
/*
* Fill lttng_channel array of all channels.
*/
-static void list_lttng_channels(enum lttng_domain_type domain,
+static ssize_t list_lttng_channels(enum lttng_domain_type domain,
struct ltt_session *session, struct lttng_channel *channels,
- struct lttcomm_channel_extended *chan_exts)
+ struct lttng_channel_extended *chan_exts)
{
- int i = 0, ret;
+ int i = 0, ret = 0;
struct ltt_kernel_channel *kchan;
DBG("Listing channels for session %s", session->name);
cds_list_for_each_entry(kchan,
&session->kernel_session->channel_list.head, list) {
uint64_t discarded_events, lost_packets;
+ struct lttng_channel_extended *extended;
+
+ extended = (struct lttng_channel_extended *)
+ kchan->channel->attr.extended.ptr;
ret = get_kernel_runtime_stats(session, kchan,
&discarded_events, &lost_packets);
chan_exts[i].discarded_events =
discarded_events;
chan_exts[i].lost_packets = lost_packets;
+ chan_exts[i].monitor_timer_interval =
+ extended->monitor_timer_interval;
i++;
}
}
break;
}
+ chan_exts[i].monitor_timer_interval =
+ uchan->monitor_timer_interval;
+
ret = get_ust_runtime_stats(session, uchan,
&discarded_events, &lost_packets);
if (ret < 0) {
}
end:
- return;
+ if (ret < 0) {
+ return -LTTNG_ERR_FATAL;
+ } else {
+ return LTTNG_OK;
+ }
}
static void increment_extended_len(const char *filter_expression,
DBG("Disable event command for event \'%s\'", event->name);
event_name = event->name;
- if (validate_event_name(event_name)) {
- ret = LTTNG_ERR_INVALID_EVENT_NAME;
- goto error;
- }
/* Error out on unhandled search criteria */
if (event->loglevel_type || event->loglevel != -1 || event->enabled
free(attr);
goto error;
}
- free(attr);
+ channel_attr_destroy(attr);
chan_ust_created = 1;
}
return ret;
}
-static int validate_event_name(const char *name)
-{
- int ret = 0;
- const char *c = name;
- const char *event_name_end = c + LTTNG_SYMBOL_NAME_LEN;
- bool null_terminated = false;
-
- /*
- * Make sure that unescaped wildcards are only used as the last
- * character of the event name.
- */
- while (c < event_name_end) {
- switch (*c) {
- case '\0':
- null_terminated = true;
- goto end;
- case '\\':
- c++;
- break;
- case '*':
- if ((c + 1) < event_name_end && *(c + 1)) {
- /* Wildcard is not the last character */
- ret = LTTNG_ERR_INVALID_EVENT_NAME;
- goto end;
- }
- default:
- break;
- }
- c++;
- }
-end:
- if (!ret && !null_terminated) {
- ret = LTTNG_ERR_INVALID_EVENT_NAME;
- }
- return ret;
-}
-
static inline bool name_starts_with(const char *name, const char *prefix)
{
const size_t max_cmp_len = min(strlen(prefix), LTTNG_SYMBOL_NAME_LEN);
struct lttng_event_exclusion *exclusion,
int wpipe, bool internal_event)
{
- int ret, channel_created = 0;
+ int ret = 0, channel_created = 0;
struct lttng_channel *attr = NULL;
assert(session);
/* If we have a filter, we must have its filter expression */
assert(!(!!filter_expression ^ !!filter));
- DBG("Enable event command for event \'%s\'", event->name);
+ /* Normalize event name as a globbing pattern */
+ strutils_normalize_star_glob_pattern(event->name);
- rcu_read_lock();
+ /* Normalize exclusion names as globbing patterns */
+ if (exclusion) {
+ size_t i;
- ret = validate_event_name(event->name);
- if (ret) {
- goto error;
+ for (i = 0; i < exclusion->count; i++) {
+ char *name = LTTNG_EVENT_EXCLUSION_NAME_AT(exclusion, i);
+
+ strutils_normalize_star_glob_pattern(name);
+ }
}
+ DBG("Enable event command for event \'%s\'", event->name);
+
+ rcu_read_lock();
+
switch (domain->type) {
case LTTNG_DOMAIN_KERNEL:
{
free(filter_expression);
free(filter);
free(exclusion);
- free(attr);
+ channel_attr_destroy(attr);
rcu_read_unlock();
return ret;
}
if (nb_chan > 0) {
const size_t channel_size = sizeof(struct lttng_channel) +
- sizeof(struct lttcomm_channel_extended);
- struct lttcomm_channel_extended *channel_exts;
+ sizeof(struct lttng_channel_extended);
+ struct lttng_channel_extended *channel_exts;
payload_size = nb_chan * channel_size;
*channels = zmalloc(payload_size);
channel_exts = ((void *) *channels) +
(nb_chan * sizeof(struct lttng_channel));
- list_lttng_channels(domain, session, *channels, channel_exts);
+ ret = list_lttng_channels(domain, session, *channels, channel_exts);
+ if (ret != LTTNG_OK) {
+ free(*channels);
+ *channels = NULL;
+ goto end;
+ }
} else {
*channels = NULL;
}
ret = notification_thread_command_register_trigger(notification_thread,
trigger);
+ /* Ownership of trigger was transferred. */
+ trigger = NULL;
end:
+ lttng_trigger_destroy(trigger);
lttng_dynamic_buffer_reset(&trigger_buffer);
return ret;
}
ret = notification_thread_command_unregister_trigger(notification_thread,
trigger);
end:
+ lttng_trigger_destroy(trigger);
lttng_dynamic_buffer_reset(&trigger_buffer);
return ret;
}