Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vSomeIP 3.5.0 #731

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@ if (ENABLE_SIGNAL_HANDLING)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DVSOMEIP_ENABLE_SIGNAL_HANDLING")
endif ()

# Event caching
if (ENABLE_DEFAULT_EVENT_CACHING)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DVSOMEIP_ENABLE_DEFAULT_EVENT_CACHING")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

endif ()

if (NOT MSVC)
# Sanitizers

Expand Down
5 changes: 5 additions & 0 deletions implementation/routing/include/routing_manager_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,11 @@ class routing_manager_impl: public routing_manager_base,
service_t _service, instance_t _instance,
const boost::asio::ip::address &_remote_address) const;

#ifdef VSOMEIP_ENABLE_DEFAULT_EVENT_CACHING
bool has_subscribed_eventgroup(
service_t _service, instance_t _instance) const;
#endif // VSOMEIP_ENABLE_DEFAULT_EVENT_CACHING

private:
std::shared_ptr<routing_manager_stub> stub_;
std::shared_ptr<sd::service_discovery> discovery_;
Expand Down
57 changes: 57 additions & 0 deletions implementation/routing/src/routing_manager_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2062,6 +2062,26 @@ bool routing_manager_impl::deliver_message(const byte_t *_data, length_t _size,
return is_delivered;
}

#ifdef VSOMEIP_ENABLE_DEFAULT_EVENT_CACHING
bool
routing_manager_impl::has_subscribed_eventgroup(
service_t _service, instance_t _instance) const {

std::lock_guard<std::mutex> its_lock(eventgroups_mutex_);
auto found_service = eventgroups_.find(_service);
if (found_service != eventgroups_.end()) {
auto found_instance = found_service->second.find(_instance);
if (found_instance != found_service->second.end())
for (const auto &its_eventgroup : found_instance->second)
for (const auto &e : its_eventgroup.second->get_events())
if (!e->get_subscribers().empty())
return true;
}

return false;
}
#endif // VSOMEIP_ENABLE_DEFAULT_EVENT_CACHING

bool routing_manager_impl::deliver_notification(
service_t _service, instance_t _instance,
const byte_t *_data, length_t _length, bool _reliable,
Expand Down Expand Up @@ -2153,13 +2173,50 @@ bool routing_manager_impl::deliver_notification(
}

} else {
#ifdef VSOMEIP_ENABLE_DEFAULT_EVENT_CACHING
if (has_subscribed_eventgroup(_service, _instance)) {
if (!is_suppress_event(_service, _instance, its_event_id)) {
VSOMEIP_WARNING << __func__ << ": Caching unregistered event ["
<< std::hex << std::setw(4) << std::setfill('0') << _service << "."
<< std::hex << std::setw(4) << std::setfill('0') << _instance << "."
<< std::hex << std::setw(4) << std::setfill('0') << its_event_id << "]";
}

routing_manager_base::register_event(host_->get_client(),
_service, _instance, its_event_id, { },
event_type_e::ET_UNKNOWN,
_reliable ? reliability_type_e::RT_RELIABLE
: reliability_type_e::RT_UNRELIABLE,
std::chrono::milliseconds::zero(), false, true, nullptr,
true, true, true);

its_event = find_event(_service, _instance, its_event_id);
if (its_event) {
auto its_length = utility::get_payload_size(_data, _length);
auto its_payload = runtime::get()->create_payload(
&_data[VSOMEIP_PAYLOAD_POS], its_length);
its_event->set_payload(its_payload, true);
} else
VSOMEIP_ERROR << __func__ << ": Event registration failed ["
<< std::hex << std::setw(4) << std::setfill('0') << _service << "."
<< std::hex << std::setw(4) << std::setfill('0') << _instance << "."
<< std::hex << std::setw(4) << std::setfill('0') << its_event_id << "]";
} else if (!is_suppress_event(_service, _instance, its_event_id)) {
VSOMEIP_WARNING << __func__ << ": Dropping unregistered event ["
<< std::hex << std::setw(4) << std::setfill('0') << _service << "."
<< std::hex << std::setw(4) << std::setfill('0') << _instance << "."
<< std::hex << std::setw(4) << std::setfill('0') << its_event_id << "] "
<< "Service has no subscribed eventgroup.";
}
#else
if (!is_suppress_event(_service, _instance, its_event_id)) {
VSOMEIP_WARNING << __func__ << ": Event ["
<< std::hex << std::setw(4) << std::setfill('0') << _service << "."
<< std::hex << std::setw(4) << std::setfill('0') << _instance << "."
<< std::hex << std::setw(4) << std::setfill('0') << its_event_id << "]"
<< " is not registered. The message is dropped.";
}
#endif // VSOMEIP_ENABLE_DEFAULT_EVENT_CACHING
}
return true;
}
Expand Down