| 2338 | } |
| 2339 | |
| 2340 | void routing_manager_client::remove_local(bool _due_to_error, client_t _client, std::set<protocol::service>& _requested_services) { |
| 2341 | |
| 2342 | vsomeip_sec_client_t its_sec_client; |
| 2343 | configuration_->get_policy_manager()->get_client_to_sec_client_mapping(_client, its_sec_client); |
| 2344 | configuration_->get_policy_manager()->remove_client_to_sec_client_mapping(_client); |
| 2345 | auto ep = ep_mgr_->find_local_server_endpoint(_client); |
| 2346 | std::string const env = ep ? ep->get_env() : ""; |
| 2347 | { |
| 2348 | std::scoped_lock its_lock(provider_mutex_); |
| 2349 | auto const subscribed_eventgroups = get_subscriptions(_client, its_lock); |
| 2350 | for (auto its_subscription : subscribed_eventgroups) { |
| 2351 | auto [its_service, its_instance, its_eventgroup] = its_subscription; |
| 2352 | // because we are in the remove local function within which the connection token is bumped, |
| 2353 | // any inflight subscription for this client is going to be dropped, therefore adjust the book-keeping |
| 2354 | // immediately. |
| 2355 | unsubscribe_base(_client, its_service, its_instance, its_eventgroup, ANY_EVENT, its_lock); |
| 2356 | VSOMEIP_INFO << "UNSUBSCRIBE(" << hex4(_client) << "): [" << hex4(its_service) << "." << hex4(its_instance) << "." |
| 2357 | << hex4(its_eventgroup) << "." << hex4(ANY_EVENT) << "]"; |
| 2358 | host_->on_subscription(its_service, its_instance, its_eventgroup, _client, &its_sec_client, env, false, [](bool) { |
| 2359 | // no need to execute anything, subscribers are updated already |
| 2360 | }); |
| 2361 | } |
| 2362 | // remove the provider endpoint under the provider_mutex_ to ensure that no subscription callback (dispatcher thread) |
| 2363 | // can mess up the book-keeping when checking the endpoint token |
| 2364 | ep_mgr_->remove_provider_endpoint(_client, _due_to_error); |
| 2365 | } |
| 2366 | ep_mgr_->remove_consumer_endpoint(_client, _due_to_error); |
| 2367 | { |
| 2368 | std::scoped_lock its_lock(consumer_mutex_); |
| 2369 | address_table_.erase(_client); |
| 2370 | auto removed = available_services_.remove_all_for_client(_client); |
| 2371 | for (auto const& [its_service, its_instance, its_major, its_minor, its_client] : removed) { |
| 2372 | // save the removed available services to re-request them from the router |
| 2373 | _requested_services.emplace(its_service, its_instance, its_major, its_minor); |
| 2374 | on_stop_offer_service(its_service, its_instance, its_major, its_minor, its_lock); |
| 2375 | } |
| 2376 | |
| 2377 | // remove disconnected client from offer service history |
| 2378 | std::set<std::tuple<service_t, instance_t, client_t>> its_clients; |
| 2379 | for (const auto& [si, clients] : available_services_history_) { |
| 2380 | for (const auto& c : clients) { |
| 2381 | if (c == _client) { |
| 2382 | its_clients.insert(std::make_tuple(si.service(), si.instance(), c)); |
| 2383 | } |
| 2384 | } |
| 2385 | } |
| 2386 | |
| 2387 | for (auto& sic : its_clients) { |
| 2388 | const service_instance_t si{std::get<0>(sic), std::get<1>(sic)}; |
| 2389 | available_services_history_[si].erase(std::get<2>(sic)); |
| 2390 | if (available_services_history_[si].empty()) { |
| 2391 | available_services_history_.erase(si); |
| 2392 | } |
| 2393 | } |
| 2394 | } |
| 2395 | } |
| 2396 | |
| 2397 | void routing_manager_client::cleanup_routing_data() { |
nothing calls this directly
no test coverage detected