From 162646081173a4edd1d105bbdf7430d41673623b Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Sat, 5 Sep 2015 13:38:01 -0400 Subject: [PATCH] Fix: Python agent: do not register twice to same port It is possible that one of the session daemons left its agent.port file on the file system, for example when killed with SIGKILL. It is also common that both those session daemons use the same port for listening to agent connections. In this case, if one session daemon is running, but two agent.port files exist, the Python agent would connect its two threads to the same session daemon, leading to everything done twice: list shows events twice, tracing records events twice, etc. This patch ensures that if two agent.port files are found and have the same content, only one thread is used. Signed-off-by: Philippe Proulx Signed-off-by: Mathieu Desnoyers --- liblttng-ust-python-agent/lttngust/agent.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/liblttng-ust-python-agent/lttngust/agent.py b/liblttng-ust-python-agent/lttngust/agent.py index 8ec26cde..84cfd838 100644 --- a/liblttng-ust-python-agent/lttngust/agent.py +++ b/liblttng-ust-python-agent/lttngust/agent.py @@ -317,6 +317,12 @@ def _init_threads(): dbg._pdebug('system session daemon port: {}'.format(sys_port)) dbg._pdebug('user session daemon port: {}'.format(user_port)) + if sys_port == user_port and sys_port is not None: + # The two session daemon ports are the same. This is not normal. + # Connect to only one. + dbg._pdebug('both user and system session daemon have the same port') + sys_port = None + try: if sys_port is not None: dbg._pdebug('creating system client thread') -- 2.34.1