Skip to content

Commit

Permalink
capicxx-dbus-runtime 3.1.12.11
Browse files Browse the repository at this point in the history
  • Loading branch information
lutzbichler committed Jul 23, 2019
1 parent 6a74d7c commit 9f85f0f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
8 changes: 8 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/CommonAPI/DBus/DBusFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
19 changes: 11 additions & 8 deletions src/CommonAPI/DBus/DBusObjectManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down Expand Up @@ -109,7 +110,6 @@ bool DBusObjectManager::registerDBusStubAdapter(std::shared_ptr<DBusStubAdapter>
dbusConnection->registerObjectPath(dbusStubAdapterObjectPath);
}
}
objectPathLock_.unlock();

return isRegistrationSuccessful;
}
Expand All @@ -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()) {
Expand Down Expand Up @@ -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) {
Expand All @@ -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()) {
Expand All @@ -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;
}
Expand Down

0 comments on commit 9f85f0f

Please sign in to comment.