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

Method reconnect

implementation/routing/src/routing_manager_client.cpp:1576–1630  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1574}
1575
1576void routing_manager_client::reconnect() {
1577 {
1578 // ensure that no further connections will be added to the list of endpoints
1579 std::scoped_lock lock(receiver_mutex_);
1580 if (routing_mode_ != routing_mode_e::UDS_ONLY) {
1581 // tcp needs to claim a port to ensure that the sender is not
1582 // blocking a wrong port
1583 if (tcp_receiver_) {
1584 // stop accepting connections + stop existing connections,
1585 // but don't close the socket to not free the claimed port.
1586 tcp_receiver_->halt();
1587 } else {
1588 // TODO this might end up looping forever, if the network is assumed
1589 // to be down. How to break out of this loop in case of "stop" ?
1590 tcp_receiver_ = ep_mgr_->create_local_server(transport_protocol_e::TCP);
1591 }
1592 }
1593
1594 if (uds_receiver_) {
1595 uds_receiver_->stop();
1596 uds_receiver_ = nullptr;
1597 }
1598 }
1599 // Now the set of endpoints should be fixed:
1600 // * no new server endpoint because local_server is stopped
1601 // * no new client endpoint because the statemachine is in the DEREGISTERED state
1602 // (-> send or sub will not lead to a find_or_create
1603 // + because the sender is down no new routing_info for subscriptions)
1604 ep_mgr_->stop_all_endpoints();
1605
1606 // Clean-up Phase
1607 //
1608 configuration_->get_policy_manager()->cleanup_client_to_sec_client_mappings();
1609 {
1610 std::scoped_lock its_lock(provider_mutex_);
1611 clear_remote_subscriptions(its_lock);
1612 cleanup_subscriber(its_lock);
1613 // by clearing the provider endpoints under the provider lock it is guaranteed
1614 // that any in-flight subscription continuation will be invalidated
1615 ep_mgr_->clear_provider_endpoints();
1616 ++lc_count_;
1617 }
1618 // it is not guaranteed that all routing data was used for creating an endpoint
1619 // therefore it is better to remove the whole set, without a dependency to
1620 // a client id.
1621 cleanup_routing_data();
1622 ep_mgr_->clear_consumer_endpoints();
1623
1624 // Restart Phase
1625 //
1626 VSOMEIP_INFO_P << "Application/Client 0x" << hex4(get_client()) << ": Reconnecting to routing manager.";
1627 // inform host about its own registration state changes
1628 host_->on_state(state_type_e::ST_DEREGISTERED);
1629 state_machine_->deregistered();
1630}
1631
1632bool routing_manager_client::is_local_client(client_t _client) const {
1633 return ep_mgr_->find_local_server_endpoint(_client) != nullptr;

Callers

nothing calls this directly

Calls 11

hex4Function · 0.85
haltMethod · 0.80
create_local_serverMethod · 0.80
stop_all_endpointsMethod · 0.80
deregisteredMethod · 0.80
stopMethod · 0.45
get_policy_managerMethod · 0.45
on_stateMethod · 0.45

Tested by

no test coverage detected