Skip to contentSkip to conversation

Fix: runas: set thread name

RFC PATCH Jérémie Galarneau 1 participant 1 message Sep 21, 2015 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

Squashed into.

commit 7567352fb68f5c3f49f549c579f5bd27c883bed2

Author: Mathieu Desnoyers <[email protected]>
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.

Thanks!
Jérémie

Quoted 37 lines · Mathieu Desnoyers

In case some system check for the thread name in pidof.

---
 src/common/runas.c | 9 +++++++++
 1 file changed, 9 insertions(+)
src/common/runas.c +9 -1
index 2634ae9..d313e83 100644
@@ -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

Signature · 8 lines
Jérémie Galarneau
EfficiOS Inc.
http://www.efficios.com

_______________________________________________
lttng-dev mailing list
[email protected]
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev