Skip to content

Commit

Permalink
Clean-up service info on registration
Browse files Browse the repository at this point in the history
Summary
Clean-up service info on client registration.
Details
These changes fix an issue related to Suspend-To-RAM (STR) where a failure
to de-register the application during suspend prevent it from offering a
service when it tried to re-register.
This is because the routing manager still kept some information from the previous
lifecycle, which caused it to ignore the new information.
The fix involves cleaning-up the local service info of the routing manager
every time that a client tries to register.
  • Loading branch information
Rui Graça authored and duartenfonseca committed Feb 19, 2025
1 parent f73201c commit 9abdb5f
Showing 1 changed file with 22 additions and 31 deletions.
53 changes: 22 additions & 31 deletions implementation/routing/src/routing_manager_stub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -823,38 +823,30 @@ void routing_manager_stub::add_known_client(client_t _client, const std::string
}

void routing_manager_stub::on_register_application(client_t _client) {

auto endpoint = host_->find_local(_client);
if (endpoint) {
VSOMEIP_WARNING << "Reregistering application: " << std::hex << _client
<< ". Last registration might have been taken too long.";
endpoint->stop();
endpoint->start();
} else {
endpoint = host_->find_or_create_local(_client);
{
std::lock_guard<std::mutex> its_lock(routing_info_mutex_);
routing_info_[_client].first = 0;
}
// Find or create a local endpoint.
(void)host_->find_or_create_local(_client);
{
std::lock_guard<std::mutex> its_lock(routing_info_mutex_);
routing_info_[_client].first = 0;
}
#ifndef VSOMEIP_DISABLE_SECURITY
if (configuration_->is_local_routing()) {
vsomeip_sec_client_t its_sec_client;
std::set<std::shared_ptr<policy> > its_policies;

bool has_mapping = configuration_->get_policy_manager()
->get_client_to_sec_client_mapping(_client, its_sec_client);
if (has_mapping) {
if (its_sec_client.port == VSOMEIP_SEC_PORT_UNUSED) {
get_requester_policies(its_sec_client.user,
its_sec_client.group, its_policies);
}

if (!its_policies.empty())
send_requester_policies({ _client }, its_policies);
if (configuration_->is_local_routing()) {
vsomeip_sec_client_t its_sec_client;
std::set<std::shared_ptr<policy> > its_policies;

bool has_mapping = configuration_->get_policy_manager()
->get_client_to_sec_client_mapping(_client, its_sec_client);
if (has_mapping) {
if (its_sec_client.port == VSOMEIP_SEC_PORT_UNUSED) {
get_requester_policies(its_sec_client.user,
its_sec_client.group, its_policies);
}

if (!its_policies.empty())
send_requester_policies({ _client }, its_policies);
}
#endif // !VSOMEIP_DISABLE_SECURITY
}
#endif // !VSOMEIP_DISABLE_SECURITY
}

void routing_manager_stub::on_deregister_application(client_t _client) {
Expand Down Expand Up @@ -990,10 +982,9 @@ void routing_manager_stub::client_registration_func(void) {

for (const auto& r : its_registrations) {
for (auto b : r.second) {
on_deregister_application(r.first);
if (b == registration_type_e::REGISTER) {
on_register_application(r.first);
} else {
on_deregister_application(r.first);
}
// Inform (de)registered client. All others will be informed after
// the client acknowledged its registered state!
Expand Down Expand Up @@ -1129,7 +1120,7 @@ routing_manager_stub::on_net_state_change(
void routing_manager_stub::on_offer_service(client_t _client,
service_t _service, instance_t _instance, major_version_t _major, minor_version_t _minor) {

VSOMEIP_DEBUG << "routing_manager_stub::" << __func__ << ": ON_OFFER_SERVICE("
VSOMEIP_INFO << "routing_manager_stub::" << __func__ << ": ON_OFFER_SERVICE("
<< std::hex << std::setw(4) << std::setfill('0') << _client <<"): ["
<< std::hex << std::setw(4) << std::setfill('0') << _service << "."
<< std::hex << std::setw(4) << std::setfill('0') << _instance
Expand Down

0 comments on commit 9abdb5f

Please sign in to comment.