Add kernel tracer check on kernel command
authorDavid Goulet <david.goulet@polymtl.ca>
Thu, 2 Jun 2011 18:41:41 +0000 (14:41 -0400)
committerDavid Goulet <david.goulet@polymtl.ca>
Thu, 2 Jun 2011 18:41:41 +0000 (14:41 -0400)
Check again at each kernel command for the kernel tracer. If the module
get loaded AFTER the session daemon, kernel tracing will be available.

Signed-off-by: David Goulet <david.goulet@polymtl.ca>
ltt-sessiond/main.c

index e069696b0c621df39fedbb71454bc20bd54006c1..cbd6a3f3f6a7469ddc2be72fb5b313555bf37989 100644 (file)
@@ -648,6 +648,23 @@ error:
        return ret;
 }
 
+/*
+ *  init_kernel_tracer
+ *
+ *  Setup necessary data for kernel tracer action.
+ */
+static void init_kernel_tracer(void)
+{
+       /* Set the global kernel tracer fd */
+       kernel_tracer_fd = open(DEFAULT_KERNEL_TRACER_PATH, O_RDWR);
+       if (kernel_tracer_fd < 0) {
+               WARN("No kernel tracer available");
+               kernel_tracer_fd = 0;
+       }
+
+       DBG("Kernel tracer fd %d", kernel_tracer_fd);
+}
+
 /*
  *     process_client_msg
  *
@@ -690,11 +707,13 @@ static int process_client_msg(struct command_ctx *cmd_ctx)
        case KERNEL_OPEN_METADATA:
        case KERNEL_START_TRACE:
        case KERNEL_STOP_TRACE:
-               /* TODO: reconnect to kernel tracer to check if
-                * it's loadded */
+               /* Kernel tracer check */
                if (kernel_tracer_fd == 0) {
-                       ret = LTTCOMM_KERN_NA;
-                       goto error;
+                       init_kernel_tracer();
+                       if (kernel_tracer_fd == 0) {
+                               ret = LTTCOMM_KERN_NA;
+                               goto error;
+                       }
                }
                break;
        }
@@ -1472,23 +1491,6 @@ error:
        return ret;
 }
 
-/*
- *  init_kernel_tracer
- *
- *  Setup necessary data for kernel tracer action.
- */
-static void init_kernel_tracer(void)
-{
-       /* Set the global kernel tracer fd */
-       kernel_tracer_fd = open(DEFAULT_KERNEL_TRACER_PATH, O_RDWR);
-       if (kernel_tracer_fd < 0) {
-               WARN("No kernel tracer available");
-               kernel_tracer_fd = 0;
-       }
-
-       DBG("Kernel tracer fd %d", kernel_tracer_fd);
-}
-
 /*
  *  set_kconsumerd_sockets
  *
This page took 0.027119 seconds and 4 git commands to generate.