Skip to content

Commit

Permalink
vsomeip 2.9.2
Browse files Browse the repository at this point in the history
  • Loading branch information
juergengehring committed Jan 25, 2018
1 parent 6cf4dc4 commit d61c5b0
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 21 deletions.
9 changes: 9 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
58 changes: 39 additions & 19 deletions implementation/routing/src/routing_manager_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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<std::chrono::milliseconds>(default_ttl);
std::map<service_t,
std::map<instance_t,
std::pair<bool, bool> > > its_expired_offers;
std::map<service_t, std::vector<instance_t> > its_expired_offers;

{
std::lock_guard<std::mutex> its_lock(services_remote_mutex_);
Expand All @@ -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);
Expand All @@ -2265,21 +2277,19 @@ 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;
}
}

return its_smallest_ttl;
}

void routing_manager_impl::expire_services(const boost::asio::ip::address &_address) {
std::map<service_t,
std::map<instance_t,
std::pair<bool, bool> > > its_expired_offers;
std::map<service_t, std::vector<instance_t> > its_expired_offers;

for (auto &s : get_services()) {
for (auto &i : s.second) {
Expand Down Expand Up @@ -2309,19 +2319,16 @@ 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);
}
}
}

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);
}
}
}
Expand Down Expand Up @@ -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<std::mutex> 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:
Expand Down
10 changes: 9 additions & 1 deletion implementation/service_discovery/src/service_discovery_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,15 @@ void service_discovery_impl::start() {
return;
}
}

{
// make sure to sent out FindService messages after resume
std::lock_guard<std::mutex> 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);
Expand Down
16 changes: 16 additions & 0 deletions implementation/utility/include/utility.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<message_type_e>(_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<message_type_e>(_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;
}
Expand Down

0 comments on commit d61c5b0

Please sign in to comment.