summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuergen Gehring <juergen.gehring@bmw.de>2018-05-22 02:56:43 -0700
committerJuergen Gehring <juergen.gehring@bmw.de>2018-05-22 02:56:43 -0700
commitafba9f6b5657334dab422715c0f01869b4242627 (patch)
tree91a19df02a13dc694a1461e1c95ccdedfef598e7
parenta2b23e379fe383103cdf38cab7547a1e7451b9e2 (diff)
downloadvSomeIP-afba9f6b5657334dab422715c0f01869b4242627.tar.gz
vsomeip 2.10.162.10.16
-rw-r--r--CHANGES3
-rw-r--r--CMakeLists.txt2
-rw-r--r--implementation/routing/src/routing_manager_proxy.cpp7
-rw-r--r--implementation/service_discovery/include/service_discovery_impl.hpp1
-rw-r--r--implementation/service_discovery/src/service_discovery_impl.cpp10
-rw-r--r--implementation/utility/include/utility.hpp3
-rw-r--r--implementation/utility/src/utility.cpp213
-rw-r--r--test/CMakeLists.txt12
-rw-r--r--test/initial_event_tests/initial_event_test_client.cpp38
-rwxr-xr-xtest/initial_event_tests/initial_event_test_master_starter.sh6
-rwxr-xr-xtest/initial_event_tests/initial_event_test_slave_starter.sh6
11 files changed, 183 insertions, 118 deletions
diff --git a/CHANGES b/CHANGES
index acadc1a..a55daff 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,5 +1,8 @@
Changes
=======
+v2.10.16
+- Only map shared memory for client IDs once per process
+
v2.10.15
- Fix remote event caching
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7b6469e..794bed3 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 15)
+set (VSOMEIP_PATCH_VERSION 16)
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_proxy.cpp b/implementation/routing/src/routing_manager_proxy.cpp
index a54b691..c1fd00b 100644
--- a/implementation/routing/src/routing_manager_proxy.cpp
+++ b/implementation/routing/src/routing_manager_proxy.cpp
@@ -1944,9 +1944,10 @@ bool routing_manager_proxy::create_placeholder_event_and_subscribe(
// full information like eventgroup, field or not etc.
std::set<eventgroup_t> its_eventgroups({ _eventgroup });
// routing_manager_proxy: Always register with own client id and shadow = false
- register_event(host_->get_client(), _service, _instance, _event,
- its_eventgroups, true, std::chrono::milliseconds::zero(), false,
- nullptr, false, false, true);
+ routing_manager_base::register_event(host_->get_client(), _service,
+ _instance, _event, its_eventgroups, true,
+ std::chrono::milliseconds::zero(), false, nullptr, false, false,
+ true);
std::shared_ptr<event> its_event = find_event(_service, _instance, _event);
if (its_event) {
is_inserted = its_event->add_subscriber(_eventgroup, _client);
diff --git a/implementation/service_discovery/include/service_discovery_impl.hpp b/implementation/service_discovery/include/service_discovery_impl.hpp
index 49ccab2..402bcc3 100644
--- a/implementation/service_discovery/include/service_discovery_impl.hpp
+++ b/implementation/service_discovery/include/service_discovery_impl.hpp
@@ -364,6 +364,7 @@ private:
std::map<boost::asio::ip::address, std::pair<session_t, bool> > sessions_sent_;
std::map<boost::asio::ip::address,
std::tuple<session_t, session_t, bool, bool> > sessions_received_;
+ std::mutex sessions_received_mutex_;
// Runtime
std::weak_ptr<runtime> runtime_;
diff --git a/implementation/service_discovery/src/service_discovery_impl.cpp b/implementation/service_discovery/src/service_discovery_impl.cpp
index 2fa5f57..04ae7d7 100644
--- a/implementation/service_discovery/src/service_discovery_impl.cpp
+++ b/implementation/service_discovery/src/service_discovery_impl.cpp
@@ -153,6 +153,14 @@ void service_discovery_impl::start() {
return;
}
}
+ {
+ std::lock_guard<std::mutex> its_lock(sessions_received_mutex_);
+ sessions_received_.clear();
+ }
+ {
+ std::lock_guard<std::mutex> its_lock(serialize_mutex_);
+ sessions_sent_.clear();
+ }
if (is_suspended_) {
// make sure to sent out FindService messages after resume
@@ -1141,6 +1149,8 @@ void service_discovery_impl::on_message(const byte_t *_data, length_t _length,
msg << std::hex << std::setw(2) << std::setfill('0') << (int)_data[i] << " ";
VSOMEIP_INFO << msg.str();
#endif
+ std::lock_guard<std::mutex> its_session_lock(sessions_received_mutex_);
+
if(is_suspended_) {
return;
}
diff --git a/implementation/utility/include/utility.hpp b/implementation/utility/include/utility.hpp
index b0ff360..34979a6 100644
--- a/implementation/utility/include/utility.hpp
+++ b/implementation/utility/include/utility.hpp
@@ -9,6 +9,7 @@
#include <memory>
#include <vector>
#include <set>
+#include <atomic>
#include <vsomeip/enumeration_types.hpp>
#include <vsomeip/message.hpp>
@@ -128,7 +129,7 @@ private:
static void set_max_assigned_client_id_without_diagnosis(client_t _client);
static void check_client_id_consistency();
- static uint16_t its_configuration_refs__;
+ static std::atomic<std::uint16_t> its_configuration_refs__;
static std::uint16_t* used_client_ids__;
};
diff --git a/implementation/utility/src/utility.cpp b/implementation/utility/src/utility.cpp
index b3e276f..e368fa6 100644
--- a/implementation/utility/src/utility.cpp
+++ b/implementation/utility/src/utility.cpp
@@ -88,7 +88,7 @@ configuration_data_t *utility::the_configuration_data__(nullptr);
// critical section to protect shared memory pointers, handles and ref count in this process
CriticalSection utility::its_local_configuration_mutex__;
// number of times auto_configuration_init() has been called in this process
-uint16_t utility::its_configuration_refs__(0);
+std::atomic<std::uint16_t> utility::its_configuration_refs__(0);
// pointer to used client IDs array in shared memory
std::uint16_t* utility::used_client_ids__(0);
@@ -228,133 +228,138 @@ bool utility::auto_configuration_init(const std::shared_ptr<configuration> &_con
}
}
#else
- const mode_t previous_mask(::umask(static_cast<mode_t>(_config->get_umask())));
- int its_descriptor = shm_open(utility::get_shm_name(_config).c_str(), O_RDWR | O_CREAT | O_EXCL,
- static_cast<mode_t>(_config->get_permissions_shm()));
- ::umask(previous_mask);
- if (its_descriptor > -1) {
- if (-1 == ftruncate(its_descriptor, its_shm_size)) {
- VSOMEIP_ERROR << "utility::auto_configuration_init: "
- "ftruncate failed: " << std::strerror(errno);
- } else {
- void *its_segment = mmap(0, its_shm_size,
- PROT_READ | PROT_WRITE, MAP_SHARED,
- its_descriptor, 0);
- if(MAP_FAILED == its_segment) {
+ if (its_configuration_refs__ > 0) {
+ // shm is already mapped into the process
+ its_configuration_refs__++;
+ } else {
+ const mode_t previous_mask(::umask(static_cast<mode_t>(_config->get_umask())));
+ int its_descriptor = shm_open(utility::get_shm_name(_config).c_str(), O_RDWR | O_CREAT | O_EXCL,
+ static_cast<mode_t>(_config->get_permissions_shm()));
+ ::umask(previous_mask);
+ if (its_descriptor > -1) {
+ if (-1 == ftruncate(its_descriptor, its_shm_size)) {
VSOMEIP_ERROR << "utility::auto_configuration_init: "
- "mmap failed: " << std::strerror(errno);
+ "ftruncate failed: " << std::strerror(errno);
} else {
- the_configuration_data__
- = reinterpret_cast<configuration_data_t *>(its_segment);
- if (the_configuration_data__ != nullptr) {
- int ret;
- pthread_mutexattr_t attr;
- ret = pthread_mutexattr_init(&attr);
- if (0 == ret) {
- ret = pthread_mutexattr_setpshared(&attr, PTHREAD_PROCESS_SHARED);
+ void *its_segment = mmap(0, its_shm_size,
+ PROT_READ | PROT_WRITE, MAP_SHARED,
+ its_descriptor, 0);
+ if(MAP_FAILED == its_segment) {
+ VSOMEIP_ERROR << "utility::auto_configuration_init: "
+ "mmap failed: " << std::strerror(errno);
+ } else {
+ the_configuration_data__
+ = reinterpret_cast<configuration_data_t *>(its_segment);
+ if (the_configuration_data__ != nullptr) {
+ int ret;
+ pthread_mutexattr_t attr;
+ ret = pthread_mutexattr_init(&attr);
+ if (0 == ret) {
+ ret = pthread_mutexattr_setpshared(&attr, PTHREAD_PROCESS_SHARED);
+ if (0 != ret) {
+ VSOMEIP_ERROR << "pthread_mutexattr_setpshared() failed " << ret;
+ }
+ ret = pthread_mutexattr_setrobust(&attr, PTHREAD_MUTEX_ROBUST);
+ if (0 != ret) {
+ VSOMEIP_ERROR << "pthread_mutexattr_setrobust() failed " << ret;
+ }
+
+ } else {
+ VSOMEIP_ERROR << "pthread_mutexattr_init() failed " << ret;
+ }
+ ret = pthread_mutex_init(&the_configuration_data__->mutex_, (0==ret)?&attr:NULL);
if (0 != ret) {
- VSOMEIP_ERROR << "pthread_mutexattr_setpshared() failed " << ret;
+ VSOMEIP_ERROR << "pthread_mutex_init() failed " << ret;
}
- ret = pthread_mutexattr_setrobust(&attr, PTHREAD_MUTEX_ROBUST);
+ ret = pthread_mutex_lock(&the_configuration_data__->mutex_);
if (0 != ret) {
- VSOMEIP_ERROR << "pthread_mutexattr_setrobust() failed " << ret;
+ VSOMEIP_ERROR << "pthread_mutex_lock() failed " << ret;
}
- } else {
- VSOMEIP_ERROR << "pthread_mutexattr_init() failed " << ret;
- }
- ret = pthread_mutex_init(&the_configuration_data__->mutex_, (0==ret)?&attr:NULL);
- if (0 != ret) {
- VSOMEIP_ERROR << "pthread_mutex_init() failed " << ret;
- }
- ret = pthread_mutex_lock(&the_configuration_data__->mutex_);
- if (0 != ret) {
- VSOMEIP_ERROR << "pthread_mutex_lock() failed " << ret;
- }
-
- the_configuration_data__->client_base_
- = static_cast<unsigned short>((_config->get_diagnosis_address() << 8) & _config->get_diagnosis_mask());
- the_configuration_data__->max_clients_ = static_cast<std::uint16_t>(~_config->get_diagnosis_mask());
- the_configuration_data__->max_used_client_ids_index_ = 1;
- the_configuration_data__->max_assigned_client_id_without_diagnosis_ = 0x00;
- the_configuration_data__->routing_manager_host_ = 0x0000;
- // the clientid array starts right after the routing_manager_host_ struct member
- used_client_ids__ = reinterpret_cast<unsigned short*>(
- reinterpret_cast<size_t>(&the_configuration_data__->routing_manager_host_) + sizeof(unsigned short));
- used_client_ids__[0] = the_configuration_data__->client_base_;
- the_configuration_data__->client_base_++;
+ the_configuration_data__->client_base_
+ = static_cast<unsigned short>((_config->get_diagnosis_address() << 8) & _config->get_diagnosis_mask());
+ the_configuration_data__->max_clients_ = static_cast<std::uint16_t>(~_config->get_diagnosis_mask());
+ the_configuration_data__->max_used_client_ids_index_ = 1;
+ the_configuration_data__->max_assigned_client_id_without_diagnosis_ = 0x00;
+ the_configuration_data__->routing_manager_host_ = 0x0000;
+ // the clientid array starts right after the routing_manager_host_ struct member
+ used_client_ids__ = reinterpret_cast<unsigned short*>(
+ reinterpret_cast<size_t>(&the_configuration_data__->routing_manager_host_) + sizeof(unsigned short));
+ used_client_ids__[0] = the_configuration_data__->client_base_;
+ the_configuration_data__->client_base_++;
- std::string its_name = _config->get_routing_host();
+ std::string its_name = _config->get_routing_host();
- its_configuration_refs__++;
+ its_configuration_refs__++;
- the_configuration_data__->initialized_ = 1;
+ the_configuration_data__->initialized_ = 1;
- ret = pthread_mutex_unlock(&the_configuration_data__->mutex_);
- if (0 != ret) {
- VSOMEIP_ERROR << "pthread_mutex_unlock() failed " << ret;
+ ret = pthread_mutex_unlock(&the_configuration_data__->mutex_);
+ if (0 != ret) {
+ VSOMEIP_ERROR << "pthread_mutex_unlock() failed " << ret;
+ }
}
- }
- if(-1 == ::close(its_descriptor)) {
- VSOMEIP_ERROR << "utility::auto_configuration_init: "
- "close failed: " << std::strerror(errno);
+ if(-1 == ::close(its_descriptor)) {
+ VSOMEIP_ERROR << "utility::auto_configuration_init: "
+ "close failed: " << std::strerror(errno);
+ }
}
}
- }
- } else if (errno == EEXIST) {
- const mode_t previous_mask(::umask(static_cast<mode_t>(_config->get_umask())));
- its_descriptor = shm_open(utility::get_shm_name(_config).c_str(), O_RDWR,
- static_cast<mode_t>(_config->get_permissions_shm()));
- ::umask(previous_mask);
- if (-1 == its_descriptor) {
- VSOMEIP_ERROR << "utility::auto_configuration_init: "
- "shm_open failed: " << std::strerror(errno);
- } else {
- // truncate to make sure we work on valid shm;
- // in case creator already called truncate, this effectively becomes a noop
- if (-1 == ftruncate(its_descriptor, its_shm_size)) {
+ } else if (errno == EEXIST) {
+ const mode_t previous_mask(::umask(static_cast<mode_t>(_config->get_umask())));
+ its_descriptor = shm_open(utility::get_shm_name(_config).c_str(), O_RDWR,
+ static_cast<mode_t>(_config->get_permissions_shm()));
+ ::umask(previous_mask);
+ if (-1 == its_descriptor) {
VSOMEIP_ERROR << "utility::auto_configuration_init: "
- "ftruncate failed: " << std::strerror(errno);
+ "shm_open failed: " << std::strerror(errno);
} else {
- void *its_segment = mmap(0, its_shm_size,
- PROT_READ | PROT_WRITE, MAP_SHARED,
- its_descriptor, 0);
- if(MAP_FAILED == its_segment) {
+ // truncate to make sure we work on valid shm;
+ // in case creator already called truncate, this effectively becomes a noop
+ if (-1 == ftruncate(its_descriptor, its_shm_size)) {
VSOMEIP_ERROR << "utility::auto_configuration_init: "
- "mmap failed: " << std::strerror(errno);
+ "ftruncate failed: " << std::strerror(errno);
} else {
- configuration_data_t *configuration_data
- = reinterpret_cast<configuration_data_t *>(its_segment);
-
- // check if it is ready for use (for 3 seconds)
- int retry_count = 300;
- while (configuration_data->initialized_ == 0 && --retry_count > 0) {
- std::this_thread::sleep_for(std::chrono::milliseconds(10));
- }
-
- if (configuration_data->initialized_ == 0) {
- VSOMEIP_ERROR << "utility::auto_configuration_init: data in shm not initialized";
+ void *its_segment = mmap(0, its_shm_size,
+ PROT_READ | PROT_WRITE, MAP_SHARED,
+ its_descriptor, 0);
+ if(MAP_FAILED == its_segment) {
+ VSOMEIP_ERROR << "utility::auto_configuration_init: "
+ "mmap failed: " << std::strerror(errno);
} else {
- the_configuration_data__ = configuration_data;
+ configuration_data_t *configuration_data
+ = reinterpret_cast<configuration_data_t *>(its_segment);
+
+ // check if it is ready for use (for 3 seconds)
+ int retry_count = 300;
+ while (configuration_data->initialized_ == 0 && --retry_count > 0) {
+ std::this_thread::sleep_for(std::chrono::milliseconds(10));
+ }
- if (EOWNERDEAD == pthread_mutex_lock(&the_configuration_data__->mutex_)) {
- VSOMEIP_WARNING << "utility::auto_configuration_init EOWNERDEAD";
- check_client_id_consistency();
- if (0 != pthread_mutex_consistent(&the_configuration_data__->mutex_)) {
- VSOMEIP_ERROR << "pthread_mutex_consistent() failed ";
+ if (configuration_data->initialized_ == 0) {
+ VSOMEIP_ERROR << "utility::auto_configuration_init: data in shm not initialized";
+ } else {
+ the_configuration_data__ = configuration_data;
+
+ if (EOWNERDEAD == pthread_mutex_lock(&the_configuration_data__->mutex_)) {
+ VSOMEIP_WARNING << "utility::auto_configuration_init EOWNERDEAD";
+ check_client_id_consistency();
+ if (0 != pthread_mutex_consistent(&the_configuration_data__->mutex_)) {
+ VSOMEIP_ERROR << "pthread_mutex_consistent() failed ";
+ }
}
+ its_configuration_refs__++;
+ used_client_ids__ = reinterpret_cast<unsigned short*>(
+ reinterpret_cast<size_t>(&the_configuration_data__->routing_manager_host_)
+ + sizeof(unsigned short));
+ pthread_mutex_unlock(&the_configuration_data__->mutex_);
}
- its_configuration_refs__++;
- used_client_ids__ = reinterpret_cast<unsigned short*>(
- reinterpret_cast<size_t>(&the_configuration_data__->routing_manager_host_)
- + sizeof(unsigned short));
- pthread_mutex_unlock(&the_configuration_data__->mutex_);
- }
- if (-1 == ::close(its_descriptor)) {
- VSOMEIP_ERROR << "utility::auto_configuration_init: "
- "close failed: " << std::strerror(errno);
+ if (-1 == ::close(its_descriptor)) {
+ VSOMEIP_ERROR << "utility::auto_configuration_init: "
+ "close failed: " << std::strerror(errno);
+ }
}
}
}
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 6f04888..98a4a5a 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -2800,6 +2800,18 @@ if(NOT ${TESTS_BAT})
COMMAND ${PROJECT_BINARY_DIR}/test/${TEST_INITIAL_EVENT_MASTER_STARTER} UDP ${TEST_INITIAL_EVENT_DIFF_IDS_DIFF_PORTS_SAME_SERVICEID_MASTER_CONFIG_FILE} SAME_SERVICE_ID MULTIPLE_EVENTS SUBSCRIBE_ON_AVAILABILITY)
set_tests_properties(${TEST_INITIAL_EVENT_NAME}_multiple_events_subscribe_on_availability_diff_client_ids_diff_ports_same_service_id_udp PROPERTIES TIMEOUT 120)
+ add_test(NAME ${TEST_INITIAL_EVENT_NAME}_multiple_events_diff_client_ids_diff_ports_partial_subscription_udp
+ COMMAND ${PROJECT_BINARY_DIR}/test/${TEST_INITIAL_EVENT_MASTER_STARTER} UDP ${TEST_INITIAL_EVENT_DIFF_IDS_DIFF_PORTS_MASTER_CONFIG_FILE} MULTIPLE_EVENTS SUBSCRIBE_ONLY_ONE)
+ set_tests_properties(${TEST_INITIAL_EVENT_NAME}_multiple_events_diff_client_ids_diff_ports_partial_subscription_udp PROPERTIES TIMEOUT 120)
+
+ add_test(NAME ${TEST_INITIAL_EVENT_NAME}_multiple_events_diff_client_ids_diff_ports_partial_subscription_tcp
+ COMMAND ${PROJECT_BINARY_DIR}/test/${TEST_INITIAL_EVENT_MASTER_STARTER} TCP ${TEST_INITIAL_EVENT_DIFF_IDS_DIFF_PORTS_MASTER_TCP_CONFIG_FILE} MULTIPLE_EVENTS SUBSCRIBE_ONLY_ONE)
+ set_tests_properties(${TEST_INITIAL_EVENT_NAME}_multiple_events_diff_client_ids_diff_ports_partial_subscription_tcp PROPERTIES TIMEOUT 120)
+
+ add_test(NAME ${TEST_INITIAL_EVENT_NAME}_multiple_events_diff_client_ids_diff_ports_partial_subscription_both_tcp_and_udp
+ COMMAND ${PROJECT_BINARY_DIR}/test/${TEST_INITIAL_EVENT_MASTER_STARTER} TCP_AND_UDP ${TEST_INITIAL_EVENT_DIFF_IDS_DIFF_PORTS_MASTER_TCP_CONFIG_FILE} MULTIPLE_EVENTS SUBSCRIBE_ONLY_ONE)
+ set_tests_properties(${TEST_INITIAL_EVENT_NAME}_multiple_events_diff_client_ids_diff_ports_partial_subscription_both_tcp_and_udp PROPERTIES TIMEOUT 120)
+
# offer tests
add_test(NAME ${TEST_OFFER_NAME}_local
COMMAND ${PROJECT_BINARY_DIR}/test/${TEST_OFFER_LOCAL_STARTER})
diff --git a/test/initial_event_tests/initial_event_test_client.cpp b/test/initial_event_tests/initial_event_test_client.cpp
index 22940eb..d667e91 100644
--- a/test/initial_event_tests/initial_event_test_client.cpp
+++ b/test/initial_event_tests/initial_event_test_client.cpp
@@ -34,7 +34,7 @@ public:
std::array<initial_event_test::service_info, 7> _service_infos,
bool _subscribe_on_available, std::uint32_t _events_to_subscribe,
bool _initial_event_strict_checking,
- bool _dont_exit) :
+ bool _dont_exit, bool _subscribe_only_one) :
client_number_(_client_number),
service_infos_(_service_infos),
subscription_type_(_subscription_type),
@@ -46,6 +46,7 @@ public:
events_to_subscribe_(_events_to_subscribe),
initial_event_strict_checking_(_initial_event_strict_checking),
dont_exit_(_dont_exit),
+ subscribe_only_one_(_subscribe_only_one),
stop_thread_(std::bind(&initial_event_test_client::wait_for_stop, this)) {
if (!app_->init()) {
ADD_FAILURE() << "Couldn't initialize application";
@@ -92,20 +93,31 @@ public:
}
other_services_available_[std::make_pair(i.service_id, i.instance_id)] = false;
- for (std::uint32_t j = 0; j < events_to_subscribe_; j++ ) {
- other_services_received_notification_[std::make_pair(i.service_id, i.method_id + j)] = 0;
- }
+
if (!subscribe_on_available_) {
- if (events_to_subscribe_ == 1 ) {
+ if (events_to_subscribe_ == 1) {
app_->subscribe(i.service_id, i.instance_id, i.eventgroup_id,
vsomeip::DEFAULT_MAJOR, subscription_type_);
+ other_services_received_notification_[std::make_pair(i.service_id, i.event_id)] = 0;
} else if (events_to_subscribe_ > 1) {
- for (std::uint32_t j = 0; j < events_to_subscribe_; j++ ) {
+ if (!subscribe_only_one_) {
+ for (std::uint32_t j = 0; j < events_to_subscribe_; j++ ) {
+ app_->subscribe(i.service_id, i.instance_id, i.eventgroup_id,
+ vsomeip::DEFAULT_MAJOR, subscription_type_,
+ static_cast<vsomeip::event_t>(i.event_id + j));
+ other_services_received_notification_[std::make_pair(i.service_id, i.event_id + j)] = 0;
+ }
+ } else {
app_->subscribe(i.service_id, i.instance_id, i.eventgroup_id,
vsomeip::DEFAULT_MAJOR, subscription_type_,
- static_cast<vsomeip::event_t>(i.event_id + j));
+ static_cast<vsomeip::event_t>(i.event_id));
+ other_services_received_notification_[std::make_pair(i.service_id, i.event_id)] = 0;
}
}
+ } else {
+ for (std::uint32_t j = 0; j < events_to_subscribe_; j++ ) {
+ other_services_received_notification_[std::make_pair(i.service_id, i.event_id + j)] = 0;
+ }
}
}
@@ -360,6 +372,7 @@ private:
std::uint32_t events_to_subscribe_;
bool initial_event_strict_checking_;
bool dont_exit_;
+ bool subscribe_only_one_;
std::mutex stop_mutex_;
std::condition_variable stop_condition_;
@@ -373,6 +386,7 @@ static bool subscribe_on_available;
static std::uint32_t subscribe_multiple_events;
static bool initial_event_strict_checking;
static bool dont_exit;
+static bool subscribe_only_one;
extern "C" void signal_handler(int signum) {
the_client->handle_signal(signum);
@@ -384,11 +398,13 @@ TEST(someip_initial_event_test, wait_for_initial_events_of_all_services)
initial_event_test_client its_sample(client_number,
subscription_type,
initial_event_test::service_infos_same_service_id, subscribe_on_available,
- subscribe_multiple_events, initial_event_strict_checking, dont_exit);
+ subscribe_multiple_events, initial_event_strict_checking, dont_exit,
+ subscribe_only_one);
} else {
initial_event_test_client its_sample(client_number, subscription_type,
initial_event_test::service_infos, subscribe_on_available,
- subscribe_multiple_events, initial_event_strict_checking, dont_exit);
+ subscribe_multiple_events, initial_event_strict_checking, dont_exit,
+ subscribe_only_one);
}
}
@@ -407,6 +423,7 @@ int main(int argc, char** argv)
std::cerr << " - MULTIPLE_EVENTS flag. If set the test will subscribe to multiple events in the eventgroup, default false" << std::endl;
std::cerr << " - STRICT_CHECKING flag. If set the test will only successfully finish if exactly the number of initial events were received (and not more). Default false" << std::endl;
std::cerr << " - DONT_EXIT flag. If set the test will not exit if all notifications have been received. Default false" << std::endl;
+ std::cerr << " - SUBSCRIBE_ONLY_ONE flag. If set the test will only subscribe to one event even if MULTIPLE_EVENTS is set. Default false" << std::endl;
return 1;
}
@@ -434,6 +451,7 @@ int main(int argc, char** argv)
use_same_service_id = false;
subscribe_multiple_events = 1;
dont_exit = false;
+ subscribe_only_one = false;
if (argc > 3) {
for (int i = 3; i < argc; i++) {
if (std::string("SUBSCRIBE_ON_AVAILABILITY") == std::string(argv[i])) {
@@ -448,6 +466,8 @@ int main(int argc, char** argv)
initial_event_strict_checking = true;
} else if (std::string("DONT_EXIT") == std::string(argv[i])) {
dont_exit = true;
+ } else if (std::string("SUBSCRIBE_ONLY_ONE") == std::string(argv[i])) {
+ subscribe_only_one = true;
}
}
}
diff --git a/test/initial_event_tests/initial_event_test_master_starter.sh b/test/initial_event_tests/initial_event_test_master_starter.sh
index 9eee669..b083c53 100755
--- a/test/initial_event_tests/initial_event_test_master_starter.sh
+++ b/test/initial_event_tests/initial_event_test_master_starter.sh
@@ -19,6 +19,7 @@ then
echo "Please pass a json file to this script."
echo "For example: $0 UDP initial_event_test_diff_client_ids_diff_ports_master.json"
echo "To use the same service id but different instances on the node pass SAME_SERVICE_ID as third parameter"
+ echo "To ensure the first client only subscribes to one event pass SUBSCRIBE_ONLY_ONE as third/fourth parameter"
exit 1
fi
@@ -111,6 +112,11 @@ sleep 1
print_starter_message
+# remove SUBSCRIBE_ONLY_ONCE parameter from $REMAINING_OPTIONS to ensure the
+# following clients subscribe normaly
+REMAINING_OPTIONS=${REMAINING_OPTIONS%SUBSCRIBE_ONLY_ONE}
+REMAINING_OPTIONS=${REMAINING_OPTIONS#SUBSCRIBE_ONLY_ONE}
+
# wait until the services on the remote node were started as well
wait $PID_AVAILABILITY_CHECKER
diff --git a/test/initial_event_tests/initial_event_test_slave_starter.sh b/test/initial_event_tests/initial_event_test_slave_starter.sh
index 69e96f7..59fdd5b 100755
--- a/test/initial_event_tests/initial_event_test_slave_starter.sh
+++ b/test/initial_event_tests/initial_event_test_slave_starter.sh
@@ -19,6 +19,7 @@ then
echo "Please pass a json file to this script."
echo "For example: $0 UDP initial_event_test_diff_client_ids_diff_ports_slave.json"
echo "To use the same service id but different instances on the node pass SAME_SERVICE_ID as third parameter"
+ echo "To ensure the first client only subscribes to one event pass SUBSCRIBE_ONLY_ONE as third/fourth parameter"
exit 1
fi
@@ -74,6 +75,11 @@ CLIENT_PIDS=()
./initial_event_test_client 9000 $PASSED_SUBSCRIPTION_TYPE DONT_EXIT $REMAINING_OPTIONS &
FIRST_PID=$!
+# remove SUBSCRIBE_ONLY_ONCE parameter from $REMAINING_OPTIONS to ensure the
+# following clients subscribe normaly
+REMAINING_OPTIONS=${REMAINING_OPTIONS%SUBSCRIBE_ONLY_ONE}
+REMAINING_OPTIONS=${REMAINING_OPTIONS#SUBSCRIBE_ONLY_ONE}
+
# Start availability checker in order to wait until the services on the remote
# were started as well
./initial_event_test_availability_checker 1234 $REMAINING_OPTIONS &