Add kernel tracer check on kernel command
[lttng-tools.git] / ltt-sessiond / main.c
index e069696b0c621df39fedbb71454bc20bd54006c1..cbd6a3f3f6a7469ddc2be72fb5b313555bf37989 100644 (file)
@@ -648,6 +648,23 @@ error:
        return ret;
 }
 
        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
  *
 /*
  *     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:
        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) {
                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;
        }
                }
                break;
        }
@@ -1472,23 +1491,6 @@ error:
        return ret;
 }
 
        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
  *
 /*
  *  set_kconsumerd_sockets
  *
This page took 0.032903 seconds and 4 git commands to generate.