Fix enable syscall and bad value of poll set size
authorDavid Goulet <david.goulet@polymtl.ca>
Mon, 3 Oct 2011 18:46:40 +0000 (14:46 -0400)
committerDavid Goulet <david.goulet@polymtl.ca>
Mon, 3 Oct 2011 18:46:40 +0000 (14:46 -0400)
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 <julien.desfossez@polymtl.ca>.

Signed-off-by: David Goulet <david.goulet@polymtl.ca>
include/lttng-kernel.h
ltt-sessiond/kernel-ctl.c
ltt-sessiond/main.c
ltt-sessiond/session.c

index a62207209f6d8bba8f6215c46444b0d96782795c..ac9370d2f48f5f3b35bc22de1c8d22fbff19b2bb 100644 (file)
@@ -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,
index b66f08cb3fd354d00f15a3abd85d8dfa21462371..e486fa10ada0002e8e2f7437ce677a0f24475ba6 100644 (file)
@@ -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:
index c72087ef25ddb88d27634e5d97d1967d1bec0277..c66ecb95690df819ce95825b83f20ac147dd4137 100644 (file)
@@ -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;
index aaca9f9370510a6765524fe27302c19ff192f3a4..b13f4a916c8963357cea305d4677649a7f955f05 100644 (file)
@@ -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, &ltt_session_list.head, list) {
                if (strncmp(iter->name, name, NAME_MAX) == 0) {
This page took 0.029618 seconds and 4 git commands to generate.