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

Method send_ping

implementation/routing/src/routing_manager_stub.cpp:1005–1039  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1003}
1004
1005bool routing_manager_stub::send_ping(client_t _client) {
1006
1007 bool has_sent(false);
1008
1009 if (auto its_endpoint = find_local_routing_endpoint(_client); its_endpoint) {
1010 std::scoped_lock its_lock{pinged_clients_mutex_};
1011
1012 if (pinged_clients_.contains(_client)) {
1013 // client was already pinged: don't ping again and wait for answer
1014 // or timeout of previous ping.
1015 has_sent = true;
1016 } else {
1017 pinged_clients_timer_.cancel();
1018 const std::chrono::steady_clock::time_point now(std::chrono::steady_clock::now());
1019
1020 std::chrono::milliseconds next_timeout(VSOMEIP_DEFAULT_PING_TIMEOUT);
1021 for (const auto& tp : pinged_clients_) {
1022 const std::chrono::milliseconds its_clients_timeout =
1023 std::chrono::duration_cast<std::chrono::milliseconds>(now - tp.second);
1024 if (next_timeout > its_clients_timeout) {
1025 next_timeout = its_clients_timeout;
1026 }
1027 }
1028
1029 pinged_clients_[_client] = now;
1030
1031 pinged_clients_timer_.expires_after(next_timeout);
1032 pinged_clients_timer_.async_wait(std::bind(&routing_manager_stub::on_ping_timer_expired, this, std::placeholders::_1));
1033
1034 has_sent = its_endpoint->send(protocol::create_ping_cmd(VSOMEIP_ROUTING_CLIENT));
1035 }
1036 }
1037
1038 return has_sent;
1039}
1040
1041void routing_manager_stub::on_ping_timer_expired(boost::system::error_code const& _error) {
1042 if (_error) {

Callers 2

Calls 6

create_ping_cmdFunction · 0.85
containsMethod · 0.45
cancelMethod · 0.45
expires_afterMethod · 0.45
async_waitMethod · 0.45
sendMethod · 0.45

Tested by

no test coverage detected