Fix: use MT-safe strtok_r in multithreaded context
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 3 Feb 2021 15:21:42 +0000 (10:21 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 3 Feb 2021 20:21:59 +0000 (15:21 -0500)
append_list_to_probes uses the non-multithread-safe "strtok" while in
multithreaded context.

It is called by modprobe_lttng_data(), which is called from
init_kernel_tracer().

init_kernel_tracer is used from main() after other threads are created,
and also from process_client_msg() when a user attempts to interact with
the kernel domain if the kernel tracer has not yet been successfully
initialized.

Fixed by using the MT-safe strtok_r() instead.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ic3f81551b8508451e0f9733c5de56a4d4407b813

src/bin/lttng-sessiond/modprobe.c

index d63483481369436f5d639463c7832caa5f9de9a7..23d4536b1ad8f88c09902d7fe6c6d8269a05a519 100644 (file)
@@ -496,7 +496,7 @@ static int append_list_to_probes(const char *list)
 {
        char *next;
        int ret;
-       char *tmp_list, *cur_list;
+       char *tmp_list, *cur_list, *saveptr;
 
        assert(list);
 
@@ -510,7 +510,7 @@ static int append_list_to_probes(const char *list)
                size_t name_len;
                struct kern_modules_param *cur_mod;
 
-               next = strtok(cur_list, ",");
+               next = strtok_r(cur_list, ",", &saveptr);
                if (!next) {
                        break;
                }
This page took 0.025831 seconds and 4 git commands to generate.