MCPcopy Create free account
hub / github.com/COVESA/vsomeip / set_routing_state

Method set_routing_state

implementation/routing/src/routing_manager_impl.cpp:2696–2887  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2694}
2695
2696void routing_manager_impl::set_routing_state(routing_state_e _routing_state) {
2697 std::scoped_lock its_lock(on_state_change_mutex_);
2698
2699 if (routing_state_ == _routing_state) {
2700 VSOMEIP_INFO_P << "No routing state change --> do nothing.";
2701 return;
2702 }
2703
2704 routing_state_ = _routing_state;
2705
2706 if (discovery_) {
2707 switch (_routing_state) {
2708 case routing_state_e::RS_SUSPENDED: {
2709 VSOMEIP_INFO_P << "Set routing to RS_SUSPENDED";
2710
2711 {
2712 std::scoped_lock its_inner_lock{offer_serialization_mutex_};
2713 // Remove all stop offers and cancel the shared graceful timer.
2714 last_stop_offer_.clear();
2715 stop_offer_graceful_timer_.cancel();
2716 }
2717
2718 // stop processing of incoming SD messages
2719 discovery_->suspend();
2720
2721 VSOMEIP_INFO_P << "Inform all applications that we are going to suspend.";
2722 send_suspend();
2723
2724 // remove all remote subscriptions to remotely offered services on this node
2725 VSOMEIP_INFO_P << "Expire subscription.";
2726 expire_subscriptions(true);
2727
2728 VSOMEIP_INFO_P << "Stop offered services.";
2729 std::vector<std::shared_ptr<serviceinfo>> _service_infos;
2730 // send StopOffer messages for remotely offered services on this node
2731 for (const auto& [service, instances] : get_offered_services()) {
2732 for (const auto& [instance, info] : instances) {
2733 bool has_reliable(info->get_endpoint(true) != nullptr);
2734 bool has_unreliable(info->get_endpoint(false) != nullptr);
2735 if (has_reliable || has_unreliable) {
2736 const client_t its_client(find_local_client(service, instance));
2737 VSOMEIP_WARNING_P << "Service " << hex4(service) << "." << hex4(instance) << " still offered by "
2738 << hex4(its_client);
2739 }
2740
2741 // collect stop offers to be sent out
2742 discovery_->stop_offer_service(info); // does book-keeping changes only due to stop()
2743 _service_infos.push_back(info);
2744 }
2745 }
2746 // send collected stop offers packed together in one ore multiple SD messages
2747 discovery_->send_collected_stop_offers(_service_infos);
2748 _service_infos.clear();
2749
2750 {
2751 std::scoped_lock its_lock{remote_subscription_state_mutex_};
2752 remote_subscription_state_.clear();
2753 }

Callers

nothing calls this directly

Calls 15

hex4Function · 0.85
resumeMethod · 0.80
set_is_in_mainphaseMethod · 0.80
start_offer_watchdogMethod · 0.80
clearMethod · 0.45
cancelMethod · 0.45
suspendMethod · 0.45
get_endpointMethod · 0.45
stop_offer_serviceMethod · 0.45
wait_until_sentMethod · 0.45

Tested by

no test coverage detected