Skip to content

Commit

Permalink
vsomeip 2.9.5
Browse files Browse the repository at this point in the history
  • Loading branch information
juergengehring committed Jan 25, 2018
1 parent e47085c commit 5c43d51
Show file tree
Hide file tree
Showing 11 changed files with 71 additions and 24 deletions.
7 changes: 7 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
Changes
=======

v2.9.5
- Change magic cookie behaviour to only send a magic cookie every 10
seconds instead of in front of every SOME/IP message
- Fixed bug which prevented resubscription after resuming from
suspended state

v2.9.4
- Fixed deadlock on suspend to RAM / resume, triggered
by signal handler.
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 4)
set (VSOMEIP_PATCH_VERSION 5)
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
2 changes: 2 additions & 0 deletions implementation/endpoints/include/tcp_client_endpoint_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#define VSOMEIP_TCP_CLIENT_ENDPOINT_IMPL_HPP

#include <boost/asio/ip/tcp.hpp>
#include <chrono>

#include <vsomeip/defines.hpp>
#include "client_endpoint_impl.hpp"
Expand Down Expand Up @@ -61,6 +62,7 @@ class tcp_client_endpoint_impl: public tcp_client_endpoint_base_impl {

const boost::asio::ip::address remote_address_;
const std::uint16_t remote_port_;
std::chrono::steady_clock::time_point last_cookie_sent_;
};

} // namespace vsomeip
Expand Down
3 changes: 3 additions & 0 deletions implementation/endpoints/include/tcp_server_endpoint_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#include <vsomeip/export.hpp>
#include "server_endpoint_impl.hpp"

#include <chrono>

