X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=ltt-sessiond%2Ftrace.c;h=eb7d0e152497569634e5fbf094d2a8d7170e9cbe;hb=950131af6bda07be09bc88fe3ecba68ee21e6c26;hp=40ba95136713e492d9c49aab05c000b6a23d699a;hpb=f3ed775ef4842019b396f06095b053c3a70bc3c8;p=lttng-tools.git diff --git a/ltt-sessiond/trace.c b/ltt-sessiond/trace.c index 40ba95136..eb7d0e152 100644 --- a/ltt-sessiond/trace.c +++ b/ltt-sessiond/trace.c @@ -27,6 +27,59 @@ #include "ltt-sessiond.h" #include "trace.h" +/* + * get_kernel_channel_by_name + * + * Find the channel name for the given kernel session. + */ +struct ltt_kernel_channel *get_kernel_channel_by_name( + char *name, struct ltt_kernel_session *session) +{ + struct ltt_kernel_channel *chan; + + if (session == NULL) { + ERR("Undefine session"); + goto error; + } + + cds_list_for_each_entry(chan, &session->channel_list.head, list) { + if (strcmp(name, chan->channel->name) == 0) { + DBG("Found channel by name %s", name); + return chan; + } + } + +error: + return NULL; +} + +/* + * get_kernel_event_by_name + * + * Find the event name for the given channel. + */ +struct ltt_kernel_event *get_kernel_event_by_name( + char *name, struct ltt_kernel_channel *channel) +{ + struct ltt_kernel_event *ev; + + if (channel == NULL) { + ERR("Undefine channel"); + goto error; + } + + cds_list_for_each_entry(ev, &channel->events_list.head, list) { + if (strcmp(name, ev->event->name) == 0) { + DBG("Found event by name %s for channel %s", name, + channel->channel->name); + return ev; + } + } + +error: + return NULL; +} + /* * trace_create_kernel_session * @@ -297,8 +350,10 @@ void trace_destroy_kernel_session(struct ltt_kernel_session *session) DBG("[trace] Closing session fd %d", session->fd); /* Close kernel fds */ close(session->fd); - DBG("[trace] Closing metadata stream fd %d", session->metadata_stream_fd); - close(session->metadata_stream_fd); + if (session->metadata_stream_fd != 0) { + DBG("[trace] Closing metadata stream fd %d", session->metadata_stream_fd); + close(session->metadata_stream_fd); + } trace_destroy_kernel_metadata(session->metadata);