diff options
author | Lutz Bichler <Lutz.Bichler@bmw.de> | 2019-07-23 07:33:45 +0200 |
---|---|---|
committer | Lutz Bichler <Lutz.Bichler@bmw.de> | 2019-07-23 07:33:45 +0200 |
commit | 9f85f0f18d9ca436fb618769149ee02e78fd283b (patch) | |
tree | 9ca7f444ff2433949c6e05933f95a58fd9bb9d0c | |
parent | 6a74d7c48e234e41e7cc4e6e7e83c406dc1385f4 (diff) | |
download | genivi-common-api-dbus-runtime-9f85f0f18d9ca436fb618769149ee02e78fd283b.tar.gz |
capicxx-dbus-runtime 3.1.12.113.1.12.11
-rw-r--r-- | CHANGES | 8 | ||||
-rw-r--r-- | src/CommonAPI/DBus/DBusFactory.cpp | 2 | ||||
-rw-r--r-- | src/CommonAPI/DBus/DBusObjectManager.cpp | 19 |
3 files changed, 21 insertions, 8 deletions
@@ -1,5 +1,13 @@ Changes ======= +v3.1.12.11 +- Prevent crash when deregistering managed service (via 'deregisterManagedStub*') and + another service (via 'unregisterService') in parallel with same DBus connection + +v3.1.12.10 +- Unregister mappings in DBusAddressTranslator (to free memory again) when + services/stubs are unregistered + v3.1.12.9 - Unregister mappings in DBusAddressTranslator (to free memory again) when proxies are destroyed diff --git a/src/CommonAPI/DBus/DBusFactory.cpp b/src/CommonAPI/DBus/DBusFactory.cpp index 2006f5a..332b1d5 100644 --- a/src/CommonAPI/DBus/DBusFactory.cpp +++ b/src/CommonAPI/DBus/DBusFactory.cpp @@ -203,6 +203,8 @@ Factory::unregisterStub(const std::string &_domain, const std::string &_interfac services_.erase(adapterResult->first); + DBusAddressTranslator::get()->remove(address); + itsLock.unlock(); decrementConnection(connection); diff --git a/src/CommonAPI/DBus/DBusObjectManager.cpp b/src/CommonAPI/DBus/DBusObjectManager.cpp index 85fdbf4..cf5fbc2 100644 --- a/src/CommonAPI/DBus/DBusObjectManager.cpp +++ b/src/CommonAPI/DBus/DBusObjectManager.cpp @@ -49,7 +49,8 @@ bool DBusObjectManager::registerDBusStubAdapter(std::shared_ptr<DBusStubAdapter> DBusInterfaceHandlerPath dbusStubAdapterHandlerPath(dbusStubAdapterObjectPath, dbusStubAdapterInterfaceName); bool isRegistrationSuccessful = false; - objectPathLock_.lock(); + std::lock_guard<std::recursive_mutex> itsLock(objectPathLock_); + isRegistrationSuccessful = addDBusInterfaceHandler(dbusStubAdapterHandlerPath, dbusStubAdapter); if (isRegistrationSuccessful && dbusStubAdapter->hasFreedesktopProperties()) { @@ -109,7 +110,6 @@ bool DBusObjectManager::registerDBusStubAdapter(std::shared_ptr<DBusStubAdapter> dbusConnection->registerObjectPath(dbusStubAdapterObjectPath); } } - objectPathLock_.unlock(); return isRegistrationSuccessful; } @@ -121,7 +121,8 @@ bool DBusObjectManager::unregisterDBusStubAdapter(std::shared_ptr<DBusStubAdapte DBusInterfaceHandlerPath dbusStubAdapterHandlerPath(dbusStubAdapterObjectPath, dbusStubAdapterInterfaceName); bool isDeregistrationSuccessful = false; - objectPathLock_.lock(); + std::lock_guard<std::recursive_mutex> itsLock(objectPathLock_); + isDeregistrationSuccessful = removeDBusInterfaceHandler(dbusStubAdapterHandlerPath, dbusStubAdapter); if (isDeregistrationSuccessful && dbusStubAdapter->isManaging()) { @@ -162,13 +163,13 @@ bool DBusObjectManager::unregisterDBusStubAdapter(std::shared_ptr<DBusStubAdapte } } - objectPathLock_.unlock(); - return isDeregistrationSuccessful; } bool DBusObjectManager::exportManagedDBusStubAdapter(const std::string& parentObjectPath, std::shared_ptr<DBusStubAdapter> dbusStubAdapter) { + std::lock_guard<std::recursive_mutex> itsLock(objectPathLock_); + auto foundManagerStubIterator = managerStubs_.find(parentObjectPath); if (managerStubs_.end() == foundManagerStubIterator) { @@ -182,6 +183,8 @@ bool DBusObjectManager::exportManagedDBusStubAdapter(const std::string& parentOb bool DBusObjectManager::unexportManagedDBusStubAdapter(const std::string& parentObjectPath, std::shared_ptr<DBusStubAdapter> dbusStubAdapter) { + std::lock_guard<std::recursive_mutex> itsLock(objectPathLock_); + auto foundManagerStubIterator = managerStubs_.find(parentObjectPath); if (foundManagerStubIterator != managerStubs_.end()) { @@ -208,20 +211,20 @@ bool DBusObjectManager::handleMessage(const DBusMessage& dbusMessage) { DBusInterfaceHandlerPath handlerPath(objectPath, interfaceName); - objectPathLock_.lock(); + std::unique_lock<std::recursive_mutex> itsLock(objectPathLock_); + auto handlerIterator = dbusRegisteredObjectsTable_.find(handlerPath); const bool foundDBusInterfaceHandler = handlerIterator != dbusRegisteredObjectsTable_.end(); bool dbusMessageHandled = false; if (foundDBusInterfaceHandler) { std::shared_ptr<DBusInterfaceHandler> dbusStubAdapterBase = handlerIterator->second.front(); - objectPathLock_.unlock(); + itsLock.unlock(); dbusMessageHandled = dbusStubAdapterBase->onInterfaceDBusMessage(dbusMessage); return dbusMessageHandled; } else if (dbusMessage.hasInterfaceName("org.freedesktop.DBus.Introspectable")) { dbusMessageHandled = onIntrospectableInterfaceDBusMessage(dbusMessage); } - objectPathLock_.unlock(); return dbusMessageHandled; } |