Skip to content

Commit

Permalink
CommonAPI-SomeIP 3.1.10.4
Browse files Browse the repository at this point in the history
  • Loading branch information
juergengehring committed Dec 12, 2016
1 parent 13bd21b commit fba3007
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
Changes
=======

v3.1.10.4
- Fixed crash (double free) on destruction of static objects
- Fixed availability issues in verification tests

v3.1.10.3
- Fixed subscription counter handling

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<eventgroup_id_t,
std::map<ProxyConnection::EventHandler* ,
std::pair<std::weak_ptr<ProxyConnection::EventHandler>, std::set<uint32_t>>>>>> pendingSelectiveErrorHandlers_;

std::mutex availabilityCalledMutex_;
std::map<service_id_t, std::map<instance_id_t, bool>> availabilityCalled_;
};


Expand Down
24 changes: 24 additions & 0 deletions src/CommonAPI/SomeIP/Connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,10 @@ void Connection::onConnectionEvent(state_type_e state) {

void Connection::onAvailabilityChange(service_id_t _service, instance_id_t _instance,
bool _is_available) {
{
std::lock_guard<std::mutex> itsLock(availabilityCalledMutex_);
availabilityCalled_[_service][_instance] = true;
}
if (auto lockedContext = mainLoopContext_.lock()) {
std::shared_ptr<AvblQueueEntry> avbl_queue_entry = std::make_shared<AvblQueueEntry>(_service, _instance, _is_available);
watch_->pushQueue(avbl_queue_entry);
Expand Down Expand Up @@ -620,6 +624,26 @@ void Connection::addSelectiveErrorListener(service_id_t serviceId,

bool
Connection::isAvailable(const Address &_address) {
{
std::lock_guard<std::mutex> itsLock(connectionMutex_);
if (connectionStatus_ != state_type_e::ST_REGISTERED) {
return false;
}
}
{
bool availabilityCalled(false);
std::lock_guard<std::mutex> itsLock(availabilityCalledMutex_);
auto its_service = availabilityCalled_.find(_address.getService());
if (its_service != availabilityCalled_.end()) {
auto its_instance = its_service->second.find(_address.getInstance());
if (its_instance != its_service->second.end()) {
availabilityCalled = its_instance->second;
}
}
if (!availabilityCalled) {
return false;
}
}
return application_->is_available(_address.getService(), _address.getInstance(),
_address.getMajorVersion(), _address.getMinorVersion());
}
Expand Down
7 changes: 6 additions & 1 deletion src/CommonAPI/SomeIP/Factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,17 @@
namespace CommonAPI {
namespace SomeIP {

static std::weak_ptr<CommonAPI::Runtime> runtime__;

INITIALIZER(FactoryInit) {
runtime__ = Runtime::get();
Runtime::get()->registerFactory("someip", Factory::get());
}

DEINITIALIZER(FactoryDeinit) {
Runtime::get()->unregisterFactory("someip");
if (auto rt = runtime__.lock()) {
rt->unregisterFactory("someip");
}
}

std::shared_ptr<Factory>
Expand Down

0 comments on commit fba3007

Please sign in to comment.