Skip to content

Commit

Permalink
capicxx-someip-runtime 3.1.12.4
Browse files Browse the repository at this point in the history
  • Loading branch information
juergengehring committed Jan 25, 2018
1 parent b482888 commit 83b2f35
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 4 deletions.
5 changes: 5 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
Changes
=======

v3.1.12.4
- Fixed calling of on$(BROADCASTNAME)SelectiveSubscriptionChanged
hooks within correct thread context if mainloop integration is used

v3.1.12.3
- Avoid holding mutex when pushing to mainloop queue

Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ message(STATUS "CommonAPI Version: ${CommonAPI_VERSION}")
find_package( Boost 1.54 COMPONENTS system thread log REQUIRED )
include_directories( ${Boost_INCLUDE_DIR} )

find_package (vsomeip 2.9.0 REQUIRED)
find_package (vsomeip 2.10.0 REQUIRED)
message(STATUS "vsomeip version: ${vsomeip_VERSION}")

include_directories (
Expand Down
3 changes: 3 additions & 0 deletions include/CommonAPI/SomeIP/Connection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,9 @@ class Connection:
std::map<instance_id_t,
std::map<eventgroup_id_t,
std::map<event_id_t, std::uint32_t>>>> requestedEvents_;

std::map<service_id_t, std::map<instance_id_t, std::map<eventgroup_id_t, SubsciptionHandler_t>>> subscription_;
std::mutex subscriptionMutex_;
};


Expand Down
57 changes: 56 additions & 1 deletion src/CommonAPI/SomeIP/Connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1068,11 +1068,66 @@ void Connection::queueSubscriptionStatusHandler(service_id_t serviceId,

void Connection::registerSubsciptionHandler(const Address &_address,
const eventgroup_id_t _eventgroup, SubsciptionHandler_t _handler) {
application_->register_subscription_handler(_address.getService(), _address.getInstance(), _eventgroup, _handler);

std::lock_guard<std::mutex> itsLock(subscriptionMutex_);
subscription_[_address.getService()][_address.getInstance()][_eventgroup] = _handler;

if (auto lockedContext = mainLoopContext_.lock()) {
(void)lockedContext;

// create async subscription handler which notifies the stack about
// the subscription result (accepted or not)
auto self = shared_from_this();
auto itsAsyncSubscriptionHandler = [this, self, _address, _eventgroup](
client_id_t _client,
bool _subscribe,
std::function<void(const bool)> _accepted_cb) {

// hooks must be called by the mainloop
proxyPushFunctionToMainLoop([this, _client, _subscribe, _accepted_cb, _address, _eventgroup]() {
SubsciptionHandler_t itsHandler;
{
std::lock_guard<std::mutex> itsLock(subscriptionMutex_);
auto foundService = subscription_.find(_address.getService());
if (foundService != subscription_.end()) {
auto foundInstance = foundService->second.find(_address.getInstance());
if (foundInstance != foundService->second.end()) {
auto foundEventgroup = foundInstance->second.find(_eventgroup);
if (foundEventgroup != foundInstance->second.end()) {
itsHandler = foundEventgroup->second;
}
}
}
}
if(itsHandler) {
_accepted_cb(itsHandler(_client, _subscribe));
} else {
_accepted_cb(true);
}
});

};
application_->register_async_subscription_handler(_address.getService(), _address.getInstance(), _eventgroup, itsAsyncSubscriptionHandler);
} else {
application_->register_subscription_handler(_address.getService(), _address.getInstance(), _eventgroup, _handler);
}
}

void Connection::unregisterSubsciptionHandler(const Address &_address,
const eventgroup_id_t _eventgroup) {
std::lock_guard<std::mutex> itsLock(subscriptionMutex_);
{
auto foundService = subscription_.find(_address.getService());
if (foundService != subscription_.end()) {
auto foundInstance = foundService->second.find(_address.getInstance());
if (foundInstance != foundService->second.end()) {
auto foundEventgroup = foundInstance->second.find(_eventgroup);
if (foundEventgroup != foundInstance->second.end()) {
foundInstance->second.erase(_eventgroup);
}
}
}
}
application_->unregister_subscription_handler(_address.getService(), _address.getInstance(), _eventgroup);
}

Expand Down
4 changes: 2 additions & 2 deletions src/CommonAPI/SomeIP/Factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,10 @@ Factory::unregisterStub(const std::string &_domain,
return false;
}

decrementConnection(connection);

servicesMutex_.unlock();

decrementConnection(connection);

return true;
}

Expand Down

0 comments on commit 83b2f35

Please sign in to comment.