Skip to content

Commit 4808f31

Browse files
vsomeip 2.10.10
1 parent 325b472 commit 4808f31

File tree

6 files changed

+52
-34
lines changed

6 files changed

+52
-34
lines changed

CHANGES

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
Changes
22
=======
3+
v2.10.10
4+
- Fix concurrency issue leading to a crash
5+
36
v2.10.9
47
- Improve handling of service discovery messages with entries
58
referencing too many options.

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 10)
11-
set (VSOMEIP_PATCH_VERSION 9)
11+
set (VSOMEIP_PATCH_VERSION 10)
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/routing/src/routing_manager_impl.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1953,7 +1953,10 @@ std::shared_ptr<endpoint> routing_manager_impl::create_remote_client(
19531953
}
19541954

19551955
if (its_endpoint) {
1956-
used_client_ports_[_reliable].insert(its_local_port);
1956+
{
1957+
std::lock_guard<std::mutex> its_lock(used_client_ports_mutex_);
1958+
used_client_ports_[_reliable].insert(its_local_port);
1959+
}
19571960
service_instances_[_service][its_endpoint.get()] = _instance;
19581961
remote_services_[_service][_instance][_client][_reliable] = its_endpoint;
19591962
if (_client == VSOMEIP_ROUTING_CLIENT) {

test/offered_services_info_test/offered_services_info_test_client.cpp

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <map>
1313
#include <algorithm>
1414
#include <atomic>
15+
#include <future>
1516

1617
#include <gtest/gtest.h>
1718

@@ -76,13 +77,17 @@ class offered_services_info_test_client {
7677
std::bind(&offered_services_info_test_client::on_message, this,
7778
std::placeholders::_1));
7879

79-
app_->register_availability_handler(service_info_.service_id,
80-
service_info_.instance_id,
80+
app_->register_availability_handler(vsomeip::ANY_SERVICE,
81+
vsomeip::ANY_INSTANCE,
8182
std::bind(&offered_services_info_test_client::on_availability, this,
8283
std::placeholders::_1, std::placeholders::_2,
8384
std::placeholders::_3));
84-
app_->request_service(service_info_.service_id,
85-
service_info_.instance_id);
85+
// request all services
86+
app_->request_service(service_info_.service_id, service_info_.instance_id);
87+
app_->request_service(service_info_.service_id, vsomeip::instance_t(service_info_.instance_id + 1));
88+
app_->request_service(remote_service_info_.service_id, remote_service_info_.instance_id);
89+
app_->request_service(vsomeip::service_t(remote_service_info_.service_id + 1), vsomeip::instance_t(remote_service_info_.instance_id + 1));
90+
app_->request_service(vsomeip::service_t(remote_service_info_.service_id + 2), vsomeip::instance_t(remote_service_info_.instance_id + 2));
8691

8792
app_->start();
8893
}
@@ -109,10 +114,14 @@ class offered_services_info_test_client {
109114
VSOMEIP_INFO << "Service [" << std::setw(4)
110115
<< std::setfill('0') << std::hex << _service << "." << _instance
111116
<< "] is " << (_is_available ? "available":"not available") << ".";
117+
static int services_available =0;
112118
std::lock_guard<std::mutex> its_lock(mutex_);
113119
if(_is_available) {
114-
wait_until_service_available_ = false;
115-
condition_.notify_one();
120+
services_available++;
121+
if (services_available == 5) {
122+
wait_until_service_available_ = false;
123+
condition_.notify_one();
124+
}
116125
} else {
117126
wait_until_service_available_ = true;
118127
condition_.notify_one();
@@ -165,28 +174,16 @@ class offered_services_info_test_client {
165174
VSOMEIP_INFO << "TEST LOCAL SERVICES";
166175
app_->get_offered_services_async(vsomeip::offer_type_e::OT_LOCAL, std::bind(&offered_services_info_test_client::on_offered_services_local, this, std::placeholders::_1));
167176

168-
VSOMEIP_INFO << "TEST REMOTE SERVICES";
169-
app_->get_offered_services_async(vsomeip::offer_type_e::OT_REMOTE, std::bind(&offered_services_info_test_client::on_offered_services_remote, this, std::placeholders::_1));
170-
171-
VSOMEIP_INFO << "TEST ALL SERVICES";
172-
app_->get_offered_services_async(vsomeip::offer_type_e::OT_ALL, std::bind(&offered_services_info_test_client::on_offered_services_all, this, std::placeholders::_1));
173-
174-
175177
// send shutdown command to service
176-
bool send(false);
177-
{
178-
std::lock_guard<std::mutex> its_lock(mutex_);
179-
send = !wait_until_service_available_;
180-
}
181-
if (send) {
178+
if (std::future_status::timeout == all_callbacks_received_.get_future().wait_for(std::chrono::seconds(15))) {
179+
ADD_FAILURE() << "Didn't receive all callbacks within time";
180+
} else {
182181
std::shared_ptr<vsomeip::message> its_req = vsomeip::runtime::get()->create_request();
183182
its_req->set_service(service_info_.service_id);
184183
its_req->set_instance(service_info_.instance_id);
185184
its_req->set_method(service_info_.shutdown_method_id);
186185
app_->send(its_req);
187186
std::this_thread::sleep_for(std::chrono::milliseconds(100));
188-
} else {
189-
std::this_thread::sleep_for(std::chrono::milliseconds(50));
190187
}
191188

192189

@@ -201,6 +198,7 @@ class offered_services_info_test_client {
201198

202199
void on_offered_services_local( const std::vector<std::pair<vsomeip::service_t, vsomeip::instance_t>> &_services) {
203200
std::cout << "ON OFFERED SERVICES LOCAL CALLBACK START" << std::endl;
201+
EXPECT_EQ(2u, _services.size());
204202
bool local_service_test_failed(true);
205203
for (auto its_pair : _services) {
206204
local_service_test_failed = true;
@@ -215,10 +213,13 @@ class offered_services_info_test_client {
215213
EXPECT_FALSE(local_service_test_failed);
216214
}
217215
std::cout << "ON OFFERED SERVICES LOCAL CALLBACK END" << std::endl;
216+
VSOMEIP_INFO << "TEST REMOTE SERVICES";
217+
app_->get_offered_services_async(vsomeip::offer_type_e::OT_REMOTE, std::bind(&offered_services_info_test_client::on_offered_services_remote, this, std::placeholders::_1));
218218
}
219219

220220
void on_offered_services_remote( const std::vector<std::pair<vsomeip::service_t, vsomeip::instance_t>> &_services) {
221221
std::cout << "ON OFFERED SERVICES REMOTE CALLBACK START" << std::endl;
222+
EXPECT_EQ(3u, _services.size());
222223
bool remote_service_test_failed(true);
223224
for (auto its_pair : _services) {
224225
remote_service_test_failed = true;
@@ -233,10 +234,13 @@ class offered_services_info_test_client {
233234
EXPECT_FALSE(remote_service_test_failed);
234235
}
235236
std::cout << "ON OFFERED SERVICES REMOTE CALLBACK END" << std::endl;
237+
VSOMEIP_INFO << "TEST ALL SERVICES";
238+
app_->get_offered_services_async(vsomeip::offer_type_e::OT_ALL, std::bind(&offered_services_info_test_client::on_offered_services_all, this, std::placeholders::_1));
236239
}
237240

238241
void on_offered_services_all( const std::vector<std::pair<vsomeip::service_t, vsomeip::instance_t>> &_services) {
239242
std::cout << "ON OFFERED SERVICES ALL CALLBACK START" << std::endl;
243+
EXPECT_EQ(5u, _services.size());
240244
bool all_service_test_failed(true);
241245
for (auto its_pair : _services) {
242246
all_service_test_failed = true;
@@ -251,6 +255,7 @@ class offered_services_info_test_client {
251255
EXPECT_FALSE(all_service_test_failed);
252256
}
253257
std::cout << "ON OFFERED SERVICES ALL CALLBACK END" << std::endl;
258+
all_callbacks_received_.set_value();
254259
}
255260

256261
void wait_for_stop() {
@@ -282,6 +287,7 @@ class offered_services_info_test_client {
282287
std::uint32_t last_received_counter_;
283288
std::chrono::steady_clock::time_point last_received_response_;
284289
std::atomic<std::uint32_t> number_received_responses_;
290+
std::promise<void> all_callbacks_received_;
285291
std::thread stop_thread_;
286292
std::thread test_offered_services_thread_;
287293
};

test/offered_services_info_test/offered_services_info_test_local.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"diagnosis":"0x12",
44
"logging" :
55
{
6-
"level" : "debug",
6+
"level" : "warning",
77
"console" : "true",
88
"file" :
99
{

test/offered_services_info_test/offered_services_info_test_service.cpp

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <map>
1313
#include <algorithm>
1414
#include <atomic>
15+
#include <future>
1516

1617
#include <gtest/gtest.h>
1718

@@ -138,14 +139,9 @@ class offer_test_service {
138139
VSOMEIP_INFO << "TEST LOCAL SERVICES";
139140
app_->get_offered_services_async(vsomeip::offer_type_e::OT_LOCAL, std::bind(&offer_test_service::on_offered_services_local, this, std::placeholders::_1));
140141

141-
VSOMEIP_INFO << "TEST REMOTE SERVICES";
142-
app_->get_offered_services_async(vsomeip::offer_type_e::OT_REMOTE, std::bind(&offer_test_service::on_offered_services_remote, this, std::placeholders::_1));
143-
144-
VSOMEIP_INFO << "TEST ALL SERVICES";
145-
app_->get_offered_services_async(vsomeip::offer_type_e::OT_ALL, std::bind(&offer_test_service::on_offered_services_all, this, std::placeholders::_1));
146-
147-
VSOMEIP_DEBUG << "[" << std::setw(4) << std::setfill('0') << std::hex
148-
<< service_info_.service_id << "] Notifying";
142+
if (std::future_status::timeout == all_callbacks_received_.get_future().wait_for(std::chrono::seconds(15))) {
143+
ADD_FAILURE() << "Didn't receive all callbacks within time";
144+
}
149145

150146
while(!shutdown_method_called_) {
151147
std::this_thread::sleep_for(std::chrono::milliseconds(10));
@@ -155,6 +151,7 @@ class offer_test_service {
155151

156152
void on_offered_services_local( const std::vector<std::pair<vsomeip::service_t, vsomeip::instance_t>> &_services) {
157153
std::cout << "ON OFFERED SERVICES LOCAL CALLBACK START" << std::endl;
154+
EXPECT_EQ(2u, _services.size());
158155
bool local_service_test_failed(true);
159156
uint16_t i=0;
160157
for (auto its_pair : _services) {
@@ -173,11 +170,15 @@ class offer_test_service {
173170
EXPECT_EQ(offer_test::num_local_offered_services, i);
174171

175172
std::cout << "ON OFFERED SERVICES LOCAL CALLBACK END" << std::endl;
173+
174+
VSOMEIP_INFO << "TEST REMOTE SERVICES";
175+
app_->get_offered_services_async(vsomeip::offer_type_e::OT_REMOTE, std::bind(&offer_test_service::on_offered_services_remote, this, std::placeholders::_1));
176176
}
177177

178178

179179
void on_offered_services_remote( const std::vector<std::pair<vsomeip::service_t, vsomeip::instance_t>> &_services) {
180180
std::cout << "ON OFFERED SERVICES REMOTE CALLBACK START" << std::endl;
181+
EXPECT_EQ(3u, _services.size());
181182
bool remote_service_test_failed(true);
182183
uint16_t i=0;
183184
for (auto its_pair : _services) {
@@ -196,12 +197,15 @@ class offer_test_service {
196197
EXPECT_EQ(offer_test::num_remote_offered_services, i);
197198

198199
std::cout << "ON OFFERED SERVICES REMOTE CALLBACK END" << std::endl;
200+
201+
VSOMEIP_INFO << "TEST ALL SERVICES";
202+
app_->get_offered_services_async(vsomeip::offer_type_e::OT_ALL, std::bind(&offer_test_service::on_offered_services_all, this, std::placeholders::_1));
199203
}
200204

201205

202206
void on_offered_services_all( const std::vector<std::pair<vsomeip::service_t, vsomeip::instance_t>> &_services) {
203-
204207
std::cout << "ON OFFERED SERVICES ALL CALLBACK START" << std::endl;
208+
EXPECT_EQ(5u, _services.size());
205209
bool all_service_test_failed(true);
206210
uint16_t i=0;
207211
for (auto its_pair : _services) {
@@ -219,6 +223,7 @@ class offer_test_service {
219223
}
220224
EXPECT_EQ(offer_test::num_all_offered_services, i);
221225
std::cout << "ON OFFERED SERVICES ALL CALLBACK END" << std::endl;
226+
all_callbacks_received_.set_value();
222227
}
223228

224229
private:
@@ -231,10 +236,11 @@ class offer_test_service {
231236
std::mutex mutex_;
232237
std::condition_variable condition_;
233238
std::atomic<bool> shutdown_method_called_;
239+
std::promise<void> all_callbacks_received_;
234240
std::thread offer_thread_;
235241
};
236242

237-
TEST(someip_offer_test, notify_increasing_counter)
243+
TEST(someip_offered_services_info_test, check_offered_services_as_rm_impl)
238244
{
239245
offer_test_service its_sample(offer_test::service, offer_test::remote_service);
240246
}

0 commit comments

Comments
 (0)