From 37e25f93d68b318602fb15e08cfd7fbca7e18747 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sun, 3 Jun 2018 12:00:16 +0200 Subject: [PATCH] lib/dbus/Glue: move Connect()/Disconnect() calls to I/O thread --- src/lib/dbus/Glue.cxx | 13 +++++++++++++ src/lib/dbus/Glue.hxx | 7 +++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/lib/dbus/Glue.cxx b/src/lib/dbus/Glue.cxx index 07e264e27..3638e3c51 100644 --- a/src/lib/dbus/Glue.cxx +++ b/src/lib/dbus/Glue.cxx @@ -19,9 +19,22 @@ #include "config.h" #include "Glue.hxx" +#include "event/Call.hxx" namespace ODBus { +void +Glue::ConnectIndirect() +{ + BlockingCall(GetEventLoop(), [this](){ Connect(); }); +} + +void +Glue::DisconnectIndirect() +{ + BlockingCall(GetEventLoop(), [this](){ Disconnect(); }); +} + void Glue::Connect() { diff --git a/src/lib/dbus/Glue.hxx b/src/lib/dbus/Glue.hxx index 49f35b170..ed6612155 100644 --- a/src/lib/dbus/Glue.hxx +++ b/src/lib/dbus/Glue.hxx @@ -35,11 +35,11 @@ class Glue final : ODBus::WatchManagerObserver { public: explicit Glue(EventLoop &event_loop) :watch(event_loop, *this) { - Connect(); + ConnectIndirect(); } ~Glue() noexcept { - Disconnect(); + DisconnectIndirect(); } EventLoop &GetEventLoop() noexcept { @@ -51,6 +51,9 @@ public: } private: + void ConnectIndirect(); + void DisconnectIndirect(); + void Connect(); void Disconnect();