diff options
author | Lutz Bichler <Lutz.Bichler@bmw.de> | 2019-07-22 12:16:43 +0200 |
---|---|---|
committer | Lutz Bichler <Lutz.Bichler@bmw.de> | 2019-07-22 12:16:43 +0200 |
commit | 6a74d7c48e234e41e7cc4e6e7e83c406dc1385f4 (patch) | |
tree | 8267d825f4d2dae1c0265206158f26ccdac32918 | |
parent | 77fd3ae09034b6f7cb87be7fd77d08cf106f53cb (diff) | |
download | genivi-common-api-dbus-runtime-6a74d7c48e234e41e7cc4e6e7e83c406dc1385f4.tar.gz |
capicxx-dbus-runtime 3.1.12.93.1.12.9
-rw-r--r-- | CHANGES | 7 | ||||
-rw-r--r-- | include/CommonAPI/DBus/DBusAddressTranslator.hpp | 3 | ||||
-rw-r--r-- | src/CommonAPI/DBus/DBusAddressTranslator.cpp | 26 | ||||
-rw-r--r-- | src/CommonAPI/DBus/DBusProxy.cpp | 2 | ||||
-rw-r--r-- | src/test/DBusConnectionTest.cpp | 1 |
5 files changed, 39 insertions, 0 deletions
@@ -1,5 +1,12 @@ Changes ======= +v3.1.12.9 +- Unregister mappings in DBusAddressTranslator (to free memory again) when + proxies are destroyed + +v3.1.12.8 +- Fixed crash in DBusConnectionTest + v3.1.12.7 - Adapted 'capi-dbus-add-support-for-custom-marshalling.patch' to be compatible with dbus version 1.12.x diff --git a/include/CommonAPI/DBus/DBusAddressTranslator.hpp b/include/CommonAPI/DBus/DBusAddressTranslator.hpp index dd5cbef..bad7b19 100644 --- a/include/CommonAPI/DBus/DBusAddressTranslator.hpp +++ b/include/CommonAPI/DBus/DBusAddressTranslator.hpp @@ -47,6 +47,8 @@ public: */ COMMONAPI_EXPORT bool isOrgFreedesktopDBusPeerMapped() const; + COMMONAPI_EXPORT void remove(const CommonAPI::Address &_address); + private: COMMONAPI_EXPORT bool readConfiguration(); @@ -65,6 +67,7 @@ private: std::map<DBusAddress, CommonAPI::Address> backwards_; std::map<std::string, std::string> compatibility_; std::map<CommonAPI::Address, std::tuple<std::string, std::string, std::string>> unversioned_; + std::map<CommonAPI::Address, DBusAddress> persistentAddresses_; std::mutex mutex_; diff --git a/src/CommonAPI/DBus/DBusAddressTranslator.cpp b/src/CommonAPI/DBus/DBusAddressTranslator.cpp index 5a087b2..643ea2e 100644 --- a/src/CommonAPI/DBus/DBusAddressTranslator.cpp +++ b/src/CommonAPI/DBus/DBusAddressTranslator.cpp @@ -200,6 +200,9 @@ DBusAddressTranslator::insert( DBusAddress dbusAddress(_service, _path, _interface); std::lock_guard<std::mutex> itsLock(mutex_); + + persistentAddresses_[address] = dbusAddress; + auto fw = forwards_.find(address); auto bw = backwards_.find(dbusAddress); if (fw == forwards_.end() && bw == backwards_.end()) { @@ -445,5 +448,28 @@ bool DBusAddressTranslator::isValidVersion(const std::string& _version) const { return true; } +void DBusAddressTranslator::remove(const CommonAPI::Address &_address) { + std::lock_guard<std::mutex> itsLock(mutex_); + + DBusAddress dbusAddress; + + // don't remove persisent addresses + auto persistent_it = persistentAddresses_.find(_address); + if(persistent_it != persistentAddresses_.end()) { + return; + } + + auto forwards_it = forwards_.find(_address); + if (forwards_it != forwards_.end()) { + dbusAddress = forwards_it->second; + forwards_.erase(forwards_it->first); + } + + auto backwards_it = backwards_.find(dbusAddress); + if (backwards_it != backwards_.end()) { + backwards_.erase(backwards_it->first); + } +} + } // namespace DBus } // namespace CommonAPI diff --git a/src/CommonAPI/DBus/DBusProxy.cpp b/src/CommonAPI/DBus/DBusProxy.cpp index 0b5b14c..2c11d8f 100644 --- a/src/CommonAPI/DBus/DBusProxy.cpp +++ b/src/CommonAPI/DBus/DBusProxy.cpp @@ -10,6 +10,7 @@ #include <CommonAPI/DBus/DBusUtils.hpp> #include <CommonAPI/DBus/DBusProxyAsyncSignalMemberCallbackHandler.hpp> #include <CommonAPI/DBus/DBusConnection.hpp> +#include <CommonAPI/DBus/DBusAddressTranslator.hpp> #include <CommonAPI/Logger.hpp> namespace CommonAPI { @@ -216,6 +217,7 @@ DBusProxy::~DBusProxy() { if (auto ptr = factory__.lock()) { ptr->decrementConnection(connection_); } + DBusAddressTranslator::get()->remove(getAddress()); } bool DBusProxy::isAvailable() const { diff --git a/src/test/DBusConnectionTest.cpp b/src/test/DBusConnectionTest.cpp index 5f66707..c4edce6 100644 --- a/src/test/DBusConnectionTest.cpp +++ b/src/test/DBusConnectionTest.cpp @@ -153,6 +153,7 @@ TEST_F(DBusConnectionTest, SendingAsyncDBusMessagesWorks) { dbusConnection_->disconnect(); interfaceHandlerDBusConnection->unregisterObjectPath(objectPath); + interfaceHandlerDBusConnection->setObjectPathMessageHandler(CommonAPI::DBus::DBusProxyConnection::DBusObjectPathMessageHandler()); ASSERT_TRUE(interfaceHandlerDBusConnection->releaseServiceName(service)); interfaceHandlerDBusConnection->disconnect(); |