From a5d2a6e4d3e1d36cc3616c96a3c0670e571c9716 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Lyson=C4=9Bk?= Date: Mon, 11 Sep 2017 09:27:14 +0200 Subject: [PATCH] Fix race between DBus exporter startup and applying a profile MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously if the profile was applied before all methods and signals were exported on DBus, the daemon thread (_thread_code() in daemon.py) could crash after attempting to emit a signal on DBus announcing that a profile was applied. A regular user is unlikely to run into the race in practice, but it frequently happens when applying an empty profile for testing purposes. Signed-off-by: Ondřej Lysoněk --- tuned/exports/dbus_exporter.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tuned/exports/dbus_exporter.py b/tuned/exports/dbus_exporter.py index b432bbc..65ee969 100644 --- a/tuned/exports/dbus_exporter.py +++ b/tuned/exports/dbus_exporter.py @@ -133,6 +133,9 @@ class DBusExporter(interfaces.ExporterInterface): self._construct_dbus_object_class() self.stop() + bus = dbus.SystemBus() + bus_name = dbus.service.BusName(self._bus_name, bus) + self._bus_object = self._dbus_object_cls(bus, self._object_name, bus_name) self._thread = threading.Thread(target=self._thread_code) self._thread.start() @@ -143,10 +146,6 @@ class DBusExporter(interfaces.ExporterInterface): self._thread = None def _thread_code(self): - bus = dbus.SystemBus() - bus_name = dbus.service.BusName(self._bus_name, bus) - self._bus_object = self._dbus_object_cls(bus, self._object_name, bus_name) - self._main_loop.run() del self._bus_object self._bus_object = None