From: David Goulet Date: Thu, 2 Jun 2011 18:41:41 +0000 (-0400) Subject: Add kernel tracer check on kernel command X-Git-Tag: v2.0-pre1~88 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=333f285e479a22c99122aa92b988b10c597551e4;p=lttng-tools.git Add kernel tracer check on kernel command 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 --- diff --git a/ltt-sessiond/main.c b/ltt-sessiond/main.c index e069696b0..cbd6a3f3f 100644 --- a/ltt-sessiond/main.c +++ b/ltt-sessiond/main.c @@ -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 *