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

Method on_client_assign_ack

implementation/routing/src/routing_manager_client.cpp:2208–2270  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2206#endif
2207
2208void routing_manager_client::on_client_assign_ack(const client_t& _client, bool _is_tcp) {
2209
2210 if (_client == VSOMEIP_CLIENT_UNSET) {
2211 VSOMEIP_ERROR_P << "(" << host_->get_name() << ":" << hex4(_client) << ") Invalid clientID";
2212 return;
2213 }
2214 // order matters:
2215 // 0. call host (while unlocked to avoid lock inversion)
2216 host_->set_client(_client);
2217
2218#ifdef __linux__
2219 auto const sec_client = get_sec_client();
2220 configuration_->get_policy_manager()->store_client_to_sec_client_mapping(_client, &sec_client);
2221 configuration_->get_policy_manager()->store_sec_client_to_client_mapping(&sec_client, _client);
2222 // TODO why is there no logic to remove this mapping
2223 // when there was some problem with the registration?
2224#endif
2225
2226 // order matters:
2227 // 1. lock the receiver mutex,
2228 // 2. try to transition the state machine
2229 // this ensures that th receiver init does counter act the potentially
2230 // interleaving stopping of the receiver within the ::stop method.
2231 bool is_started{false};
2232 std::unique_lock its_lock{receiver_mutex_};
2233
2234 init_receiver_side(its_lock);
2235 {
2236 auto start_receiver = [&](auto& _receiver) {
2237 if (_receiver) {
2238 _receiver->set_id(_client);
2239 _receiver->start();
2240 is_started = true;
2241 }
2242 };
2243
2244 switch (routing_mode_) {
2245 case routing_mode_e::UDS_ONLY:
2246 start_receiver(uds_receiver_);
2247 break;
2248 case routing_mode_e::UDS_AND_TCP:
2249 start_receiver(uds_receiver_);
2250 start_receiver(tcp_receiver_);
2251 break;
2252 default: // TCP_ONLY
2253 start_receiver(tcp_receiver_);
2254 break;
2255 }
2256
2257 if (is_started) {
2258 VSOMEIP_INFO_P << "Client 0x" << hex4(get_client()) << " (" << host_->get_name() << ") successfully connected to routing via "
2259 << (_is_tcp ? "TCP" : "UDS") << " ~> registering...";
2260 register_application(_client);
2261 }
2262 }
2263
2264 if (!is_started) {
2265 VSOMEIP_WARNING_P << ": (" << host_->get_name() << ":" << hex4(_client) << ") Receiver not started. Restarting";

Callers

nothing calls this directly

Calls 10

hex4Function · 0.85
deregisteredMethod · 0.80
unlockMethod · 0.80
get_nameMethod · 0.45
set_clientMethod · 0.45
get_policy_managerMethod · 0.45
set_idMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected