summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLutz Bichler <Lutz.Bichler@bmw.de>2020-10-27 10:00:57 +0100
committerLutz Bichler <Lutz.Bichler@bmw.de>2020-10-27 10:00:57 +0100
commitd1610ad0d6f1b6751964af41a0cc1599e2d7a955 (patch)
tree2144ae231a4ca372f497605d5b4779d2e11c2888 /src
parent9f85f0f18d9ca436fb618769149ee02e78fd283b (diff)
downloadgenivi-common-api-dbus-runtime-d1610ad0d6f1b6751964af41a0cc1599e2d7a955.tar.gz
capicxx-dbus-runtime 3.2.0HEAD3.2.0master
Diffstat (limited to 'src')
-rw-r--r--src/CommonAPI/DBus/DBusAddress.cpp12
-rw-r--r--src/CommonAPI/DBus/DBusAddressTranslator.cpp2
-rw-r--r--src/CommonAPI/DBus/DBusClientId.cpp10
-rw-r--r--src/CommonAPI/DBus/DBusConnection.cpp29
-rw-r--r--src/CommonAPI/DBus/DBusDaemonProxy.cpp14
-rw-r--r--src/CommonAPI/DBus/DBusError.cpp2
-rw-r--r--src/CommonAPI/DBus/DBusFactory.cpp2
-rw-r--r--src/CommonAPI/DBus/DBusFreedesktopPropertiesStub.cpp2
-rw-r--r--src/CommonAPI/DBus/DBusFunctionalHash.cpp2
-rw-r--r--src/CommonAPI/DBus/DBusInputStream.cpp2
-rw-r--r--src/CommonAPI/DBus/DBusInstanceAvailabilityStatusChangedEvent.cpp4
-rwxr-xr-xsrc/CommonAPI/DBus/DBusMainLoop.cpp140
-rw-r--r--src/CommonAPI/DBus/DBusMainLoopContext.cpp91
-rw-r--r--src/CommonAPI/DBus/DBusMessage.cpp2
-rw-r--r--src/CommonAPI/DBus/DBusObjectManager.cpp2
-rw-r--r--src/CommonAPI/DBus/DBusObjectManagerStub.cpp2
-rw-r--r--src/CommonAPI/DBus/DBusOutputStream.cpp8
-rw-r--r--src/CommonAPI/DBus/DBusProxy.cpp4
-rw-r--r--src/CommonAPI/DBus/DBusProxyBase.cpp2
-rw-r--r--src/CommonAPI/DBus/DBusProxyManager.cpp2
-rw-r--r--src/CommonAPI/DBus/DBusServiceRegistry.cpp7
-rw-r--r--src/CommonAPI/DBus/DBusStubAdapter.cpp2
-rw-r--r--src/murmurhash/MurmurHash3.cpp35
-rw-r--r--src/pugixml/pugixml.cpp8
-rw-r--r--src/test/CMakeLists.txt47
-rw-r--r--src/test/DBusClientIdTest.cpp7
26 files changed, 153 insertions, 287 deletions
diff --git a/src/CommonAPI/DBus/DBusAddress.cpp b/src/CommonAPI/DBus/DBusAddress.cpp
index 4819a40..bae8190 100644
--- a/src/CommonAPI/DBus/DBusAddress.cpp
+++ b/src/CommonAPI/DBus/DBusAddress.cpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2015-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+// Copyright (C) 2015-2020 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
@@ -27,6 +27,15 @@ DBusAddress::DBusAddress(const DBusAddress &_source)
DBusAddress::~DBusAddress() {
}
+DBusAddress &
+DBusAddress::operator=(const DBusAddress &_other) {
+ service_ = _other.service_;
+ objectPath_ = _other.objectPath_;
+ interface_ = _other.interface_;
+
+ return (*this);
+}
+
bool
DBusAddress::operator==(const DBusAddress &_other) const {
return (service_ == _other.service_ &&
@@ -97,6 +106,5 @@ operator<<(std::ostream &_out, const DBusAddress &_dbusAddress) {
return _out;
}
-
} // namespace DBus
} // namespace CommonAPI
diff --git a/src/CommonAPI/DBus/DBusAddressTranslator.cpp b/src/CommonAPI/DBus/DBusAddressTranslator.cpp
index 643ea2e..56d5926 100644
--- a/src/CommonAPI/DBus/DBusAddressTranslator.cpp
+++ b/src/CommonAPI/DBus/DBusAddressTranslator.cpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2013-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+// Copyright (C) 2013-2020 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
diff --git a/src/CommonAPI/DBus/DBusClientId.cpp b/src/CommonAPI/DBus/DBusClientId.cpp
index 12983b5..d6dcbc5 100644
--- a/src/CommonAPI/DBus/DBusClientId.cpp
+++ b/src/CommonAPI/DBus/DBusClientId.cpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2013-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+// Copyright (C) 2013-2020 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
@@ -58,5 +58,13 @@ DBusMessage DBusClientId::createMessage(const std::string objectPath, const std:
return(returnMessage);
}
+uid_t DBusClientId::getUid() const {
+ return (0);
+}
+
+gid_t DBusClientId::getGid() const {
+ return (0);
+}
+
} // namespace DBus
} // namespace CommonAPI
diff --git a/src/CommonAPI/DBus/DBusConnection.cpp b/src/CommonAPI/DBus/DBusConnection.cpp
index 06c3f5d..7364849 100644
--- a/src/CommonAPI/DBus/DBusConnection.cpp
+++ b/src/CommonAPI/DBus/DBusConnection.cpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2013-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+// Copyright (C) 2013-2020 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
@@ -231,7 +231,7 @@ bool DBusConnection::attachMainLoopContext(std::weak_ptr<MainLoopContext> mainLo
lockedContext->registerDispatchSource(queueDispatchSource_);
lockedContext->registerWatch(queueWatch_);
- dispatchSource_ = new DBusDispatchSource(this);
+ dispatchSource_ = new DBusDispatchSource(shared_from_this());
watchContext_ = new WatchContext(mainLoopContext_, dispatchSource_, shared_from_this());
lockedContext->registerDispatchSource(dispatchSource_);
@@ -620,6 +620,8 @@ void DBusConnection::onLibdbusPendingCall(::DBusPendingCall* _libdbusPendingCall
delete _dbusMessageReplyAsyncHandler;
} else {
_dbusMessageReplyAsyncHandler->unlock();
+ std::lock_guard<std::recursive_mutex> enforcerLock(enforcerThreadMutex_);
+ enforceTimeoutCondition_.notify_one();
}
}
@@ -1373,9 +1375,12 @@ bool DBusConnection::removeLibdbusSignalMatchRule(const std::string& dbusMatchRu
dbus_bus_remove_match(connection_, dbusMatchRule.c_str(), NULL);
- libdbusSignalMatchRulesCount_--;
- if (libdbusSignalMatchRulesCount_ == 0) {
- dbus_connection_remove_filter(connection_, &onLibdbusSignalFilterThunk, this);
+ {
+ std::unique_lock<std::recursive_mutex> dbusConnectionLock(connectionGuard_);
+ libdbusSignalMatchRulesCount_--;
+ if (libdbusSignalMatchRulesCount_ == 0) {
+ dbus_connection_remove_filter(connection_, &onLibdbusSignalFilterThunk, this);
+ }
}
return true;
@@ -1493,7 +1498,6 @@ void DBusConnection::addLibdbusSignalMatchRule(const std::string& objectPath,
// add the libdbus message signal filter
if (isFirstMatchRule) {
-
libdbusSuccess = 0 != dbus_connection_add_filter(
connection_,
&onLibdbusSignalFilterThunk,
@@ -1795,19 +1799,6 @@ void DBusConnection::pushDBusMessageReplyToMainLoop(const DBusMessage& _reply,
queueWatch_->pushQueue(msgReplyQueueEntry);
}
-void DBusConnection::setPendingCallTimedOut(DBusPendingCall* _pendingCall, ::DBusTimeout* _timeout) const {
- std::lock_guard<std::mutex> lock(enforceTimeoutMutex_);
- auto it = timeoutMap_.find(_pendingCall);
- if(it != timeoutMap_.end()) {
- auto replyAsyncHandler = std::get<1>(it->second);
- replyAsyncHandler->lock();
- if(!replyAsyncHandler->getTimeoutOccurred()) {
- dbus_timeout_handle(_timeout);
- }
- replyAsyncHandler->unlock();
- }
-}
-
void DBusConnection::deleteAsyncHandlers() {
std::vector<DBusMessageReplyAsyncHandler*> asyncHandlers;
{
diff --git a/src/CommonAPI/DBus/DBusDaemonProxy.cpp b/src/CommonAPI/DBus/DBusDaemonProxy.cpp
index 7c2ce50..2258bb7 100644
--- a/src/CommonAPI/DBus/DBusDaemonProxy.cpp
+++ b/src/CommonAPI/DBus/DBusDaemonProxy.cpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2013-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+// Copyright (C) 2013-2020 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
@@ -48,6 +48,9 @@ DBusDaemonProxy::DBusDaemonProxy(const std::shared_ptr<DBusProxyConnection>& dbu
interfaceVersionAttribute_(1, 0) {
}
+DBusDaemonProxy::~DBusDaemonProxy() {
+}
+
void DBusDaemonProxy::init() {
}
@@ -100,7 +103,8 @@ void DBusDaemonProxy::listNames(CommonAPI::CallStatus& callStatus, std::vector<s
DBusInputStream inputStream(dbusMessageReply);
const bool success = DBusSerializableArguments<std::vector<std::string>>::deserialize(inputStream, busNames);
if (!success) {
- callStatus = CallStatus::REMOTE_ERROR;
+ COMMONAPI_ERROR("DBusDaemonProxy::", __func__, ": deserialization failed!");
+ callStatus = CallStatus::SERIALIZATION_ERROR;
return;
}
@@ -113,7 +117,8 @@ void DBusDaemonProxy::nameHasOwner(const std::string& busName, CommonAPI::CallSt
DBusOutputStream outputStream(dbusMethodCall);
bool success = DBusSerializableArguments<std::string>::serialize(outputStream, busName);
if (!success) {
- callStatus = CallStatus::OUT_OF_MEMORY;
+ COMMONAPI_ERROR("DBusDaemonProxy::", __func__, ": serialization failed!");
+ callStatus = CallStatus::SERIALIZATION_ERROR;
return;
}
outputStream.flush();
@@ -131,7 +136,8 @@ void DBusDaemonProxy::nameHasOwner(const std::string& busName, CommonAPI::CallSt
DBusInputStream inputStream(dbusMessageReply);
success = DBusSerializableArguments<bool>::deserialize(inputStream, hasOwner);
if (!success) {
- callStatus = CallStatus::REMOTE_ERROR;
+ COMMONAPI_ERROR("DBusDaemonProxy::", __func__, ": deserialization failed!");
+ callStatus = CallStatus::SERIALIZATION_ERROR;
return;
}
callStatus = CallStatus::SUCCESS;
diff --git a/src/CommonAPI/DBus/DBusError.cpp b/src/CommonAPI/DBus/DBusError.cpp
index 4b51318..2e9f46a 100644
--- a/src/CommonAPI/DBus/DBusError.cpp
+++ b/src/CommonAPI/DBus/DBusError.cpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2013-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+// Copyright (C) 2013-2020 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
diff --git a/src/CommonAPI/DBus/DBusFactory.cpp b/src/CommonAPI/DBus/DBusFactory.cpp
index 332b1d5..ef17f9a 100644
--- a/src/CommonAPI/DBus/DBusFactory.cpp
+++ b/src/CommonAPI/DBus/DBusFactory.cpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2013-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+// Copyright (C) 2013-2020 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
diff --git a/src/CommonAPI/DBus/DBusFreedesktopPropertiesStub.cpp b/src/CommonAPI/DBus/DBusFreedesktopPropertiesStub.cpp
index d9c950f..f4e7252 100644
--- a/src/CommonAPI/DBus/DBusFreedesktopPropertiesStub.cpp
+++ b/src/CommonAPI/DBus/DBusFreedesktopPropertiesStub.cpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2013-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+// Copyright (C) 2013-2020 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
diff --git a/src/CommonAPI/DBus/DBusFunctionalHash.cpp b/src/CommonAPI/DBus/DBusFunctionalHash.cpp
index 7e5dad0..2b54fb5 100644
--- a/src/CommonAPI/DBus/DBusFunctionalHash.cpp
+++ b/src/CommonAPI/DBus/DBusFunctionalHash.cpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2013-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+// Copyright (C) 2013-2020 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
diff --git a/src/CommonAPI/DBus/DBusInputStream.cpp b/src/CommonAPI/DBus/DBusInputStream.cpp
index 1bede6f..6f59741 100644
--- a/src/CommonAPI/DBus/DBusInputStream.cpp
+++ b/src/CommonAPI/DBus/DBusInputStream.cpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2013-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+// Copyright (C) 2013-2020 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
diff --git a/src/CommonAPI/DBus/DBusInstanceAvailabilityStatusChangedEvent.cpp b/src/CommonAPI/DBus/DBusInstanceAvailabilityStatusChangedEvent.cpp
index 8b88753..80bf391 100644
--- a/src/CommonAPI/DBus/DBusInstanceAvailabilityStatusChangedEvent.cpp
+++ b/src/CommonAPI/DBus/DBusInstanceAvailabilityStatusChangedEvent.cpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2013-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+// Copyright (C) 2013-2020 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
@@ -280,5 +280,3 @@ void DBusInstanceAvailabilityStatusChangedEvent::translate(
} // namespace DBus
} // namespace CommonAPI
-
-
diff --git a/src/CommonAPI/DBus/DBusMainLoop.cpp b/src/CommonAPI/DBus/DBusMainLoop.cpp
index 6b3d5e6..dec9888 100755
--- a/src/CommonAPI/DBus/DBusMainLoop.cpp
+++ b/src/CommonAPI/DBus/DBusMainLoop.cpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2013-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+// Copyright (C) 2013-2020 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
@@ -220,17 +220,15 @@ void DBusMainLoop::stop() {
void DBusMainLoop::doSingleIteration(const int64_t& timeout) {
{
- std::lock_guard<std::mutex> itsDispatchSourcesLock(dispatchSourcesMutex_);
+ std::lock_guard<std::recursive_mutex> itsDispatchSourcesLock(dispatchSourcesMutex_);
std::lock_guard<std::mutex> itsWatchesLock(watchesMutex_);
for (auto dispatchSourceIterator = registeredDispatchSources_.begin();
dispatchSourceIterator != registeredDispatchSources_.end();
dispatchSourceIterator++) {
- (dispatchSourceIterator->second)->mutex_->lock();
if ((dispatchSourceIterator->second)->deleteObject_) {
if (!(dispatchSourceIterator->second)->isExecuted_) {
- (dispatchSourceIterator->second)->mutex_->unlock();
bool contained = false;
for (std::set<std::pair<DispatchPriority, DispatchSourceToDispatchStruct*>>::iterator dispatchSourceIteratorInner = sourcesToDispatch_.begin();
dispatchSourceIteratorInner != sourcesToDispatch_.end(); dispatchSourceIteratorInner++) {
@@ -242,8 +240,6 @@ void DBusMainLoop::doSingleIteration(const int64_t& timeout) {
if (!contained) {
delete (dispatchSourceIterator->second)->dispatchSource_;
(dispatchSourceIterator->second)->dispatchSource_ = NULL;
- delete (dispatchSourceIterator->second)->mutex_;
- (dispatchSourceIterator->second)->mutex_ = NULL;
delete dispatchSourceIterator->second;
dispatchSourceIterator = registeredDispatchSources_.erase(dispatchSourceIterator);
}
@@ -251,12 +247,6 @@ void DBusMainLoop::doSingleIteration(const int64_t& timeout) {
break;
}
}
- else {
- (dispatchSourceIterator->second)->mutex_->unlock();
- }
- }
- else {
- (dispatchSourceIterator->second)->mutex_->unlock();
}
}
@@ -264,10 +254,8 @@ void DBusMainLoop::doSingleIteration(const int64_t& timeout) {
watchesIterator != registeredWatches_.end();
watchesIterator++) {
- (watchesIterator->second)->mutex_->lock();
if ((watchesIterator->second)->deleteObject_) {
if (!(watchesIterator->second)->isExecuted_) {
- (watchesIterator->second)->mutex_->unlock();
bool contained = false;
for (auto watchesIteratorInner = watchesToDispatch_.begin();
watchesIteratorInner != watchesToDispatch_.end(); watchesIteratorInner++) {
@@ -279,8 +267,6 @@ void DBusMainLoop::doSingleIteration(const int64_t& timeout) {
if (!contained) {
delete (watchesIterator->second)->watch_;
(watchesIterator->second)->watch_ = NULL;
- delete (watchesIterator->second)->mutex_;
- (watchesIterator->second)->mutex_ = NULL;
delete watchesIterator->second;
watchesIterator = registeredWatches_.erase(watchesIterator);
}
@@ -288,12 +274,6 @@ void DBusMainLoop::doSingleIteration(const int64_t& timeout) {
break;
}
}
- else {
- (watchesIterator->second)->mutex_->unlock();
- }
- }
- else {
- (watchesIterator->second)->mutex_->unlock();
}
}
}
@@ -304,10 +284,8 @@ void DBusMainLoop::doSingleIteration(const int64_t& timeout) {
timeoutIterator != registeredTimeouts_.end();
timeoutIterator++) {
- (timeoutIterator->second)->mutex_->lock();
if ((timeoutIterator->second)->deleteObject_) {
if (!(timeoutIterator->second)->isExecuted_) {
- (timeoutIterator->second)->mutex_->unlock();
bool contained = false;
for (std::set<std::pair<DispatchPriority, TimeoutToDispatchStruct*>>::iterator timeoutIteratorInner = timeoutsToDispatch_.begin();
timeoutIteratorInner != timeoutsToDispatch_.end(); timeoutIteratorInner++) {
@@ -319,8 +297,6 @@ void DBusMainLoop::doSingleIteration(const int64_t& timeout) {
if (!contained) {
delete (timeoutIterator->second)->timeout_;
(timeoutIterator->second)->timeout_ = NULL;
- delete (timeoutIterator->second)->mutex_;
- (timeoutIterator->second)->mutex_ = NULL;
delete timeoutIterator->second;
timeoutIterator = registeredTimeouts_.erase(timeoutIterator);
}
@@ -328,12 +304,6 @@ void DBusMainLoop::doSingleIteration(const int64_t& timeout) {
break;
}
}
- else {
- (timeoutIterator->second)->mutex_->unlock();
- }
- }
- else {
- (timeoutIterator->second)->mutex_->unlock();
}
}
}
@@ -351,22 +321,22 @@ void DBusMainLoop::doSingleIteration(const int64_t& timeout) {
bool DBusMainLoop::prepare(const int64_t& timeout) {
currentMinimalTimeoutInterval_ = timeout;
- dispatchSourcesMutex_.lock();
- for (auto dispatchSourceIterator = registeredDispatchSources_.begin();
- dispatchSourceIterator != registeredDispatchSources_.end();
- dispatchSourceIterator++) {
+ {
+ std::lock_guard<std::recursive_mutex> itsLock(dispatchSourcesMutex_);
+ for (auto dispatchSourceIterator = registeredDispatchSources_.begin();
+ dispatchSourceIterator != registeredDispatchSources_.end();
+ dispatchSourceIterator++) {
+
+ int64_t dispatchTimeout = TIMEOUT_INFINITE;
- int64_t dispatchTimeout = TIMEOUT_INFINITE;
- dispatchSourcesMutex_.unlock();
- if (!(dispatchSourceIterator->second->deleteObject_) &&
- (dispatchSourceIterator->second)->dispatchSource_->prepare(dispatchTimeout)) {
- sourcesToDispatch_.insert(*dispatchSourceIterator);
- } else if (dispatchTimeout > 0 && dispatchTimeout < currentMinimalTimeoutInterval_) {
- currentMinimalTimeoutInterval_ = dispatchTimeout;
+ if (!(dispatchSourceIterator->second)->deleteObject_ &&
+ (dispatchSourceIterator->second)->dispatchSource_->prepare(dispatchTimeout)) {
+ sourcesToDispatch_.insert(*dispatchSourceIterator);
+ } else if (dispatchTimeout > 0 && dispatchTimeout < currentMinimalTimeoutInterval_) {
+ currentMinimalTimeoutInterval_ = dispatchTimeout;
+ }
}
- dispatchSourcesMutex_.lock();
}
- dispatchSourcesMutex_.unlock();
int64_t currentContextTime = getCurrentTimeInMs();
@@ -376,11 +346,7 @@ bool DBusMainLoop::prepare(const int64_t& timeout) {
timeoutPriorityRange != registeredTimeouts_.end();
timeoutPriorityRange++) {
- (timeoutPriorityRange->second)->mutex_->lock();
- bool deleteObject = (timeoutPriorityRange->second)->deleteObject_;
- (timeoutPriorityRange->second)->mutex_->unlock();
-
- if (!deleteObject) {
+ if (!(timeoutPriorityRange->second)->deleteObject_) {
if (!(timeoutPriorityRange->second)->timeoutElapsed_) { // check that timeout is not elapsed
int64_t intervalToReady = (timeoutPriorityRange->second)->timeout_->getReadyTime()
- currentContextTime;
@@ -450,11 +416,7 @@ void DBusMainLoop::poll() {
timeoutPriorityRange != registeredTimeouts_.end();
timeoutPriorityRange++) {
- (timeoutPriorityRange->second)->mutex_->lock();
- bool deleteObject = (timeoutPriorityRange->second)->deleteObject_;
- (timeoutPriorityRange->second)->mutex_->unlock();
-
- if (!deleteObject) {
+ if (!(timeoutPriorityRange->second)->deleteObject_) {
if (!(timeoutPriorityRange->second)->timeoutElapsed_) { // check that timeout is not elapsed
int64_t intervalToReady =
(timeoutPriorityRange->second)->timeout_->getReadyTime()
@@ -491,11 +453,7 @@ bool DBusMainLoop::check() {
registeredWatchIterator != registeredWatches_.end();
registeredWatchIterator++) {
- (registeredWatchIterator->second)->mutex_->lock();
- bool deleteObject = (registeredWatchIterator->second)->deleteObject_;
- (registeredWatchIterator->second)->mutex_->unlock();
-
- if (!deleteObject) {
+ if (!(registeredWatchIterator->second)->deleteObject_) {
if ((registeredWatchIterator->second)->fd_ == fileDescriptor->fd
&& fileDescriptor->revents) {
watchesToDispatch_.insert(*registeredWatchIterator);
@@ -506,18 +464,18 @@ bool DBusMainLoop::check() {
}
}
- dispatchSourcesMutex_.lock();
- for (auto dispatchSourceIterator = registeredDispatchSources_.begin();
- dispatchSourceIterator != registeredDispatchSources_.end();
- ++dispatchSourceIterator) {
- dispatchSourcesMutex_.unlock();
- if (!dispatchSourceIterator->second->deleteObject_&&
- dispatchSourceIterator->second->dispatchSource_->check()) {
- sourcesToDispatch_.insert(*dispatchSourceIterator);
+ {
+ std::lock_guard<std::recursive_mutex> itsLock(dispatchSourcesMutex_);
+ for (auto dispatchSourceIterator = registeredDispatchSources_.begin();
+ dispatchSourceIterator != registeredDispatchSources_.end();
+ ++dispatchSourceIterator) {
+
+ if (!(dispatchSourceIterator->second)->deleteObject_ &&
+ dispatchSourceIterator->second->dispatchSource_->check()) {
+ sourcesToDispatch_.insert(*dispatchSourceIterator);
+ }
}
- dispatchSourcesMutex_.lock();
}
- dispatchSourcesMutex_.unlock();
return (!timeoutsToDispatch_.empty() ||
!watchesToDispatch_.empty() ||
@@ -530,17 +488,12 @@ void DBusMainLoop::dispatch() {
for (auto timeoutIterator = timeoutsToDispatch_.begin();
timeoutIterator != timeoutsToDispatch_.end(); timeoutIterator++) {
auto timeoutToDispatchStruct = std::get<1>(*timeoutIterator);
- timeoutToDispatchStruct->mutex_->lock();
if (!timeoutToDispatchStruct->deleteObject_) {
timeoutToDispatchStruct->isExecuted_ = true;
- timeoutToDispatchStruct->mutex_->unlock();
timeoutToDispatchStruct->timeout_->dispatch();
- timeoutToDispatchStruct->mutex_->lock();
timeoutToDispatchStruct->isExecuted_ = false;
}
- timeoutToDispatchStruct->mutex_->unlock();
}
-
timeoutsToDispatch_.clear();
}
@@ -549,17 +502,13 @@ void DBusMainLoop::dispatch() {
for (auto watchIterator = watchesToDispatch_.begin();
watchIterator != watchesToDispatch_.end(); watchIterator++) {
auto watchToDispatchStruct = std::get<1>(*watchIterator);
- watchToDispatchStruct->mutex_->lock();
if (!watchToDispatchStruct->deleteObject_) {
watchToDispatchStruct->isExecuted_ = true;
- watchToDispatchStruct->mutex_->unlock();
Watch* watch = watchToDispatchStruct->watch_;
const unsigned int flags = (unsigned int)(watch->getAssociatedFileDescriptor().events);
watch->dispatch(flags);
- watchToDispatchStruct->mutex_->lock();
watchToDispatchStruct->isExecuted_ = false;
}
- watchToDispatchStruct->mutex_->unlock();
}
watchesToDispatch_.clear();
}
@@ -571,20 +520,14 @@ void DBusMainLoop::dispatch() {
dispatchSourceIterator != sourcesToDispatch_.end() && !isBroken_;
dispatchSourceIterator++) {
auto dispatchSourceToDispatchStruct = std::get<1>(*dispatchSourceIterator);
- dispatchSourceToDispatchStruct->mutex_->lock();
if (!dispatchSourceToDispatchStruct->deleteObject_) {
dispatchSourceToDispatchStruct->isExecuted_ = true;
- dispatchSourceToDispatchStruct->mutex_->unlock();
while(!dispatchSourceToDispatchStruct->deleteObject_ &&
dispatchSourceToDispatchStruct->dispatchSource_->dispatch());
- dispatchSourceToDispatchStruct->mutex_->lock();
dispatchSourceToDispatchStruct->isExecuted_ = false;
}
- dispatchSourceToDispatchStruct->mutex_->unlock();
- }
- {
- sourcesToDispatch_.clear();
}
+ sourcesToDispatch_.clear();
}
}
@@ -635,14 +578,12 @@ void DBusMainLoop::wakeupAck() {
void DBusMainLoop::cleanup() {
{
- std::lock_guard<std::mutex> itsLock(dispatchSourcesMutex_);
+ std::lock_guard<std::recursive_mutex> itsLock(dispatchSourcesMutex_);
for (auto dispatchSourceIterator = registeredDispatchSources_.begin();
dispatchSourceIterator != registeredDispatchSources_.end();) {
delete (dispatchSourceIterator->second)->dispatchSource_;
(dispatchSourceIterator->second)->dispatchSource_ = NULL;
- delete (dispatchSourceIterator->second)->mutex_;
- (dispatchSourceIterator->second)->mutex_ = NULL;
delete dispatchSourceIterator->second;
dispatchSourceIterator = registeredDispatchSources_.erase(dispatchSourceIterator);
}
@@ -655,8 +596,6 @@ void DBusMainLoop::cleanup() {
delete (timeoutIterator->second)->timeout_;
(timeoutIterator->second)->timeout_ = NULL;
- delete (timeoutIterator->second)->mutex_;
- (timeoutIterator->second)->mutex_ = NULL;
delete timeoutIterator->second;
timeoutIterator = registeredTimeouts_.erase(timeoutIterator);
}
@@ -669,8 +608,6 @@ void DBusMainLoop::cleanup() {
delete (watchesIterator->second)->watch_;
(watchesIterator->second)->watch_ = NULL;
- delete (watchesIterator->second)->mutex_;
- (watchesIterator->second)->mutex_ = NULL;
delete watchesIterator->second;
watchesIterator = registeredWatches_.erase(watchesIterator);
}
@@ -698,22 +635,20 @@ void DBusMainLoop::unregisterFileDescriptor(
void DBusMainLoop::registerDispatchSource(DispatchSource* dispatchSource,
const DispatchPriority dispatchPriority) {
- DispatchSourceToDispatchStruct* dispatchSourceStruct = new DispatchSourceToDispatchStruct(dispatchSource, new std::mutex, false, false);
- std::lock_guard<std::mutex> itsLock(dispatchSourcesMutex_);
+ DispatchSourceToDispatchStruct* dispatchSourceStruct = new DispatchSourceToDispatchStruct(dispatchSource, false, false);
+ std::lock_guard<std::recursive_mutex> itsLock(dispatchSourcesMutex_);
registeredDispatchSources_.insert({ dispatchPriority, dispatchSourceStruct });
}
void DBusMainLoop::unregisterDispatchSource(DispatchSource* dispatchSource) {
{
- std::lock_guard<std::mutex> itsLock(dispatchSourcesMutex_);
+ std::lock_guard<std::recursive_mutex> itsLock(dispatchSourcesMutex_);
for (auto dispatchSourceIterator = registeredDispatchSources_.begin();
dispatchSourceIterator != registeredDispatchSources_.end();
dispatchSourceIterator++) {
if ((dispatchSourceIterator->second)->dispatchSource_ == dispatchSource){
- (dispatchSourceIterator->second)->mutex_->lock();
(dispatchSourceIterator->second)->deleteObject_ = true;
- (dispatchSourceIterator->second)->mutex_->unlock();
break;
}
}
@@ -728,13 +663,12 @@ void DBusMainLoop::registerWatch(Watch* watch,
registerFileDescriptor(fdToRegister);
std::lock_guard<std::mutex> itsLock(watchesMutex_);
- std::mutex* mtx = new std::mutex;
#ifdef _WIN32
std::atomic_signal_fence(std::memory_order_acq_rel);
#else
asm volatile ("":::"memory");
#endif
- WatchToDispatchStruct* watchStruct = new WatchToDispatchStruct(fdToRegister.fd, watch, mtx, false, false);
+ WatchToDispatchStruct* watchStruct = new WatchToDispatchStruct(fdToRegister.fd, watch, false, false);
registeredWatches_.insert({ dispatchPriority, watchStruct});
}
@@ -747,9 +681,7 @@ void DBusMainLoop::unregisterWatch(Watch* watch) {
watchIterator != registeredWatches_.end(); watchIterator++) {
if ((watchIterator->second)->watch_ == watch) {
- (watchIterator->second)->mutex_->lock();
(watchIterator->second)->deleteObject_ = true;
- (watchIterator->second)->mutex_->unlock();
break;
}
}
@@ -758,7 +690,7 @@ void DBusMainLoop::unregisterWatch(Watch* watch) {
void DBusMainLoop::registerTimeout(Timeout* timeout,
const DispatchPriority dispatchPriority) {
- TimeoutToDispatchStruct* timeoutStruct = new TimeoutToDispatchStruct(timeout, new std::mutex, false, false, false);
+ TimeoutToDispatchStruct* timeoutStruct = new TimeoutToDispatchStruct(timeout, false, false, false);
std::lock_guard<std::mutex> itsLock(timeoutsMutex_);
registeredTimeouts_.insert({ dispatchPriority, timeoutStruct });
}
@@ -771,9 +703,7 @@ void DBusMainLoop::unregisterTimeout(Timeout* timeout) {
timeoutIterator++) {
if ((timeoutIterator->second)->timeout_ == timeout) {
- (timeoutIterator->second)->mutex_->lock();
(timeoutIterator->second)->deleteObject_ = true;
- (timeoutIterator->second)->mutex_->unlock();
break;
}
}
diff --git a/src/CommonAPI/DBus/DBusMainLoopContext.cpp b/src/CommonAPI/DBus/DBusMainLoopContext.cpp
index 150676e..c68e296 100644
--- a/src/CommonAPI/DBus/DBusMainLoopContext.cpp
+++ b/src/CommonAPI/DBus/DBusMainLoopContext.cpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2013-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+// Copyright (C) 2013-2020 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
@@ -23,7 +23,7 @@
namespace CommonAPI {
namespace DBus {
-DBusDispatchSource::DBusDispatchSource(DBusConnection* dbusConnection):
+DBusDispatchSource::DBusDispatchSource(std::weak_ptr<DBusConnection> dbusConnection):
dbusConnection_(dbusConnection) {
}
@@ -32,15 +32,24 @@ DBusDispatchSource::~DBusDispatchSource() {
bool DBusDispatchSource::prepare(int64_t &_timeout) {
_timeout = -1;
- return dbusConnection_->isDispatchReady();
+ if(auto itsConnection = dbusConnection_.lock()) {
+ return itsConnection->isDispatchReady();
+ }
+ return false;
}
bool DBusDispatchSource::check() {
- return dbusConnection_->isDispatchReady();
+ if(auto itsConnection = dbusConnection_.lock()) {
+ return itsConnection->isDispatchReady();
+ }
+ return false;
}
bool DBusDispatchSource::dispatch() {
- return dbusConnection_->singleDispatch();
+ if(auto itsConnection = dbusConnection_.lock()) {
+ return itsConnection->singleDispatch();
+ }
+ return false;
}
DBusQueueDispatchSource::DBusQueueDispatchSource(DBusQueueWatch* watch) :
@@ -467,77 +476,5 @@ void DBusQueueWatch::processQueueEntry(std::shared_ptr<QueueEntry> _queueEntry)
}
}
-#ifdef _WIN32
-__declspec(thread) DBusTimeout* DBusTimeout::currentTimeout_ = NULL;
-#else
-thread_local DBusTimeout* DBusTimeout::currentTimeout_ = NULL;
-#endif
-
-DBusTimeout::DBusTimeout(::DBusTimeout* libdbusTimeout, std::weak_ptr<MainLoopContext>& mainLoopContext,
- std::weak_ptr<DBusConnection>& dbusConnection) :
- dueTimeInMs_(TIMEOUT_INFINITE),
- libdbusTimeout_(libdbusTimeout),
- mainLoopContext_(mainLoopContext),
- dbusConnection_(dbusConnection),
- pendingCall_(NULL) {
- currentTimeout_ = this;
-}
-
-bool DBusTimeout::isReadyToBeMonitored() {
- return 0 != dbus_timeout_get_enabled(libdbusTimeout_);
-}
-
-void DBusTimeout::startMonitoring() {
- auto lockedContext = mainLoopContext_.lock();
- if (NULL == lockedContext) {
- COMMONAPI_ERROR(std::string(__FUNCTION__) + " lockedContext == NULL");
- } else {
- recalculateDueTime();
- lockedContext->registerTimeoutSource(this);
- }
-}
-
-void DBusTimeout::stopMonitoring() {
- dueTimeInMs_ = TIMEOUT_INFINITE;
- auto lockedContext = mainLoopContext_.lock();
- if (lockedContext) {
- lockedContext->deregisterTimeoutSource(this);
- }
-}
-
-bool DBusTimeout::dispatch() {
- std::shared_ptr<DBusConnection> itsConnection = dbusConnection_.lock();
- if(itsConnection) {
- if(itsConnection->setDispatching(true)) {
- recalculateDueTime();
- itsConnection->setPendingCallTimedOut(pendingCall_, libdbusTimeout_);
- itsConnection->setDispatching(false);
- return true;
- }
- }
- return false;
-}
-
-int64_t DBusTimeout::getTimeoutInterval() const {
- return dbus_timeout_get_interval(libdbusTimeout_);
-}
-
-int64_t DBusTimeout::getReadyTime() const {
- return dueTimeInMs_;
-}
-
-void DBusTimeout::recalculateDueTime() {
- if(dbus_timeout_get_enabled(libdbusTimeout_)) {
- int intervalInMs = dbus_timeout_get_interval(libdbusTimeout_);
- dueTimeInMs_ = getCurrentTimeInMs() + intervalInMs;
- } else {
- dueTimeInMs_ = TIMEOUT_INFINITE;
- }
-}
-
-void DBusTimeout::setPendingCall(DBusPendingCall* _pendingCall) {
- pendingCall_ = _pendingCall;
-}
-
} // namespace DBus
} // namespace CommonAPI
diff --git a/src/CommonAPI/DBus/DBusMessage.cpp b/src/CommonAPI/DBus/DBusMessage.cpp
index 4bdf760..b6ad6ba 100644
--- a/src/CommonAPI/DBus/DBusMessage.cpp
+++ b/src/CommonAPI/DBus/DBusMessage.cpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2013-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+// Copyright (C) 2013-2020 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
diff --git a/src/CommonAPI/DBus/DBusObjectManager.cpp b/src/CommonAPI/DBus/DBusObjectManager.cpp
index cf5fbc2..eb53506 100644
--- a/src/CommonAPI/DBus/DBusObjectManager.cpp
+++ b/src/CommonAPI/DBus/DBusObjectManager.cpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2013-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+// Copyright (C) 2013-2020 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
diff --git a/src/CommonAPI/DBus/DBusObjectManagerStub.cpp b/src/CommonAPI/DBus/DBusObjectManagerStub.cpp
index 226c825..845cd50 100644
--- a/src/CommonAPI/DBus/DBusObjectManagerStub.cpp
+++ b/src/CommonAPI/DBus/DBusObjectManagerStub.cpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2013-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+// Copyright (C) 2013-2020 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
diff --git a/src/CommonAPI/DBus/DBusOutputStream.cpp b/src/CommonAPI/DBus/DBusOutputStream.cpp
index 3f77c8f..31b4f62 100644
--- a/src/CommonAPI/DBus/DBusOutputStream.cpp
+++ b/src/CommonAPI/DBus/DBusOutputStream.cpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2013-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+// Copyright (C) 2013-2020 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
@@ -16,7 +16,8 @@ namespace CommonAPI {
namespace DBus {
DBusOutputStream::DBusOutputStream(DBusMessage dbusMessage)
- : dbusMessage_(dbusMessage) {
+ : errorOccurred_(false),
+ dbusMessage_(dbusMessage) {
}
// Internal
@@ -36,7 +37,7 @@ size_t DBusOutputStream::popPosition() {
// TODO Check where dbusError_ is set
bool DBusOutputStream::hasError() const {
- return dbusError_;
+ return errorOccurred_;
}
// Writes the data that was buffered within this #DBusOutputMessageStream to
@@ -52,6 +53,7 @@ void DBusOutputStream::flush() {
}
void DBusOutputStream::setError() {
+ errorOccurred_ = true;
}
/**
diff --git a/src/CommonAPI/DBus/DBusProxy.cpp b/src/CommonAPI/DBus/DBusProxy.cpp
index 2c11d8f..49d29b6 100644
--- a/src/CommonAPI/DBus/DBusProxy.cpp
+++ b/src/CommonAPI/DBus/DBusProxy.cpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2013-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+// Copyright (C) 2013-2020 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
@@ -651,6 +651,8 @@ void DBusProxy::freeDesktopGetCurrentValueForSignalListener(
_message,
DBusProxyAsyncSignalMemberCallbackHandler<DBusProxy>::create(delegate, dbusSignalHandler, subscription),
&defaultCallInfo);
+ } else {
+ COMMONAPI_ERROR("DBusProxy::", __func__, ": serialization failed!");
}
} else {
availabilityMutex_.unlock();
diff --git a/src/CommonAPI/DBus/DBusProxyBase.cpp b/src/CommonAPI/DBus/DBusProxyBase.cpp
index f4add0e..ce5d17f 100644
--- a/src/CommonAPI/DBus/DBusProxyBase.cpp
+++ b/src/CommonAPI/DBus/DBusProxyBase.cpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2013-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+// Copyright (C) 2013-2020 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
diff --git a/src/CommonAPI/DBus/DBusProxyManager.cpp b/src/CommonAPI/DBus/DBusProxyManager.cpp
index a522bf4..8355066 100644
--- a/src/CommonAPI/DBus/DBusProxyManager.cpp
+++ b/src/CommonAPI/DBus/DBusProxyManager.cpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2013-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+// Copyright (C) 2013-2020 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
diff --git a/src/CommonAPI/DBus/DBusServiceRegistry.cpp b/src/CommonAPI/DBus/DBusServiceRegistry.cpp
index 2953d12..247aa2e 100644
--- a/src/CommonAPI/DBus/DBusServiceRegistry.cpp
+++ b/src/CommonAPI/DBus/DBusServiceRegistry.cpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2013-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+// Copyright (C) 2013-2020 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
@@ -23,7 +23,7 @@ std::mutex DBusServiceRegistry::registriesMutex_;
static CommonAPI::CallInfo serviceRegistryInfo(10000);
std::shared_ptr<DBusServiceRegistry>
-DBusServiceRegistry::get(std::shared_ptr<DBusProxyConnection> _connection, bool _insert) {
+DBusServiceRegistry::get(const std::shared_ptr<DBusProxyConnection> &_connection, bool _insert) {
std::unique_lock<std::mutex> itsGuard(registriesMutex_);
auto registries = getRegistryMap();
auto registryIterator = registries->find(_connection.get());
@@ -43,7 +43,7 @@ DBusServiceRegistry::get(std::shared_ptr<DBusProxyConnection> _connection, bool
}
void
-DBusServiceRegistry::remove(std::shared_ptr<DBusProxyConnection> _connection) {
+DBusServiceRegistry::remove(const std::shared_ptr<DBusProxyConnection> &_connection) {
std::lock_guard<std::mutex> itsGuard(registriesMutex_);
auto registries = getRegistryMap();
registries->erase(_connection.get());
@@ -759,6 +759,7 @@ bool DBusServiceRegistry::getManagedObjects(const std::string& dbusServiceName,
DBusInputStream input(reply);
if (!DBusSerializableArguments<DBusObjectManagerStub::DBusObjectPathAndInterfacesDict>::deserialize(
input, availableServiceInstances) || error)
+ COMMONAPI_ERROR("DBusServiceRegistry::", __func__, ": deserialization failed!");
return false;
}
return true;
diff --git a/src/CommonAPI/DBus/DBusStubAdapter.cpp b/src/CommonAPI/DBus/DBusStubAdapter.cpp
index 44ed866..ecdbb56 100644
--- a/src/CommonAPI/DBus/DBusStubAdapter.cpp
+++ b/src/CommonAPI/DBus/DBusStubAdapter.cpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2013-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+// Copyright (C) 2013-2020 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
diff --git a/src/murmurhash/MurmurHash3.cpp b/src/murmurhash/MurmurHash3.cpp
index 86ca147..01292e3 100644
--- a/src/murmurhash/MurmurHash3.cpp
+++ b/src/murmurhash/MurmurHash3.cpp
@@ -130,7 +130,9 @@ void MurmurHash3_x86_32 ( const void * key, unsigned int len,
switch(len & 3)
{
case 3: k1 ^= uint32_t(tail[2] << 16);
+ /* FALLTHROUGH */
case 2: k1 ^= uint32_t(tail[1] << 8);
+ /* FALLTHROUGH */
case 1: k1 ^= tail[0];
k1 *= c1; k1 = ROTL32(k1,15); k1 *= c2; h1 ^= k1;
};
@@ -205,25 +207,36 @@ void MurmurHash3_x86_128 ( const void * key, const unsigned int len,
switch(len & 15)
{
case 15: k4 ^= uint32_t(tail[14] << 16);
+ /* FALLTHROUGH */
case 14: k4 ^= uint32_t(tail[13] << 8);
+ /* FALLTHROUGH */
case 13: k4 ^= tail[12];
k4 *= c4; k4 = ROTL32(k4,18); k4 *= c1; h4 ^= k4;
-
+ /* FALLTHROUGH */
case 12: k3 ^= uint32_t(tail[11] << 24);
+ /* FALLTHROUGH */
case 11: k3 ^= uint32_t(tail[10] << 16);
+ /* FALLTHROUGH */
case 10: k3 ^= uint32_t(tail[ 9] << 8);
+ /* FALLTHROUGH */
case 9: k3 ^= tail[ 8];
k3 *= c3; k3 = ROTL32(k3,17); k3 *= c4; h3 ^= k3;
-
+ /* FALLTHROUGH */
case 8: k2 ^= uint32_t(tail[ 7] << 24);
+ /* FALLTHROUGH */
case 7: k2 ^= uint32_t(tail[ 6] << 16);
+ /* FALLTHROUGH */
case 6: k2 ^= uint32_t(tail[ 5] << 8);
+ /* FALLTHROUGH */
case 5: k2 ^= tail[ 4];
k2 *= c2; k2 = ROTL32(k2,16); k2 *= c3; h2 ^= k2;
-
+ /* FALLTHROUGH */
case 4: k1 ^= uint32_t(tail[ 3] << 24);
+ /* FALLTHROUGH */
case 3: k1 ^= uint32_t(tail[ 2] << 16);
+ /* FALLTHROUGH */
case 2: k1 ^= uint32_t(tail[ 1] << 8);
+ /* FALLTHROUGH */
case 1: k1 ^= tail[ 0];
k1 *= c1; k1 = ROTL32(k1,15); k1 *= c2; h1 ^= k1;
};
@@ -294,21 +307,34 @@ void MurmurHash3_x64_128 ( const void * key, const unsigned int len,
switch(len & 15)
{
case 15: k2 ^= uint64_t(tail[14]) << 48;
+ /* FALLTHROUGH */
case 14: k2 ^= uint64_t(tail[13]) << 40;
+ /* FALLTHROUGH */
case 13: k2 ^= uint64_t(tail[12]) << 32;
+ /* FALLTHROUGH */
case 12: k2 ^= uint64_t(tail[11]) << 24;
+ /* FALLTHROUGH */
case 11: k2 ^= uint64_t(tail[10]) << 16;
+ /* FALLTHROUGH */
case 10: k2 ^= uint64_t(tail[ 9]) << 8;
+ /* FALLTHROUGH */
case 9: k2 ^= uint64_t(tail[ 8]) << 0;
k2 *= c2; k2 = ROTL64(k2,33); k2 *= c1; h2 ^= k2;
-
+ /* FALLTHROUGH */
case 8: k1 ^= uint64_t(tail[ 7]) << 56;
+ /* FALLTHROUGH */
case 7: k1 ^= uint64_t(tail[ 6]) << 48;
+ /* FALLTHROUGH */
case 6: k1 ^= uint64_t(tail[ 5]) << 40;
+ /* FALLTHROUGH */
case 5: k1 ^= uint64_t(tail[ 4]) << 32;
+ /* FALLTHROUGH */
case 4: k1 ^= uint64_t(tail[ 3]) << 24;
+ /* FALLTHROUGH */
case 3: k1 ^= uint64_t(tail[ 2]) << 16;
+ /* FALLTHROUGH */
case 2: k1 ^= uint64_t(tail[ 1]) << 8;
+ /* FALLTHROUGH */
case 1: k1 ^= uint64_t(tail[ 0]) << 0;
k1 *= c1; k1 = ROTL64(k1,31); k1 *= c2; h1 ^= k1;
};
@@ -332,4 +358,3 @@ void MurmurHash3_x64_128 ( const void * key, const unsigned int len,
}
//-----------------------------------------------------------------------------
-
diff --git a/src/pugixml/pugixml.cpp b/src/pugixml/pugixml.cpp
index a97e065..84144e0 100644
--- a/src/pugixml/pugixml.cpp
+++ b/src/pugixml/pugixml.cpp
@@ -8119,7 +8119,7 @@ PUGI__NS_BEGIN
// fallthrough to type conversion
}
-
+ /* FALLTHRU */
default:
{
switch (_rettype)
@@ -8255,7 +8255,7 @@ PUGI__NS_BEGIN
// fallthrough to type conversion
}
-
+ /* FALLTHRU */
default:
{
switch (_rettype)
@@ -8524,7 +8524,7 @@ PUGI__NS_BEGIN
// fallthrough to type conversion
}
-
+ /* FALLTHROUGH */
default:
{
switch (_rettype)
@@ -8673,7 +8673,7 @@ PUGI__NS_BEGIN
// fallthrough to type conversion
}
-
+ /* FALLTHROUGH */
default:
assert(0 && "Wrong expression for return type node set");
return xpath_node_set_raw();
diff --git a/src/test/CMakeLists.txt b/src/test/CMakeLists.txt
index 3707379..5e8cd02 100644
--- a/src/test/CMakeLists.txt
+++ b/src/test/CMakeLists.txt
@@ -23,53 +23,6 @@ if ("${USE_INSTALLED_DBUS}" STREQUAL "OFF")
)
endif()
-set(VERSION "v1")
-
-set(TestInterfaceSources src-gen/core/commonapi/tests/DerivedTypeCollection.cpp
- src-gen/core/${VERSION}/commonapi/tests/TestInterfaceStubDefault.cpp)
-
-set(TestInterfaceDBusSources ${TestInterfaceSources}
- src-gen/dbus/${VERSION}/commonapi/tests/TestInterfaceDBusProxy.cpp
- src-gen/dbus/${VERSION}/commonapi/tests/TestInterfaceDBusStubAdapter.cpp
- src-gen/dbus/${VERSION}/fake/legacy/service/LegacyInterfaceDBusProxy.cpp
- src-gen/dbus/${VERSION}/fake/legacy/service/LegacyInterfaceNoObjectManagerDBusProxy.cpp)
-
-set(TestInterfaceManagerSources src-gen/core/${VERSION}/commonapi/tests/TestInterfaceManagerStubDefault.cpp)
-
-set(TestInterfaceManagerDBusSources ${TestInterfaceManagerSources}
- src-gen/dbus/${VERSION}/commonapi/tests/TestInterfaceManagerDBusProxy.cpp
- src-gen/dbus/${VERSION}/commonapi/tests/TestInterfaceManagerDBusStubAdapter.cpp)
-
-set(FreedesktopPropertiesSources src-gen/core/${VERSION}/commonapi/tests/TestFreedesktopInterfaceStubDefault.cpp
- src-gen/core/${VERSION}/commonapi/tests/TestFreedesktopDerivedInterfaceStubDefault.cpp)
-
-set(FreedesktopPropertiesDBusSources ${FreedesktopPropertiesSources}
- src-gen/dbus/${VERSION}/commonapi/tests/TestFreedesktopInterfaceDBusProxy.cpp
- src-gen/dbus/${VERSION}/commonapi/tests/TestFreedesktopInterfaceDBusStubAdapter.cpp
- src-gen/dbus/${VERSION}/commonapi/tests/TestFreedesktopDerivedInterfaceDBusProxy.cpp
- src-gen/dbus/${VERSION}/commonapi/tests/TestFreedesktopDerivedInterfaceDBusStubAdapter.cpp)
-
-set(ManagedSources src-gen/core/${VERSION}/commonapi/tests/managed/LeafInterfaceStubDefault.cpp
- src-gen/core/${VERSION}/commonapi/tests/managed/BranchInterfaceStubDefault.cpp
- src-gen/core/${VERSION}/commonapi/tests/managed/RootInterfaceStubDefault.cpp
- src-gen/core/${VERSION}/commonapi/tests/managed/SecondRootStubDefault.cpp)
-
-set(ManagedDBusSources ${ManagedSources}
- src-gen/dbus/${VERSION}/commonapi/tests/managed/RootInterfaceDBusProxy.cpp
- src-gen/dbus/${VERSION}/commonapi/tests/managed/RootInterfaceDBusStubAdapter.cpp
- src-gen/dbus/${VERSION}/commonapi/tests/managed/LeafInterfaceDBusProxy.cpp
- src-gen/dbus/${VERSION}/commonapi/tests/managed/LeafInterfaceDBusStubAdapter.cpp
- src-gen/dbus/${VERSION}/commonapi/tests/managed/BranchInterfaceDBusProxy.cpp
- src-gen/dbus/${VERSION}/commonapi/tests/managed/BranchInterfaceDBusStubAdapter.cpp
- src-gen/dbus/${VERSION}/commonapi/tests/managed/SecondRootDBusProxy.cpp
- src-gen/dbus/${VERSION}/commonapi/tests/managed/SecondRootDBusStubAdapter.cpp)
-
-set(ExtendedInterfaceSources src-gen/core/${VERSION}/commonapi/tests/ExtendedInterfaceStubDefault.cpp)
-
-set(ExtendedInterfaceDBusSources ${ExtendedInterfaceSources}
- src-gen/dbus/${VERSION}/commonapi/tests/ExtendedInterfaceDBusProxy.cpp
- src-gen/dbus/${VERSION}/commonapi/tests/ExtendedInterfaceDBusStubAdapter.cpp)
-
if (MSVC)
set(TEST_LINK_LIBRARIES ${DBus_LDFLAGS} CommonAPI-DBus CommonAPI gtest )
else()
diff --git a/src/test/DBusClientIdTest.cpp b/src/test/DBusClientIdTest.cpp
index d94a4aa..a94a2af 100644
--- a/src/test/DBusClientIdTest.cpp
+++ b/src/test/DBusClientIdTest.cpp
@@ -36,7 +36,12 @@ public:
std::size_t hashCode() {
return 0;
}
-
+ CommonAPI::uid_t getUid() const {
+ return 0;
+ }
+ CommonAPI::gid_t getGid() const {
+ return 0;
+ }
};
TEST_F(DBusClientIdTest, TestClientIdImplementation) {