Skip to content

Commit

Permalink
vsomeip 2.10.10
Browse files Browse the repository at this point in the history
  • Loading branch information
juergengehring committed Jan 25, 2018
1 parent 325b472 commit 4808f31
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 34 deletions.
3 changes: 3 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -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.
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 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)
Expand Down
5 changes: 4 additions & 1 deletion implementation/routing/src/routing_manager_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <map>
#include <algorithm>
#include <atomic>
#include <future>

#include <gtest/gtest.h>

Expand Down Expand Up @@ -76,13 +77,17 @@ class offered_services_info_test_client {
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();
}
Expand All @@ -109,10 +114,14 @@ class offered_services_info_test_client {
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();
Expand Down Expand Up @@ -165,28 +174,16 @@ class offered_services_info_test_client {
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));
}


Expand All @@ -201,6 +198,7 @@ class offered_services_info_test_client {

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;
Expand All @@ -215,10 +213,13 @@ class offered_services_info_test_client {
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;
Expand All @@ -233,10 +234,13 @@ class offered_services_info_test_client {
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;
Expand All @@ -251,6 +255,7 @@ class offered_services_info_test_client {
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() {
Expand Down Expand Up @@ -282,6 +287,7 @@ class offered_services_info_test_client {
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_;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"diagnosis":"0x12",
"logging" :
{
"level" : "debug",
"level" : "warning",
"console" : "true",
"file" :
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <map>
#include <algorithm>
#include <atomic>
#include <future>

#include <gtest/gtest.h>

Expand Down Expand Up @@ -138,14 +139,9 @@ class offer_test_service {
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));
Expand All @@ -155,6 +151,7 @@ class offer_test_service {

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) {
Expand All @@ -173,11 +170,15 @@ class offer_test_service {
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) {
Expand All @@ -196,12 +197,15 @@ class offer_test_service {
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) {
Expand All @@ -219,6 +223,7 @@ class offer_test_service {
}
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:
Expand All @@ -231,10 +236,11 @@ class offer_test_service {
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);
}
Expand Down

0 comments on commit 4808f31

Please sign in to comment.