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

Method del_routing_info

implementation/routing/src/routing_manager_impl.cpp:1762–1843  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1760}
1761
1762void routing_manager_impl::del_routing_info(service_t _service, instance_t _instance, bool _has_reliable, bool _has_unreliable,
1763 bool _trigger_availability) {
1764
1765 std::shared_ptr<serviceinfo> its_info(find_service(_service, _instance));
1766 if (!its_info)
1767 return;
1768
1769 if (_trigger_availability) {
1770 stub_->on_stop_offer_service(VSOMEIP_ROUTING_CLIENT, _service, _instance, its_info->get_major(), its_info->get_minor());
1771 }
1772
1773 // Implicit unsubscribe
1774
1775 std::vector<std::shared_ptr<event>> its_events;
1776 {
1777 // Acquire event_registration_mutex_ before eventgroups_mutex_ to serialize with
1778 // subscribe()/on_subscribe_ack() and atomically clear subscribers with the service removal.
1779 std::scoped_lock its_reg_lock{event_registration_mutex_};
1780 std::scoped_lock its_lock{eventgroups_mutex_};
1781 const auto search = eventgroups_.find(service_instance_t{_service, _instance});
1782
1783 if (search != eventgroups_.end()) {
1784 for (const auto& [eventgroup_id, eventgroup_info] : search->second) {
1785 // As the service is gone, all subscriptions to its events
1786 // do no longer exist and the last received payload is no
1787 // longer valid.
1788 for (auto& its_event : eventgroup_info->get_events()) {
1789 const auto its_subscribers = its_event->get_subscribers();
1790 for (const auto its_subscriber : its_subscribers) {
1791 its_event->remove_subscriber(eventgroup_id, its_subscriber);
1792 }
1793 its_events.push_back(its_event);
1794 }
1795 }
1796 }
1797 }
1798
1799 for (const auto& e : its_events) {
1800 if (e->is_set()) {
1801 VSOMEIP_INFO_P << "Unsetting payload for [" << hex4(_service) << "." << hex4(_instance) << "." << hex4(e->get_event()) << "]";
1802 }
1803 e->unset_payload(true);
1804 }
1805
1806 {
1807 std::scoped_lock its_lock{remote_subscription_state_mutex_};
1808 std::set<std::tuple<service_t, instance_t, eventgroup_t, client_t>> its_invalid;
1809
1810 for (const auto& its_state : remote_subscription_state_) {
1811 if (std::get<0>(its_state.first) == _service && std::get<1>(its_state.first) == _instance) {
1812 its_invalid.insert(its_state.first);
1813 }
1814 }
1815
1816 for (const auto& its_key : its_invalid)
1817 remote_subscription_state_.erase(its_key);
1818 }
1819

Callers 1

process_serviceentryMethod · 0.80

Calls 15

hex4Function · 0.85
endMethod · 0.80
get_eventsMethod · 0.80
get_subscribersMethod · 0.80
remove_subscriberMethod · 0.80
is_setMethod · 0.80
unset_payloadMethod · 0.80
insertMethod · 0.80
on_stop_offer_serviceMethod · 0.45

Tested by

no test coverage detected