namespace vsomeip {

typedef server_endpoint_impl<
Expand Down Expand Up @@ -108,6 +110,7 @@ class tcp_server_endpoint_impl: public tcp_server_endpoint_base_impl {
boost::asio::ip::address remote_address_;
std::uint16_t remote_port_;
std::atomic<bool> magic_cookies_enabled_;
std::chrono::steady_clock::time_point last_cookie_sent_;
};

std::mutex acceptor_mutex_;
Expand Down
15 changes: 12 additions & 3 deletions implementation/endpoints/src/tcp_client_endpoint_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ tcp_client_endpoint_impl::tcp_client_endpoint_impl(
shrink_count_(0),
buffer_shrink_threshold_(_buffer_shrink_threshold),
remote_address_(_remote.address()),
remote_port_(_remote.port()) {
remote_port_(_remote.port()),
last_cookie_sent_(std::chrono::steady_clock::now() - std::chrono::seconds(11)) {
is_supporting_magic_cookies_ = true;
}

Expand Down Expand Up @@ -174,8 +175,16 @@ void tcp_client_endpoint_impl::send_queued() {
return;
}

if (has_enabled_magic_cookies_)
send_magic_cookie(its_buffer);
if (has_enabled_magic_cookies_) {
const std::chrono::steady_clock::time_point now =
std::chrono::steady_clock::now();
if (std::chrono::duration_cast<std::chrono::milliseconds>(
now - last_cookie_sent_) > std::chrono::milliseconds(10000)) {
send_magic_cookie(its_buffer);
last_cookie_sent_ = now;
}
}


#if 0
std::stringstream msg;
Expand Down
11 changes: 9 additions & 2 deletions implementation/endpoints/src/tcp_server_endpoint_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,8 @@ tcp_server_endpoint_impl::connection::connection(
shrink_count_(0),
buffer_shrink_threshold_(_buffer_shrink_threshold),
remote_port_(0),
magic_cookies_enabled_(_magic_cookies_enabled) {
magic_cookies_enabled_(_magic_cookies_enabled),
last_cookie_sent_(std::chrono::steady_clock::now() - std::chrono::seconds(11)) {
}

tcp_server_endpoint_impl::connection::ptr
Expand Down Expand Up @@ -303,7 +304,13 @@ void tcp_server_endpoint_impl::connection::send_queued(
}
message_buffer_ptr_t its_buffer = _queue_iterator->second.front();
if (magic_cookies_enabled_) {
send_magic_cookie(its_buffer);
const std::chrono::steady_clock::time_point now =
std::chrono::steady_clock::now();
if (std::chrono::duration_cast<std::chrono::milliseconds>(
now - last_cookie_sent_) > std::chrono::milliseconds(10000)) {
send_magic_cookie(its_buffer);
last_cookie_sent_ = now;
}
}

{
Expand Down
30 changes: 15 additions & 15 deletions implementation/routing/src/routing_manager_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3692,21 +3692,6 @@ void routing_manager_impl::set_routing_state(routing_state_e _routing_state) {
}
}

// determine existing subscriptions to remote services and send StopSubscribe
for (auto &s : get_services()) {
for (auto &i : s.second) {
if (find_local_client(s.first, i.first) != VSOMEIP_ROUTING_CLIENT) {
continue; //don't expire local services
}
for (auto its_eventgroup : get_subscribed_eventgroups(s.first, i.first)) {
discovery_->unsubscribe(s.first, i.first, its_eventgroup, VSOMEIP_ROUTING_CLIENT);
auto specific_endpoint_clients = get_specific_endpoint_clients(s.first, i.first);
for (auto its_client : specific_endpoint_clients) {
discovery_->unsubscribe(s.first, i.first, its_eventgroup, its_client);
}
}
}
}
// mark all external services as offline
services_t its_remote_services;
{
Expand All @@ -3715,9 +3700,24 @@ void routing_manager_impl::set_routing_state(routing_state_e _routing_state) {
}
for (const auto &s : its_remote_services) {
for (const auto &i : s.second) {
// determine existing subscriptions to remote service and send StopSubscribe
for (auto its_eventgroup : get_subscribed_eventgroups(s.first, i.first)) {
discovery_->unsubscribe(s.first, i.first, its_eventgroup, VSOMEIP_ROUTING_CLIENT);
auto specific_endpoint_clients = get_specific_endpoint_clients(s.first, i.first);
for (auto its_client : specific_endpoint_clients) {
discovery_->unsubscribe(s.first, i.first, its_eventgroup, its_client);
}
for (const auto &e : find_events(s.first, i.first, its_eventgroup)) {
e->clear_subscribers();
}
}

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);

// clear all cached payloads of remote services
unset_all_eventpayloads(s.first, i.first);
}
}
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,14 +145,19 @@ void service_discovery_impl::start() {
return;
}
}
{

if (is_suspended_) {
// 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);
}
}
if (endpoint_) {
// rejoin multicast group
endpoint_->join(sd_multicast_);
}
}
is_suspended_ = false;
start_main_phase_timer();
Expand Down
2 changes: 1 addition & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2089,7 +2089,7 @@ if(NOT ${TESTS_BAT})
add_test(NAME ${TEST_MAGIC_COOKIES_NAME}
COMMAND ${PROJECT_BINARY_DIR}/test/${TEST_MAGIC_COOKIES_STARTER}
)
set_tests_properties(${TEST_MAGIC_COOKIES_NAME} PROPERTIES TIMEOUT 120)
set_tests_properties(${TEST_MAGIC_COOKIES_NAME} PROPERTIES TIMEOUT 250)

# Header/Factory tets
add_test(NAME ${TEST_HEADER_FACTORY_NAME} COMMAND ${TEST_HEADER_FACTORY})
Expand Down
14 changes: 14 additions & 0 deletions test/magic_cookies_tests/magic_cookies_test_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,32 +163,46 @@ class magic_cookies_test_client {
// Test sequence
its_good_payload_data[11] = 0x01;
its_routing->send(0x1343, its_good_payload_data, sizeof(its_good_payload_data), vsomeip_test::TEST_SERVICE_INSTANCE_ID, true, true);
std::this_thread::sleep_for(std::chrono::seconds(11));
its_bad_payload_data[11] = 0x02;
its_routing->send(0x1343, its_bad_payload_data, sizeof(its_bad_payload_data), vsomeip_test::TEST_SERVICE_INSTANCE_ID, true, true);
std::this_thread::sleep_for(std::chrono::seconds(11));
its_good_payload_data[11] = 0x03;
its_routing->send(0x1343, its_good_payload_data, sizeof(its_good_payload_data), vsomeip_test::TEST_SERVICE_INSTANCE_ID, true, true);
std::this_thread::sleep_for(std::chrono::seconds(11));
its_bad_payload_data[11] = 0x04;
its_routing->send(0x1343, its_bad_payload_data, sizeof(its_bad_payload_data), vsomeip_test::TEST_SERVICE_INSTANCE_ID, true, true);
std::this_thread::sleep_for(std::chrono::seconds(11));
its_bad_payload_data[11] = 0x05;
its_routing->send(0x1343, its_bad_payload_data, sizeof(its_bad_payload_data), vsomeip_test::TEST_SERVICE_INSTANCE_ID, true, true);
std::this_thread::sleep_for(std::chrono::seconds(11));
its_good_payload_data[11] = 0x06;
its_routing->send(0x1343, its_good_payload_data, sizeof(its_good_payload_data), vsomeip_test::TEST_SERVICE_INSTANCE_ID, true, true);
std::this_thread::sleep_for(std::chrono::seconds(11));
its_good_payload_data[11] = 0x07;
its_routing->send(0x1343, its_good_payload_data, sizeof(its_good_payload_data), vsomeip_test::TEST_SERVICE_INSTANCE_ID, true, true);
std::this_thread::sleep_for(std::chrono::seconds(11));
its_bad_payload_data[11] = 0x08;
its_routing->send(0x1343, its_bad_payload_data, sizeof(its_bad_payload_data), vsomeip_test::TEST_SERVICE_INSTANCE_ID, true, true);
std::this_thread::sleep_for(std::chrono::seconds(11));
its_bad_payload_data[11] = 0x09;
its_routing->send(0x1343, its_bad_payload_data, sizeof(its_bad_payload_data), vsomeip_test::TEST_SERVICE_INSTANCE_ID, true, true);
std::this_thread::sleep_for(std::chrono::seconds(11));
its_bad_payload_data[11] = 0x0A;
its_routing->send(0x1343, its_bad_payload_data, sizeof(its_bad_payload_data), vsomeip_test::TEST_SERVICE_INSTANCE_ID, true, true);
std::this_thread::sleep_for(std::chrono::seconds(11));
its_good_payload_data[11] = 0x0B;
its_routing->send(0x1343, its_good_payload_data, sizeof(its_good_payload_data), vsomeip_test::TEST_SERVICE_INSTANCE_ID, true, true);
std::this_thread::sleep_for(std::chrono::seconds(11));
its_good_payload_data[11] = 0x0C;
its_routing->send(0x1343, its_good_payload_data, sizeof(its_good_payload_data), vsomeip_test::TEST_SERVICE_INSTANCE_ID, true, true);
std::this_thread::sleep_for(std::chrono::seconds(11));
its_good_payload_data[11] = 0x0D;
its_routing->send(0x1343, its_good_payload_data, sizeof(its_good_payload_data), vsomeip_test::TEST_SERVICE_INSTANCE_ID, true, true);
std::this_thread::sleep_for(std::chrono::seconds(11));
its_bad_payload_data[11] = 0x0E;
its_routing->send(0x1343, its_bad_payload_data, sizeof(its_bad_payload_data), vsomeip_test::TEST_SERVICE_INSTANCE_ID, true, true);
std::this_thread::sleep_for(std::chrono::seconds(11));
its_good_payload_data[11] = 0x0F;
its_routing->send(0x1343, its_good_payload_data, sizeof(its_good_payload_data), vsomeip_test::TEST_SERVICE_INSTANCE_ID, true, true);

Expand Down
2 changes: 1 addition & 1 deletion test/magic_cookies_tests/magic_cookies_test_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class magic_cookies_test_service {
offer();
while (!blocked_) {
if(std::cv_status::timeout ==
condition_.wait_for(its_lock, std::chrono::seconds(55))) {
condition_.wait_for(its_lock, std::chrono::seconds(200))) {
GTEST_NONFATAL_FAILURE_("Didn't receive all requests within time");
break;
}
Expand Down

0 comments on commit 5c43d51

Please sign in to comment.