Skip to content

Commit 5c43d51

Browse files
vsomeip 2.9.5
1 parent e47085c commit 5c43d51

File tree

11 files changed

+71
-24
lines changed

11 files changed

+71
-24
lines changed

CHANGES

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
Changes
22
=======
3+
4+
v2.9.5
5+
- Change magic cookie behaviour to only send a magic cookie every 10
6+
seconds instead of in front of every SOME/IP message
7+
- Fixed bug which prevented resubscription after resuming from
8+
suspended state
9+
310
v2.9.4
411
- Fixed deadlock on suspend to RAM / resume, triggered
512
by signal handler.

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ project (vsomeip)
88

99
set (VSOMEIP_MAJOR_VERSION 2)
1010
set (VSOMEIP_MINOR_VERSION 9)
11-
set (VSOMEIP_PATCH_VERSION 4)
11+
set (VSOMEIP_PATCH_VERSION 5)
1212
set (VSOMEIP_VERSION ${VSOMEIP_MAJOR_VERSION}.${VSOMEIP_MINOR_VERSION}.${VSOMEIP_PATCH_VERSION})
1313
set (PACKAGE_VERSION ${VSOMEIP_VERSION}) # Used in documentatin/doxygen.in
1414
set (CMAKE_VERBOSE_MAKEFILE off)

implementation/endpoints/include/tcp_client_endpoint_impl.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#define VSOMEIP_TCP_CLIENT_ENDPOINT_IMPL_HPP
88

99
#include <boost/asio/ip/tcp.hpp>
10+
#include <chrono>
1011

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

6263
const boost::asio::ip::address remote_address_;
6364
const std::uint16_t remote_port_;
65+
std::chrono::steady_clock::time_point last_cookie_sent_;
6466
};
6567

6668
} // namespace vsomeip

implementation/endpoints/include/tcp_server_endpoint_impl.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
#include <vsomeip/export.hpp>
1616
#include "server_endpoint_impl.hpp"
1717

