diff options
author | Johannes Schanda <schanda@itestra.de> | 2013-08-07 15:28:23 +0200 |
---|---|---|
committer | Stefan Laner <laner@itestra.de> | 2013-08-07 15:28:23 +0200 |
commit | dd1bca359710c796aeb7f406ce268264226e3294 (patch) | |
tree | 0da4d916d96d6cb57c32ace8854dbfb8e34f507e /src | |
parent | 9f66fbe2099558c08b2f10c03262c4ad220f0ec3 (diff) | |
download | genivi-common-api-dbus-runtime-dd1bca359710c796aeb7f406ce268264226e3294.tar.gz |
Backported thread teardown fix
Diffstat (limited to 'src')
-rw-r--r-- | src/CommonAPI/DBus/DBusConnection.cpp | 11 | ||||
-rw-r--r-- | src/CommonAPI/DBus/DBusConnection.h | 2 |
2 files changed, 9 insertions, 4 deletions
diff --git a/src/CommonAPI/DBus/DBusConnection.cpp b/src/CommonAPI/DBus/DBusConnection.cpp index df77e95..3b58241 100644 --- a/src/CommonAPI/DBus/DBusConnection.cpp +++ b/src/CommonAPI/DBus/DBusConnection.cpp @@ -29,13 +29,17 @@ DBusObjectPathVTable DBusConnection::libdbusObjectPathVTable_ = { &DBusConnection::onLibdbusObjectPathMessageThunk }; -void DBusConnection::dispatch(std::shared_ptr<DBusConnection> selfReference) { - while (!stopDispatching_ && readWriteDispatch(10) && !selfReference.unique()) { +void DBusConnection::dispatch(std::shared_ptr<DBusConnection>* selfReference) { +//void DBusConnection::dispatch() { + //auto selfReference = this->shared_from_this(); + while (!stopDispatching_ && readWriteDispatch(10) && !selfReference->unique()) { if(pauseDispatching_) { dispatchSuspendLock_.lock(); dispatchSuspendLock_.unlock(); } } + delete selfReference; + } bool DBusConnection::readWriteDispatch(int timeoutMilliseconds) { @@ -259,7 +263,8 @@ bool DBusConnection::connect(DBusError& dbusError, bool startDispatchThread) { initLibdbusSignalFilterAfterConnect(); if(startDispatchThread) { - dispatchThread_ = new std::thread(&DBusConnection::dispatch, this, this->shared_from_this()); + std::shared_ptr<DBusConnection>* ptr = new std::shared_ptr<DBusConnection>(this->shared_from_this()); + dispatchThread_ = new std::thread(&DBusConnection::dispatch, this, ptr); } stopDispatching_ = !startDispatchThread; diff --git a/src/CommonAPI/DBus/DBusConnection.h b/src/CommonAPI/DBus/DBusConnection.h index 81c8cfa..cefc37e 100644 --- a/src/CommonAPI/DBus/DBusConnection.h +++ b/src/CommonAPI/DBus/DBusConnection.h @@ -115,7 +115,7 @@ class DBusConnection: public DBusProxyConnection, public std::enable_shared_from bool singleDispatch(); private: - void dispatch(std::shared_ptr<DBusConnection> selfReference); + void dispatch(std::shared_ptr<DBusConnection>* selfReference); void suspendDispatching() const; void resumeDispatching() const; |