From: David Goulet Date: Mon, 3 Oct 2011 18:46:40 +0000 (-0400) Subject: Fix enable syscall and bad value of poll set size X-Git-Tag: v2.0-pre15~200 X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=commitdiff_plain;h=5f822d0a2688bb0b085b579dfc37a1958fff072e Fix enable syscall and bad value of poll set size First, when enabling syscall tracing, on success 0 is return so we don't add this value to the event list or else we were polling on fd 0 which is not a valid event fd. A normal kernel create event, the fd of that event is returned from the ioctl which is not the case for syscalls. Second, the poll size was not reset when updating the kernel poll set so at each kernel poll update, the value was not coherent with the real poll size and thus creating unstable behavior (unknown). This commit MIGHT fix a blocking problem happening when using a custom channel and enabling syscall on it. This issue was reported by Julien Desfossez . Signed-off-by: David Goulet --- diff --git a/include/lttng-kernel.h b/include/lttng-kernel.h index a62207209..ac9370d2f 100644 --- a/include/lttng-kernel.h +++ b/include/lttng-kernel.h @@ -34,7 +34,7 @@ */ enum lttng_kernel_instrumentation { - LTTNG_KERNEL_ALL = -1, /* Used within lttng-tools */ + LTTNG_KERNEL_ALL = -1, /* Used within lttng-tools */ LTTNG_KERNEL_TRACEPOINT = 0, LTTNG_KERNEL_KPROBE = 1, LTTNG_KERNEL_FUNCTION = 2, diff --git a/ltt-sessiond/kernel-ctl.c b/ltt-sessiond/kernel-ctl.c index b66f08cb3..e486fa10a 100644 --- a/ltt-sessiond/kernel-ctl.c +++ b/ltt-sessiond/kernel-ctl.c @@ -194,10 +194,19 @@ int kernel_create_event(struct lttng_event *ev, ret = kernctl_create_event(channel->fd, event->event); if (ret < 0) { - perror("create event ioctl"); + PERROR("create event ioctl"); goto free_event; } + /* + * LTTNG_KERNEL_SYSCALL event creation will return 0 on success. However + * this FD must not be added to the event list. + */ + if (ret == 0 && event->event->instrumentation == LTTNG_KERNEL_SYSCALL) { + DBG2("Kernel event syscall creation success"); + goto end; + } + event->fd = ret; /* Prevent fd duplication after execlp() */ ret = fcntl(event->fd, F_SETFD, FD_CLOEXEC); @@ -211,6 +220,7 @@ int kernel_create_event(struct lttng_event *ev, DBG("Event %s created (fd: %d)", ev->name, event->fd); +end: return 0; free_event: diff --git a/ltt-sessiond/main.c b/ltt-sessiond/main.c index c72087ef2..c66ecb956 100644 --- a/ltt-sessiond/main.c +++ b/ltt-sessiond/main.c @@ -701,6 +701,12 @@ static void *thread_manage_kernel(void *data) while (1) { if (update_poll_flag == 1) { + /* + * Reset number of fd in the poll set. Always 2 since there is the thread + * quit pipe and the kernel pipe. + */ + events.nb_fd = 2; + ret = update_kernel_poll(&events); if (ret < 0) { goto error; diff --git a/ltt-sessiond/session.c b/ltt-sessiond/session.c index aaca9f937..b13f4a916 100644 --- a/ltt-sessiond/session.c +++ b/ltt-sessiond/session.c @@ -121,6 +121,8 @@ struct ltt_session *session_find_by_name(char *name) int found = 0; struct ltt_session *iter; + DBG2("Trying to find session by name %s", name); + session_lock_list(); cds_list_for_each_entry(iter, <t_session_list.head, list) { if (strncmp(iter->name, name, NAME_MAX) == 0) {