From d61c5b092845109f7f07ec7582b332afb1b8517c Mon Sep 17 00:00:00 2001 From: Juergen Gehring Date: Thu, 25 Jan 2018 00:40:03 -0800 Subject: [PATCH] vsomeip 2.9.2 --- CHANGES | 9 +++ CMakeLists.txt | 2 +- .../routing/src/routing_manager_impl.cpp | 58 +++++++++++++------ .../src/service_discovery_impl.cpp | 10 +++- implementation/utility/include/utility.hpp | 16 +++++ 5 files changed, 74 insertions(+), 21 deletions(-) diff --git a/CHANGES b/CHANGES index bf584ba27..a1f4cff0f 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,14 @@ Changes ======= +v2.9.2 +- fix handling of received response messages for unknown + clients. +- Ensure that all external services are marked as offline when + routing_state is set to RS_SUSPENDED +- Ensure to start sending out FindService messages for requested + services after resuming. +- Ensure that the service info is also deleted if no unreliable + communication happened before the service TTL has expired. v2.9.1 - Don't ignore service requests for UDP-only remote services done diff --git a/CMakeLists.txt b/CMakeLists.txt index 2ce790e36..ab6f6cc03 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,7 +8,7 @@ project (vsomeip) set (VSOMEIP_MAJOR_VERSION 2) set (VSOMEIP_MINOR_VERSION 9) -set (VSOMEIP_PATCH_VERSION 1) +set (VSOMEIP_PATCH_VERSION 2) set (VSOMEIP_VERSION ${VSOMEIP_MAJOR_VERSION}.${VSOMEIP_MINOR_VERSION}.${VSOMEIP_PATCH_VERSION}) set (PACKAGE_VERSION ${VSOMEIP_VERSION}) # Used in documentatin/doxygen.in set (CMAKE_VERBOSE_MAKEFILE off) diff --git a/implementation/routing/src/routing_manager_impl.cpp b/implementation/routing/src/routing_manager_impl.cpp index 8cd311ad5..b79eb4edc 100644 --- a/implementation/routing/src/routing_manager_impl.cpp +++ b/implementation/routing/src/routing_manager_impl.cpp @@ -704,6 +704,23 @@ bool routing_manager_impl::send(client_t _client, const byte_t *_data, #endif } } else { + if ((utility::is_response(_data[VSOMEIP_MESSAGE_TYPE_POS]) + || utility::is_error(_data[VSOMEIP_MESSAGE_TYPE_POS])) + && !its_info->is_local()) { + // we received a response/error but neither the hosting application + // nor another local client could be found --> drop + const session_t its_session = VSOMEIP_BYTES_TO_WORD( + _data[VSOMEIP_SESSION_POS_MIN], + _data[VSOMEIP_SESSION_POS_MAX]); + VSOMEIP_ERROR + << "routing_manager_impl::send: Received response/error for unknown client (" + << std::hex << std::setw(4) << std::setfill('0') << its_client << "): [" + << std::hex << std::setw(4) << std::setfill('0') << its_service << "." + << std::hex << std::setw(4) << std::setfill('0') << _instance << "." + << std::hex << std::setw(4) << std::setfill('0') << its_method << "] " + << std::hex << std::setw(4) << std::setfill('0') << its_session; + return false; + } its_target = is_service_discovery ? (sd_info_ ? sd_info_->get_endpoint(false) : nullptr) : its_info->get_endpoint(_reliable); if (its_target) { @@ -2234,9 +2251,7 @@ std::chrono::milliseconds routing_manager_impl::update_routing_info(std::chrono: const std::chrono::seconds default_ttl(DEFAULT_TTL); std::chrono::milliseconds its_smallest_ttl = std::chrono::duration_cast(default_ttl); - std::map > > its_expired_offers; + std::map > its_expired_offers; { std::lock_guard its_lock(services_remote_mutex_); @@ -2247,10 +2262,7 @@ std::chrono::milliseconds routing_manager_impl::update_routing_info(std::chrono: std::chrono::milliseconds precise_ttl = i.second->get_precise_ttl(); if (precise_ttl.count() < _elapsed.count() || precise_ttl.count() == 0) { i.second->set_ttl(0); - its_expired_offers[s.first][i.first] = { - i.second->get_endpoint(true) != nullptr, - i.second->get_endpoint(false) != nullptr - }; + its_expired_offers[s.first].push_back(i.first); } else { std::chrono::milliseconds its_new_ttl(precise_ttl - _elapsed); i.second->set_precise_ttl(its_new_ttl); @@ -2265,11 +2277,11 @@ std::chrono::milliseconds routing_manager_impl::update_routing_info(std::chrono: for (const auto &s : its_expired_offers) { for (const auto &i : s.second) { if (discovery_) { - discovery_->unsubscribe_all(s.first, i.first); + discovery_->unsubscribe_all(s.first, i); } - del_routing_info(s.first, i.first, i.second.first, i.second.second); + del_routing_info(s.first, i, true, true); VSOMEIP_INFO << "update_routing_info: elapsed=" << _elapsed.count() - << " : delete service/instance " << std::hex << s.first << "/" << i.first; + << " : delete service/instance " << std::hex << s.first << "/" << i; } } @@ -2277,9 +2289,7 @@ std::chrono::milliseconds routing_manager_impl::update_routing_info(std::chrono: } void routing_manager_impl::expire_services(const boost::asio::ip::address &_address) { - std::map > > its_expired_offers; + std::map > its_expired_offers; for (auto &s : get_services()) { for (auto &i : s.second) { @@ -2309,10 +2319,7 @@ void routing_manager_impl::expire_services(const boost::asio::ip::address &_addr if (is_gone) { if (discovery_) discovery_->unsubscribe_all(s.first, i.first); - its_expired_offers[s.first][i.first] = { - i.second->get_endpoint(true) != nullptr, - i.second->get_endpoint(false) != nullptr - }; + its_expired_offers[s.first].push_back(i.first); } } } @@ -2320,8 +2327,8 @@ void routing_manager_impl::expire_services(const boost::asio::ip::address &_addr for (auto &s : its_expired_offers) { for (auto &i : s.second) { VSOMEIP_INFO << "expire_services for address: " << _address.to_string() - << " : delete service/instance " << std::hex << s.first << "/" << i.first; - del_routing_info(s.first, i.first, i.second.first, i.second.second); + << " : delete service/instance " << std::hex << s.first << "/" << i; + del_routing_info(s.first, i, true, true); } } } @@ -3700,6 +3707,19 @@ void routing_manager_impl::set_routing_state(routing_state_e _routing_state) { } } } + // mark all external services as offline + services_t its_remote_services; + { + std::lock_guard its_lock(services_remote_mutex_); + its_remote_services = services_remote_; + } + for (const auto &s : its_remote_services) { + for (const auto &i : s.second) { + const bool has_reliable(i.second->get_endpoint(true)); + const bool has_unreliable(i.second->get_endpoint(false)); + del_routing_info(s.first, i.first, has_reliable, has_unreliable); + } + } break; } case vsomeip::routing_state_e::RS_RESUMED: diff --git a/implementation/service_discovery/src/service_discovery_impl.cpp b/implementation/service_discovery/src/service_discovery_impl.cpp index 9577526ee..7d5f23be1 100644 --- a/implementation/service_discovery/src/service_discovery_impl.cpp +++ b/implementation/service_discovery/src/service_discovery_impl.cpp @@ -145,7 +145,15 @@ void service_discovery_impl::start() { return; } } - + { + // make sure to sent out FindService messages after resume + std::lock_guard its_lock(requested_mutex_); + for (const auto &s : requested_) { + for (const auto &i : s.second) { + i.second->set_sent_counter(0); + } + } + } is_suspended_ = false; start_main_phase_timer(); start_offer_debounce_timer(true); diff --git a/implementation/utility/include/utility.hpp b/implementation/utility/include/utility.hpp index 40c697362..ac55fdbef 100644 --- a/implementation/utility/include/utility.hpp +++ b/implementation/utility/include/utility.hpp @@ -47,6 +47,22 @@ class utility { || _type == message_type_e::MT_REQUEST_NO_RETURN_ACK); } + static inline bool is_response(byte_t _type) { + return is_response(static_cast(_type)); + } + + static inline bool is_response(message_type_e _type) { + return _type == message_type_e::MT_RESPONSE; + } + + static inline bool is_error(byte_t _type) { + return is_error(static_cast(_type)); + } + + static inline bool is_error(message_type_e _type) { + return _type == message_type_e::MT_ERROR; + } + static inline bool is_event(byte_t _data) { return (0x80 & _data) > 0; }