18+
#include <chrono>
19+
1820
namespace vsomeip {
1921

2022
typedef server_endpoint_impl<
@@ -108,6 +110,7 @@ class tcp_server_endpoint_impl: public tcp_server_endpoint_base_impl {
108110
boost::asio::ip::address remote_address_;
109111
std::uint16_t remote_port_;
110112
std::atomic<bool> magic_cookies_enabled_;
113+
std::chrono::steady_clock::time_point last_cookie_sent_;
111114
};
112115

113116
std::mutex acceptor_mutex_;

implementation/endpoints/src/tcp_client_endpoint_impl.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ tcp_client_endpoint_impl::tcp_client_endpoint_impl(
3535
shrink_count_(0),
3636
buffer_shrink_threshold_(_buffer_shrink_threshold),
3737
remote_address_(_remote.address()),
38-
remote_port_(_remote.port()) {
38+
remote_port_(_remote.port()),
39+
last_cookie_sent_(std::chrono::steady_clock::now() - std::chrono::seconds(11)) {
3940
is_supporting_magic_cookies_ = true;
4041
}
4142

@@ -174,8 +175,16 @@ void tcp_client_endpoint_impl::send_queued() {
174175
return;
175176
}
176177

177-
if (has_enabled_magic_cookies_)
178-
send_magic_cookie(its_buffer);
178+
if (has_enabled_magic_cookies_) {
179+
const std::chrono::steady_clock::time_point now =
180+
std::chrono::steady_clock::now();
181+
if (std::chrono::duration_cast<std::chrono::milliseconds>(
182+
now - last_cookie_sent_) > std::chrono::milliseconds(10000)) {
183+
send_magic_cookie(its_buffer);
184+
last_cookie_sent_ = now;
185+
}
186+
}
187+
179188

180189
#if 0
181190
std::stringstream msg;

implementation/endpoints/src/tcp_server_endpoint_impl.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,8 @@ tcp_server_endpoint_impl::connection::connection(
213213
shrink_count_(0),
214214
buffer_shrink_threshold_(_buffer_shrink_threshold),
215215
remote_port_(0),
216-
magic_cookies_enabled_(_magic_cookies_enabled) {
216+
magic_cookies_enabled_(_magic_cookies_enabled),
217+
last_cookie_sent_(std::chrono::steady_clock::now() - std::chrono::seconds(11)) {
217218
}
218219

219220
tcp_server_endpoint_impl::connection::ptr
@@ -303,7 +304,13 @@ void tcp_server_endpoint_impl::connection::send_queued(
303304
}
304305
message_buffer_ptr_t its_buffer = _queue_iterator->second.front();
305306
if (magic_cookies_enabled_) {
306-
send_magic_cookie(its_buffer);
307+
const std::chrono::steady_clock::time_point now =
308+
std::chrono::steady_clock::now();
309+
if (std::chrono::duration_cast<std::chrono::milliseconds>(
310+
now - last_cookie_sent_) > std::chrono::milliseconds(10000)) {
311+
send_magic_cookie(its_buffer);
312+
last_cookie_sent_ = now;
313+
}
307314
}
308315

309316
{

implementation/routing/src/routing_manager_impl.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3692,21 +3692,6 @@ void routing_manager_impl::set_routing_state(routing_state_e _routing_state) {
36923692
}
36933693
}
36943694

3695-
// determine existing subscriptions to remote services and send StopSubscribe
3696-
for (auto &s : get_services()) {
3697-
for (auto &i : s.second) {
3698-
if (find_local_client(s.first, i.first) != VSOMEIP_ROUTING_CLIENT) {
3699-
continue; //don't expire local services
3700-
}
3701-
for (auto its_eventgroup : get_subscribed_eventgroups(s.first, i.first)) {
3702-
discovery_->unsubscribe(s.first, i.first, its_eventgroup, VSOMEIP_ROUTING_CLIENT);
3703-
auto specific_endpoint_clients = get_specific_endpoint_clients(s.first, i.first);
3704-
for (auto its_client : specific_endpoint_clients) {
3705-
discovery_->unsubscribe(s.first, i.first, its_eventgroup, its_client);
3706-
}
3707-
}
3708-
}
3709-
}
37103695
// mark all external services as offline
37113696
services_t its_remote_services;
37123697
{
@@ -3715,9 +3700,24 @@ void routing_manager_impl::set_routing_state(routing_state_e _routing_state) {
37153700
}
37163701
for (const auto &s : its_remote_services) {
37173702
for (const auto &i : s.second) {
3703+
// determine existing subscriptions to remote service and send StopSubscribe
3704+
for (auto its_eventgroup : get_subscribed_eventgroups(s.first, i.first)) {
3705+
discovery_->unsubscribe(s.first, i.first, its_eventgroup, VSOMEIP_ROUTING_CLIENT);
3706+
auto specific_endpoint_clients = get_specific_endpoint_clients(s.first, i.first);
3707+
for (auto its_client : specific_endpoint_clients) {
3708+
discovery_->unsubscribe(s.first, i.first, its_eventgroup, its_client);
3709+
}
3710+
for (const auto &e : find_events(s.first, i.first, its_eventgroup)) {
3711+
e->clear_subscribers();
3712+
}
3713+
}
3714+
37183715
const bool has_reliable(i.second->get_endpoint(true));
37193716
const bool has_unreliable(i.second->get_endpoint(false));
37203717
del_routing_info(s.first, i.first, has_reliable, has_unreliable);
3718+
3719+
// clear all cached payloads of remote services
3720+
unset_all_eventpayloads(s.first, i.first);
37213721
}
37223722
}
37233723
break;

implementation/service_discovery/src/service_discovery_impl.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,14 +145,19 @@ void service_discovery_impl::start() {
145145
return;
146146
}
147147
}
148-
{
148+
149+
if (is_suspended_) {
149150
// make sure to sent out FindService messages after resume
150151
std::lock_guard<std::mutex> its_lock(requested_mutex_);
151152
for (const auto &s : requested_) {
152153
for (const auto &i : s.second) {
153154
i.second->set_sent_counter(0);
154155
}
155156
}
157+
if (endpoint_) {
158+
// rejoin multicast group
159+
endpoint_->join(sd_multicast_);
160+
}
156161
}
157162
is_suspended_ = false;
158163
start_main_phase_timer();

test/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2089,7 +2089,7 @@ if(NOT ${TESTS_BAT})
20892089
add_test(NAME ${TEST_MAGIC_COOKIES_NAME}
20902090
COMMAND ${PROJECT_BINARY_DIR}/test/${TEST_MAGIC_COOKIES_STARTER}
20912091
)
2092-
set_tests_properties(${TEST_MAGIC_COOKIES_NAME} PROPERTIES TIMEOUT 120)
2092+
set_tests_properties(${TEST_MAGIC_COOKIES_NAME} PROPERTIES TIMEOUT 250)
20932093

20942094
# Header/Factory tets
20952095
add_test(NAME ${TEST_HEADER_FACTORY_NAME} COMMAND ${TEST_HEADER_FACTORY})

test/magic_cookies_tests/magic_cookies_test_client.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,32 +163,46 @@ class magic_cookies_test_client {
163163
// Test sequence
164164
its_good_payload_data[11] = 0x01;
165165
its_routing->send(0x1343, its_good_payload_data, sizeof(its_good_payload_data), vsomeip_test::TEST_SERVICE_INSTANCE_ID, true, true);
166+
std::this_thread::sleep_for(std::chrono::seconds(11));
166167
its_bad_payload_data[11] = 0x02;
167168
its_routing->send(0x1343, its_bad_payload_data, sizeof(its_bad_payload_data), vsomeip_test::TEST_SERVICE_INSTANCE_ID, true, true);
169+
std::this_thread::sleep_for(std::chrono::seconds(11));
168170
its_good_payload_data[11] = 0x03;
169171
its_routing->send(0x1343, its_good_payload_data, sizeof(its_good_payload_data), vsomeip_test::TEST_SERVICE_INSTANCE_ID, true, true);
172+
std::this_thread::sleep_for(std::chrono::seconds(11));
170173
its_bad_payload_data[11] = 0x04;
171174
its_routing->send(0x1343, its_bad_payload_data, sizeof(its_bad_payload_data), vsomeip_test::TEST_SERVICE_INSTANCE_ID, true, true);
175+
std::this_thread::sleep_for(std::chrono::seconds(11));
172176
its_bad_payload_data[11] = 0x05;
173177
its_routing->send(0x1343, its_bad_payload_data, sizeof(its_bad_payload_data), vsomeip_test::TEST_SERVICE_INSTANCE_ID, true, true);
178+
std::this_thread::sleep_for(std::chrono::seconds(11));
174179
its_good_payload_data[11] = 0x06;
175180
its_routing->send(0x1343, its_good_payload_data, sizeof(its_good_payload_data), vsomeip_test::TEST_SERVICE_INSTANCE_ID, true, true);
181+
std::this_thread::sleep_for(std::chrono::seconds(11));
176182
its_good_payload_data[11] = 0x07;
177183
its_routing->send(0x1343, its_good_payload_data, sizeof(its_good_payload_data), vsomeip_test::TEST_SERVICE_INSTANCE_ID, true, true);
184+
std::this_thread::sleep_for(std::chrono::seconds(11));
178185
its_bad_payload_data[11] = 0x08;
179186
its_routing->send(0x1343, its_bad_payload_data, sizeof(its_bad_payload_data), vsomeip_test::TEST_SERVICE_INSTANCE_ID, true, true);
187+
std::this_thread::sleep_for(std::chrono::seconds(11));
180188
its_bad_payload_data[11] = 0x09;
181189
its_routing->send(0x1343, its_bad_payload_data, sizeof(its_bad_payload_data), vsomeip_test::TEST_SERVICE_INSTANCE_ID, true, true);
190+
std::this_thread::sleep_for(std::chrono::seconds(11));
182191
its_bad_payload_data[11] = 0x0A;
183192
its_routing->send(0x1343, its_bad_payload_data, sizeof(its_bad_payload_data), vsomeip_test::TEST_SERVICE_INSTANCE_ID, true, true);
193+
std::this_thread::sleep_for(std::chrono::seconds(11));
184194
its_good_payload_data[11] = 0x0B;
185195
its_routing->send(0x1343, its_good_payload_data, sizeof(its_good_payload_data), vsomeip_test::TEST_SERVICE_INSTANCE_ID, true, true);
196+
std::this_thread::sleep_for(std::chrono::seconds(11));
186197
its_good_payload_data[11] = 0x0C;
187198
its_routing->send(0x1343, its_good_payload_data, sizeof(its_good_payload_data), vsomeip_test::TEST_SERVICE_INSTANCE_ID, true, true);
199+
std::this_thread::sleep_for(std::chrono::seconds(11));
188200
its_good_payload_data[11] = 0x0D;
189201
its_routing->send(0x1343, its_good_payload_data, sizeof(its_good_payload_data), vsomeip_test::TEST_SERVICE_INSTANCE_ID, true, true);
202+
std::this_thread::sleep_for(std::chrono::seconds(11));
190203
its_bad_payload_data[11] = 0x0E;
191204
its_routing->send(0x1343, its_bad_payload_data, sizeof(its_bad_payload_data), vsomeip_test::TEST_SERVICE_INSTANCE_ID, true, true);
205+
std::this_thread::sleep_for(std::chrono::seconds(11));
192206
its_good_payload_data[11] = 0x0F;
193207
its_routing->send(0x1343, its_good_payload_data, sizeof(its_good_payload_data), vsomeip_test::TEST_SERVICE_INSTANCE_ID, true, true);
194208

0 commit comments

Comments
 (0)