summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuergen Gehring <juergen.gehring@bmw.de>2018-01-25 00:40:10 -0800
committerJuergen Gehring <juergen.gehring@bmw.de>2018-01-25 00:40:10 -0800
commit4808f3130c97cea3f0168005b9df029282060539 (patch)
tree36a04d2d6078582c69ca11d1b5df6d665bfe27de
parent325b4724c9622bb7f8b1f3315a227dde867c70f1 (diff)
downloadvSomeIP-4808f3130c97cea3f0168005b9df029282060539.tar.gz
vsomeip 2.10.102.10.10
-rw-r--r--CHANGES3
-rw-r--r--CMakeLists.txt2
-rw-r--r--implementation/routing/src/routing_manager_impl.cpp5
-rw-r--r--test/offered_services_info_test/offered_services_info_test_client.cpp48
-rw-r--r--test/offered_services_info_test/offered_services_info_test_local.json2
-rw-r--r--test/offered_services_info_test/offered_services_info_test_service.cpp26
6 files changed, 52 insertions, 34 deletions
diff --git a/CHANGES b/CHANGES
index 65d6d86..26f1445 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,5 +1,8 @@
Changes
=======
+v2.10.10
+- Fix concurrency issue leading to a crash
+
v2.10.9
- Improve handling of service discovery messages with entries
referencing too many options.
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a9d9f4c..39d64af 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -8,7 +8,7 @@ project (vsomeip)
set (VSOMEIP_MAJOR_VERSION 2)
set (VSOMEIP_MINOR_VERSION 10)
-set (VSOMEIP_PATCH_VERSION 9)
+set (VSOMEIP_PATCH_VERSION 10)
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 5442134..e317e6d 100644
--- a/implementation/routing/src/routing_manager_impl.cpp
+++ b/implementation/routing/src/routing_manager_impl.cpp
@@ -1953,7 +1953,10 @@ std::shared_ptr<endpoint> routing_manager_impl::create_remote_client(
}
if (its_endpoint) {
- used_client_ports_[_reliable].insert(its_local_port);
+ {
+ std::lock_guard<std::mutex> its_lock(used_client_ports_mutex_);
+ used_client_ports_[_reliable].insert(its_local_port);
+ }
service_instances_[_service][its_endpoint.get()] = _instance;
remote_services_[_service][_instance][_client][_reliable] = its_endpoint;
if (_client == VSOMEIP_ROUTING_CLIENT) {
diff --git a/test/offered_services_info_test/offered_services_info_test_client.cpp b/test/offered_services_info_test/offered_services_info_test_client.cpp
index 13adc58..1aa0802 100644
--- a/test/offered_services_info_test/offered_services_info_test_client.cpp
+++ b/test/offered_services_info_test/offered_services_info_test_client.cpp
@@ -12,6 +12,7 @@
#include <map>
#include <algorithm>
#include <atomic>
+#include <future>
#include <gtest/gtest.h>
@@ -76,13 +77,17 @@ public:
std::bind(&offered_services_info_test_client::on_message, this,
std::placeholders::_1));
- app_->register_availability_handler(service_info_.service_id,
- service_info_.instance_id,
+ app_->register_availability_handler(vsomeip::ANY_SERVICE,
+ vsomeip::ANY_INSTANCE,
std::bind(&offered_services_info_test_client::on_availability, this,
std::placeholders::_1, std::placeholders::_2,
std::placeholders::_3));
- app_->request_service(service_info_.service_id,
- service_info_.instance_id);
+ // request all services
+ app_->request_service(service_info_.service_id, service_info_.instance_id);
+ app_->request_service(service_info_.service_id, vsomeip::instance_t(service_info_.instance_id + 1));
+ app_->request_service(remote_service_info_.service_id, remote_service_info_.instance_id);
+ app_->request_service(vsomeip::service_t(remote_service_info_.service_id + 1), vsomeip::instance_t(remote_service_info_.instance_id + 1));
+ app_->request_service(vsomeip::service_t(remote_service_info_.service_id + 2), vsomeip::instance_t(remote_service_info_.instance_id + 2));
app_->start();
}
@@ -109,10 +114,14 @@ public:
VSOMEIP_INFO << "Service [" << std::setw(4)
<< std::setfill('0') << std::hex << _service << "." << _instance
<< "] is " << (_is_available ? "available":"not available") << ".";
+ static int services_available =0;
std::lock_guard<std::mutex> its_lock(mutex_);
if(_is_available) {
- wait_until_service_available_ = false;
- condition_.notify_one();
+ services_available++;
+ if (services_available == 5) {
+ wait_until_service_available_ = false;
+ condition_.notify_one();
+ }
} else {
wait_until_service_available_ = true;
condition_.notify_one();
@@ -165,28 +174,16 @@ public:
VSOMEIP_INFO << "TEST LOCAL SERVICES";
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));
- VSOMEIP_INFO << "TEST REMOTE SERVICES";
- 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));
-
- VSOMEIP_INFO << "TEST ALL SERVICES";
- 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));
-
-
// send shutdown command to service
- bool send(false);
- {
- std::lock_guard<std::mutex> its_lock(mutex_);
- send = !wait_until_service_available_;
- }
- if (send) {
+ if (std::future_status::timeout == all_callbacks_received_.get_future().wait_for(std::chrono::seconds(15))) {
+ ADD_FAILURE() << "Didn't receive all callbacks within time";
+ } else {
std::shared_ptr<vsomeip::message> its_req = vsomeip::runtime::get()->create_request();
its_req->set_service(service_info_.service_id);
its_req->set_instance(service_info_.instance_id);
its_req->set_method(service_info_.shutdown_method_id);
app_->send(its_req);
std::this_thread::sleep_for(std::chrono::milliseconds(100));
- } else {
- std::this_thread::sleep_for(std::chrono::milliseconds(50));
}
@@ -201,6 +198,7 @@ public:
void on_offered_services_local( const std::vector<std::pair<vsomeip::service_t, vsomeip::instance_t>> &_services) {
std::cout << "ON OFFERED SERVICES LOCAL CALLBACK START" << std::endl;
+ EXPECT_EQ(2u, _services.size());
bool local_service_test_failed(true);
for (auto its_pair : _services) {
local_service_test_failed = true;
@@ -215,10 +213,13 @@ public:
EXPECT_FALSE(local_service_test_failed);
}
std::cout << "ON OFFERED SERVICES LOCAL CALLBACK END" << std::endl;
+ VSOMEIP_INFO << "TEST REMOTE SERVICES";
+ 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));
}
void on_offered_services_remote( const std::vector<std::pair<vsomeip::service_t, vsomeip::instance_t>> &_services) {
std::cout << "ON OFFERED SERVICES REMOTE CALLBACK START" << std::endl;
+ EXPECT_EQ(3u, _services.size());
bool remote_service_test_failed(true);
for (auto its_pair : _services) {
remote_service_test_failed = true;
@@ -233,10 +234,13 @@ public:
EXPECT_FALSE(remote_service_test_failed);
}
std::cout << "ON OFFERED SERVICES REMOTE CALLBACK END" << std::endl;
+ VSOMEIP_INFO << "TEST ALL SERVICES";
+ 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));
}
void on_offered_services_all( const std::vector<std::pair<vsomeip::service_t, vsomeip::instance_t>> &_services) {
std::cout << "ON OFFERED SERVICES ALL CALLBACK START" << std::endl;
+ EXPECT_EQ(5u, _services.size());
bool all_service_test_failed(true);
for (auto its_pair : _services) {
all_service_test_failed = true;
@@ -251,6 +255,7 @@ public:
EXPECT_FALSE(all_service_test_failed);
}
std::cout << "ON OFFERED SERVICES ALL CALLBACK END" << std::endl;
+ all_callbacks_received_.set_value();
}
void wait_for_stop() {
@@ -282,6 +287,7 @@ private:
std::uint32_t last_received_counter_;
std::chrono::steady_clock::time_point last_received_response_;
std::atomic<std::uint32_t> number_received_responses_;
+ std::promise<void> all_callbacks_received_;
std::thread stop_thread_;
std::thread test_offered_services_thread_;
};
diff --git a/test/offered_services_info_test/offered_services_info_test_local.json b/test/offered_services_info_test/offered_services_info_test_local.json
index 768a7ca..cb7db92 100644
--- a/test/offered_services_info_test/offered_services_info_test_local.json
+++ b/test/offered_services_info_test/offered_services_info_test_local.json
@@ -3,7 +3,7 @@
"diagnosis":"0x12",
"logging" :
{
- "level" : "debug",
+ "level" : "warning",
"console" : "true",
"file" :
{
diff --git a/test/offered_services_info_test/offered_services_info_test_service.cpp b/test/offered_services_info_test/offered_services_info_test_service.cpp
index 0476f30..d9a7ae4 100644
--- a/test/offered_services_info_test/offered_services_info_test_service.cpp
+++ b/test/offered_services_info_test/offered_services_info_test_service.cpp
@@ -12,6 +12,7 @@
#include <map>
#include <algorithm>
#include <atomic>
+#include <future>
#include <gtest/gtest.h>
@@ -138,14 +139,9 @@ public:
VSOMEIP_INFO << "TEST LOCAL SERVICES";
app_->get_offered_services_async(vsomeip::offer_type_e::OT_LOCAL, std::bind(&offer_test_service::on_offered_services_local, this, std::placeholders::_1));
- VSOMEIP_INFO << "TEST REMOTE SERVICES";
- app_->get_offered_services_async(vsomeip::offer_type_e::OT_REMOTE, std::bind(&offer_test_service::on_offered_services_remote, this, std::placeholders::_1));
-
- VSOMEIP_INFO << "TEST ALL SERVICES";
- app_->get_offered_services_async(vsomeip::offer_type_e::OT_ALL, std::bind(&offer_test_service::on_offered_services_all, this, std::placeholders::_1));
-
- VSOMEIP_DEBUG << "[" << std::setw(4) << std::setfill('0') << std::hex
- << service_info_.service_id << "] Notifying";
+ if (std::future_status::timeout == all_callbacks_received_.get_future().wait_for(std::chrono::seconds(15))) {
+ ADD_FAILURE() << "Didn't receive all callbacks within time";
+ }
while(!shutdown_method_called_) {
std::this_thread::sleep_for(std::chrono::milliseconds(10));
@@ -155,6 +151,7 @@ public:
void on_offered_services_local( const std::vector<std::pair<vsomeip::service_t, vsomeip::instance_t>> &_services) {
std::cout << "ON OFFERED SERVICES LOCAL CALLBACK START" << std::endl;
+ EXPECT_EQ(2u, _services.size());
bool local_service_test_failed(true);
uint16_t i=0;
for (auto its_pair : _services) {
@@ -173,11 +170,15 @@ public:
EXPECT_EQ(offer_test::num_local_offered_services, i);
std::cout << "ON OFFERED SERVICES LOCAL CALLBACK END" << std::endl;
+
+ VSOMEIP_INFO << "TEST REMOTE SERVICES";
+ app_->get_offered_services_async(vsomeip::offer_type_e::OT_REMOTE, std::bind(&offer_test_service::on_offered_services_remote, this, std::placeholders::_1));
}
void on_offered_services_remote( const std::vector<std::pair<vsomeip::service_t, vsomeip::instance_t>> &_services) {
std::cout << "ON OFFERED SERVICES REMOTE CALLBACK START" << std::endl;
+ EXPECT_EQ(3u, _services.size());
bool remote_service_test_failed(true);
uint16_t i=0;
for (auto its_pair : _services) {
@@ -196,12 +197,15 @@ public:
EXPECT_EQ(offer_test::num_remote_offered_services, i);
std::cout << "ON OFFERED SERVICES REMOTE CALLBACK END" << std::endl;
+
+ VSOMEIP_INFO << "TEST ALL SERVICES";
+ app_->get_offered_services_async(vsomeip::offer_type_e::OT_ALL, std::bind(&offer_test_service::on_offered_services_all, this, std::placeholders::_1));
}
void on_offered_services_all( const std::vector<std::pair<vsomeip::service_t, vsomeip::instance_t>> &_services) {
-
std::cout << "ON OFFERED SERVICES ALL CALLBACK START" << std::endl;
+ EXPECT_EQ(5u, _services.size());
bool all_service_test_failed(true);
uint16_t i=0;
for (auto its_pair : _services) {
@@ -219,6 +223,7 @@ public:
}
EXPECT_EQ(offer_test::num_all_offered_services, i);
std::cout << "ON OFFERED SERVICES ALL CALLBACK END" << std::endl;
+ all_callbacks_received_.set_value();
}
private:
@@ -231,10 +236,11 @@ private:
std::mutex mutex_;
std::condition_variable condition_;
std::atomic<bool> shutdown_method_called_;
+ std::promise<void> all_callbacks_received_;
std::thread offer_thread_;
};
-TEST(someip_offer_test, notify_increasing_counter)
+TEST(someip_offered_services_info_test, check_offered_services_as_rm_impl)
{
offer_test_service its_sample(offer_test::service, offer_test::remote_service);
}