[lttng-dev] [RFC PATCH lttng-tools] Fix: runas: set thread name

Jérémie Galarneau jeremie.galarneau at efficios.com
Mon Sep 21 11:31:03 EDT 2015


Squashed into.

commit 7567352fb68f5c3f49f549c579f5bd27c883bed2
Author: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
Date:   Thu Sep 17 11:30:29 2015 -0400

    Fix: libc internal mutex races with run_as

    Implement a proper run_as worker process scheme to fix internal libc
    mutex races. Those races lead to having the internal mutex held by
    another process when clone() is called, thus hanging the clone child.

    Now that we create the worker process when the parent process is
    still single-threaded, we don't run into those issues. Implement a
    standard fork + file descriptor passing over unnamed unix sockets rather
    than the prior clone + shared file descriptor table, which was causing
    issues with valgrind.

    This adds a new process called "lttng-runas" for each sessiond
    and consumerd process.

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

Thanks!
Jérémie

On Fri, Sep 18, 2015 at 12:00 PM, Mathieu Desnoyers
<mathieu.desnoyers at efficios.com> wrote:
> In case some system check for the thread name in pidof.
>
> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
> ---
>  src/common/runas.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
>
> diff --git a/src/common/runas.c b/src/common/runas.c
> index 2634ae9..d313e83 100644
> --- a/src/common/runas.c
> +++ b/src/common/runas.c
> @@ -302,6 +302,7 @@ int run_as_worker(struct run_as_worker *worker)
>         ssize_t writelen;
>         struct run_as_ret sendret;
>         size_t proc_orig_len;
> +       int ret;
>
>         /*
>          * Initialize worker. Set a different process cmdline.
> @@ -310,6 +311,14 @@ int run_as_worker(struct run_as_worker *worker)
>         memset(worker->procname, 0, proc_orig_len);
>         strncpy(worker->procname, "lttng-runas", proc_orig_len);
>
> +       ret = pthread_setname_np(pthread_self(), "lttng-runas");
> +       if (ret) {
> +               errno = ret;
> +               ret = -1;
> +               PERROR("pthread_setname_np");
> +               return EXIT_FAILURE;
> +       }
> +
>         sendret.ret = 0;
>         sendret._errno = 0;
>         writelen = lttcomm_send_unix_sock(worker->sockpair[1], &sendret,
> --
> 2.1.4
>



-- 
Jérémie Galarneau
EfficiOS Inc.
http://www.efficios.com



More information about the lttng-dev mailing list