summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuergen Gehring <juergen.gehring@bmw.de>2018-01-25 00:40:05 -0800
committerJuergen Gehring <juergen.gehring@bmw.de>2018-01-25 00:40:05 -0800
commitd04934f62eae198242d55298a9bc0365b0d7ec64 (patch)
treece669ec2a362f85f48c369d6cf5448fddad66f38
parent3f1a365a25910caee2c740b3ca3bd4f07c8c0779 (diff)
downloadvSomeIP-d04934f62eae198242d55298a9bc0365b0d7ec64.tar.gz
vsomeip 2.10.22.10.2
-rw-r--r--CHANGES10
-rw-r--r--CMakeLists.txt2
-rw-r--r--daemon/vsomeipd.cpp1
-rw-r--r--documentation/vsomeipUserGuide10
-rw-r--r--implementation/configuration/include/client.hpp2
-rw-r--r--implementation/configuration/include/configuration.hpp8
-rw-r--r--implementation/configuration/include/configuration_impl.hpp20
-rw-r--r--implementation/configuration/include/internal.hpp.in2
-rw-r--r--implementation/configuration/src/configuration_impl.cpp160
-rw-r--r--implementation/endpoints/include/client_endpoint_impl.hpp1
-rw-r--r--implementation/endpoints/include/endpoint.hpp2
-rw-r--r--implementation/endpoints/include/endpoint_impl.hpp1
-rw-r--r--implementation/endpoints/include/local_client_endpoint_impl.hpp1
-rw-r--r--implementation/endpoints/include/local_server_endpoint_impl.hpp5
-rw-r--r--implementation/endpoints/include/server_endpoint_impl.hpp2
-rw-r--r--implementation/endpoints/include/tcp_client_endpoint_impl.hpp1
-rw-r--r--implementation/endpoints/include/tcp_server_endpoint_impl.hpp8
-rw-r--r--implementation/endpoints/include/udp_client_endpoint_impl.hpp4
-rw-r--r--implementation/endpoints/include/udp_server_endpoint_impl.hpp3
-rw-r--r--implementation/endpoints/include/virtual_server_endpoint_impl.hpp1
-rw-r--r--implementation/endpoints/src/local_client_endpoint_impl.cpp20
-rw-r--r--implementation/endpoints/src/local_server_endpoint_impl.cpp49
-rw-r--r--implementation/endpoints/src/server_endpoint_impl.cpp2
-rw-r--r--implementation/endpoints/src/tcp_client_endpoint_impl.cpp25
-rw-r--r--implementation/endpoints/src/tcp_server_endpoint_impl.cpp41
-rw-r--r--implementation/endpoints/src/udp_client_endpoint_impl.cpp50
-rw-r--r--implementation/endpoints/src/udp_server_endpoint_impl.cpp23
-rw-r--r--implementation/endpoints/src/virtual_server_endpoint_impl.cpp4
-rw-r--r--implementation/plugin/include/plugin_manager.hpp9
-rw-r--r--implementation/plugin/src/plugin_manager.cpp42
-rw-r--r--implementation/routing/include/routing_manager_base.hpp2
-rw-r--r--implementation/routing/include/routing_manager_impl.hpp26
-rw-r--r--implementation/routing/include/routing_manager_stub.hpp1
-rw-r--r--implementation/routing/src/eventgroupinfo.cpp38
-rw-r--r--implementation/routing/src/routing_manager_base.cpp6
-rw-r--r--implementation/routing/src/routing_manager_impl.cpp207
-rw-r--r--implementation/routing/src/routing_manager_stub.cpp9
-rw-r--r--implementation/runtime/src/application_impl.cpp52
-rw-r--r--implementation/service_discovery/include/service_discovery_host.hpp3
-rw-r--r--implementation/service_discovery/include/service_discovery_impl.hpp5
-rw-r--r--implementation/service_discovery/src/service_discovery_impl.cpp64
-rw-r--r--test/client_id_tests/client_id_test_utility.cpp2
-rw-r--r--test/configuration_tests/configuration-test.cpp9
43 files changed, 752 insertions, 181 deletions
diff --git a/CHANGES b/CHANGES
index e1defd0..e279fdd 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,16 @@
Changes
=======
+v2.10.2
+- Fix deadlock in routing manager when processing subscription
+ acknowledgment from a local client if the corresponding service
+ instance was stopped in the meanwhile.
+- Introduce status_log_interval and memory_log_interval json file
+ parameters which can be used to cyclically log memory consumption
+ and/or internal status of the routing manager in a given interval
+- Add Debug Diagnosis Job plug-in
+- Support definition of multiple client port ranges in configuration
+
v2.10.1
- Fix possible memory corruption in routing manager on TCP connection
reset
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a35193a..2fd0022 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 1)
+set (VSOMEIP_PATCH_VERSION 2)
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/daemon/vsomeipd.cpp b/daemon/vsomeipd.cpp
index 37f22a0..b9a27d0 100644
--- a/daemon/vsomeipd.cpp
+++ b/daemon/vsomeipd.cpp
@@ -9,6 +9,7 @@
#include <unistd.h>
#include <thread>
#include <condition_variable>
+#include <mutex>
#include <iostream>
diff --git a/documentation/vsomeipUserGuide b/documentation/vsomeipUserGuide
index b0fbb14..882890d 100644
--- a/documentation/vsomeipUserGuide
+++ b/documentation/vsomeipUserGuide
@@ -338,6 +338,16 @@ values: _true, false_)
+
Configures interval in seconds to log the vSomeIP version. Default value is 10.
+
+** 'memory_log_interval'
++
+Configures interval in seconds in which the routing manager logs its used
+memory. Setting a value greater than zero enables the logging.
++
+** 'status_log_interval'
++
+Configures interval in seconds in which the routing manager logs its internal
+status. Setting a value greater than zero enables the logging.
++
//Tracing
* anchor:config-tracing[]'tracing' (optional)
+
diff --git a/implementation/configuration/include/client.hpp b/implementation/configuration/include/client.hpp
index 2b48a98..81ed890 100644
--- a/implementation/configuration/include/client.hpp
+++ b/implementation/configuration/include/client.hpp
@@ -16,6 +16,8 @@ namespace vsomeip {
namespace cfg {
struct client {
+ client() : service_(ANY_SERVICE), instance_(ANY_INSTANCE) {}
+
// ports for specific service / instance
service_t service_;
instance_t instance_;
diff --git a/implementation/configuration/include/configuration.hpp b/implementation/configuration/include/configuration.hpp
index 22ae6c3..9908e48 100644
--- a/implementation/configuration/include/configuration.hpp
+++ b/implementation/configuration/include/configuration.hpp
@@ -136,7 +136,7 @@ public:
virtual bool check_credentials(client_t _client, uint32_t _uid, uint32_t _gid) const = 0;
// Plugins
- virtual std::map<plugin_type_e, std::string> get_plugins(
+ virtual std::map<plugin_type_e, std::set<std::string>> get_plugins(
const std::string &_name) const = 0;
virtual void set_configuration_path(const std::string &_path) = 0;
@@ -144,6 +144,12 @@ public:
//E2E
virtual std::map<e2exf::data_identifier, std::shared_ptr<cfg::e2e>> get_e2e_configuration() const = 0;
virtual bool is_e2e_enabled() const = 0;
+
+ virtual bool log_memory() const = 0;
+ virtual uint32_t get_log_memory_interval() const = 0;
+
+ virtual bool log_status() const = 0;
+ virtual uint32_t get_log_status_interval() const = 0;
};
} // namespace vsomeip
diff --git a/implementation/configuration/include/configuration_impl.hpp b/implementation/configuration/include/configuration_impl.hpp
index 4f8886a..265d5d9 100644
--- a/implementation/configuration/include/configuration_impl.hpp
+++ b/implementation/configuration/include/configuration_impl.hpp
@@ -149,12 +149,18 @@ public:
instance_t _instance) const;
VSOMEIP_EXPORT bool check_credentials(client_t _client, uint32_t _uid, uint32_t _gid) const;
- VSOMEIP_EXPORT std::map<plugin_type_e, std::string> get_plugins(
+ VSOMEIP_EXPORT std::map<plugin_type_e, std::set<std::string>> get_plugins(
const std::string &_name) const;
// E2E
VSOMEIP_EXPORT std::map<e2exf::data_identifier, std::shared_ptr<cfg::e2e>> get_e2e_configuration() const;
VSOMEIP_EXPORT bool is_e2e_enabled() const;
+ VSOMEIP_EXPORT bool log_memory() const;
+ VSOMEIP_EXPORT uint32_t get_log_memory_interval() const;
+
+ VSOMEIP_EXPORT bool log_status() const;
+ VSOMEIP_EXPORT uint32_t get_log_status_interval() const;
+
private:
void read_data(const std::set<std::string> &_input,
std::vector<element> &_elements,
@@ -217,10 +223,12 @@ private:
servicegroup *find_servicegroup(const std::string &_name) const;
std::shared_ptr<client> find_client(service_t _service,
- instance_t _instance, uint16_t _remote_port, bool _reliable) const;
+ instance_t _instance) const;
std::shared_ptr<service> find_service(service_t _service, instance_t _instance) const;
std::shared_ptr<eventgroup> find_eventgroup(service_t _service,
instance_t _instance, eventgroup_t _eventgroup) const;
+ bool find_port(uint16_t &_port, uint16_t _remote, bool _reliable,
+ std::map<bool, std::set<uint16_t> > &_used_client_ports) const;
void set_magic_cookies_unicast_address();
@@ -255,7 +263,7 @@ protected:
boost::log::trivial::severity_level loglevel_;
std::map<std::string, std::tuple<client_t, std::size_t, std::size_t,
- size_t, size_t, std::map<plugin_type_e, std::string>>> applications_;
+ size_t, size_t, std::map<plugin_type_e, std::set<std::string>>>> applications_;
std::set<client_t> client_identifiers_;
std::map<service_t,
@@ -341,6 +349,12 @@ protected:
bool e2e_enabled_;
std::map<e2exf::data_identifier, std::shared_ptr<cfg::e2e>> e2e_configuration_;
+
+ bool log_memory_;
+ uint32_t log_memory_interval_;
+
+ bool log_status_;
+ uint32_t log_status_interval_;
};
} // namespace cfg
diff --git a/implementation/configuration/include/internal.hpp.in b/implementation/configuration/include/internal.hpp.in
index 682dbcc..3a987f9 100644
--- a/implementation/configuration/include/internal.hpp.in
+++ b/implementation/configuration/include/internal.hpp.in
@@ -16,12 +16,14 @@
#define VSOMEIP_ENV_MANDATORY_CONFIGURATION_FILES "VSOMEIP_MANDATORY_CONFIGURATION_FILES"
#define VSOMEIP_ENV_LOAD_PLUGINS "VSOMEIP_LOAD_PLUGINS"
#define VSOMEIP_ENV_CLIENTSIDELOGGING "VSOMEIP_CLIENTSIDELOGGING"
+#define VSOMEIP_ENV_DEBUG_CONFIGURATION "VSOMEIP_DEBUG_CONFIGURATION"
#define VSOMEIP_DEFAULT_CONFIGURATION_FILE "/etc/vsomeip.json"
#define VSOMEIP_LOCAL_CONFIGURATION_FILE "./vsomeip.json"
#define VSOMEIP_MANDATORY_CONFIGURATION_FILES "vsomeip_std.json,vsomeip_app.json,vsomeip_plc.json,vsomeip_log.json"
#define VSOMEIP_DEFAULT_CONFIGURATION_FOLDER "/etc/vsomeip"
+#define VSOMEIP_DEBUG_CONFIGURATION_FOLDER "/var/opt/public/sin/vsomeip/"
#define VSOMEIP_LOCAL_CONFIGURATION_FOLDER "./vsomeip"
#define VSOMEIP_BASE_PATH "/tmp/"
diff --git a/implementation/configuration/src/configuration_impl.cpp b/implementation/configuration/src/configuration_impl.cpp
index ea14755..243f93e 100644
--- a/implementation/configuration/src/configuration_impl.cpp
+++ b/implementation/configuration/src/configuration_impl.cpp
@@ -19,6 +19,7 @@
#include <vsomeip/constants.hpp>
#include <vsomeip/plugins/application_plugin.hpp>
+#include <vsomeip/plugins/pre_configuration_plugin.hpp>
#include "../include/client.hpp"
#include "../include/configuration_impl.hpp"
@@ -30,6 +31,7 @@
#include "../../routing/include/event.hpp"
#include "../../service_discovery/include/defines.hpp"
#include "../../utility/include/utility.hpp"
+#include "../../plugin/include/plugin_manager.hpp"
VSOMEIP_PLUGIN(vsomeip::cfg::configuration_impl)
@@ -71,7 +73,11 @@ configuration_impl::configuration_impl()
policy_enabled_(false),
check_credentials_(false),
network_("vsomeip"),
- e2e_enabled_(false) {
+ e2e_enabled_(false),
+ log_memory_(false),
+ log_memory_interval_(0),
+ log_status_(false),
+ log_status_interval_(0) {
unicast_ = unicast_.from_string(VSOMEIP_UNICAST_ADDRESS);
for (auto i = 0; i < ET_MAX; i++)
is_configured_[i] = false;
@@ -133,6 +139,11 @@ configuration_impl::configuration_impl(const configuration_impl &_other)
check_credentials_ = _other.check_credentials_;
network_ = _other.network_;
e2e_enabled_ = _other.e2e_enabled_;
+
+ log_memory_ = _other.log_memory_;
+ log_memory_interval_ = _other.log_memory_interval_;
+ log_status_ = _other.log_status_;
+ log_status_interval_ = _other.log_status_interval_;
}
configuration_impl::~configuration_impl() {
@@ -170,17 +181,6 @@ bool configuration_impl::load(const std::string &_name) {
}
}
- // Finally, pverride with path from set config path (if existing)
- if (configuration_path_.length()) {
- if (utility::is_file(configuration_path_)) {
- its_file = configuration_path_;
- its_folder = "";
- } else if (utility::is_folder(configuration_path_)) {
- its_folder = configuration_path_;
- its_file = "";
- }
- }
-
std::set<std::string> its_input;
if (its_file != "") {
its_input.insert(its_file);
@@ -189,6 +189,14 @@ bool configuration_impl::load(const std::string &_name) {
its_input.insert(its_folder);
}
+ // Add debug configuration folder/file on top of already set input
+ const char* its_debug_env = getenv(VSOMEIP_ENV_DEBUG_CONFIGURATION);
+ if (nullptr != its_debug_env) {
+ its_input.insert(its_debug_env);
+ } else {
+ its_input.insert(VSOMEIP_DEBUG_CONFIGURATION_FOLDER);
+ }
+
// Determine standard configuration file
its_env = getenv(VSOMEIP_ENV_MANDATORY_CONFIGURATION_FILES);
if (nullptr != its_env) {
@@ -236,11 +244,13 @@ bool configuration_impl::load(const std::string &_name) {
<< std::chrono::duration_cast<std::chrono::milliseconds>(end - begin).count()
<< "ms";
- if (utility::is_file(its_file))
- VSOMEIP_INFO << "Using configuration file: \"" << its_file << "\".";
+ for (auto i : its_input) {
+ if (utility::is_file(i))
+ VSOMEIP_INFO << "Using configuration file: \"" << i << "\".";
- if (utility::is_folder(its_folder))
- VSOMEIP_INFO << "Using configuration folder: \"" << its_folder << "\".";
+ if (utility::is_folder(i))
+ VSOMEIP_INFO << "Using configuration folder: \"" << i << "\".";
+ }
if (policy_enabled_ && check_credentials_)
VSOMEIP_INFO << "Security configuration is active.";
@@ -341,6 +351,10 @@ bool configuration_impl::load_data(const std::vector<element> &_elements,
}
}
+ for (auto its_service : services_) {
+ VSOMEIP_INFO << "service: " << its_service.first;
+ }
+
return is_logging_loaded_ && has_routing && has_applications;
}
@@ -418,6 +432,20 @@ bool configuration_impl::load_logging(
its_converter >> log_version_interval_;
}
}
+ } else if (its_key == "memory_log_interval") {
+ std::stringstream its_converter;
+ its_converter << std::dec << i->second.data();
+ its_converter >> log_memory_interval_;
+ if (log_memory_interval_ > 0) {
+ log_memory_ = true;
+ }
+ } else if (its_key == "status_log_interval") {
+ std::stringstream its_converter;
+ its_converter << std::dec << i->second.data();
+ its_converter >> log_status_interval_;
+ if (log_status_interval_ > 0) {
+ log_status_ = true;
+ }
}
}
} catch (...) {
@@ -465,7 +493,7 @@ void configuration_impl::load_application_data(
std::size_t its_max_dispatch_time(VSOMEIP_MAX_DISPATCH_TIME);
std::size_t its_io_thread_count(VSOMEIP_IO_THREAD_COUNT);
std::size_t its_request_debounce_time(VSOMEIP_REQUEST_DEBOUNCE_TIME);
- std::map<plugin_type_e, std::string> plugins;
+ std::map<plugin_type_e, std::set<std::string>> plugins;
for (auto i = _tree.begin(); i != _tree.end(); ++i) {
std::string its_key(i->first);
std::string its_value(i->second.data());
@@ -520,7 +548,13 @@ void configuration_impl::load_application_data(
library += ".";
library += (VSOMEIP_APPLICATION_PLUGIN_VERSION + '0');
#endif
- plugins[plugin_type_e::APPLICATION_PLUGIN] = library;
+ plugins[plugin_type_e::APPLICATION_PLUGIN].insert(library);
+ } else if (its_inner_key == "configuration_plugin") {
+ #ifndef _WIN32
+ library += ".";
+ library += (VSOMEIP_PRE_CONFIGURATION_PLUGIN_VERSION + '0');
+ #endif
+ plugins[plugin_type_e::PRE_CONFIGURATION_PLUGIN].insert(library);
} else {
VSOMEIP_WARNING << "Unknown plug-in type ("
<< its_inner_key << ") configured for client: "
@@ -1896,19 +1930,14 @@ bool configuration_impl::get_client_port(
uint16_t _remote_port, bool _reliable,
std::map<bool, std::set<uint16_t> > &_used_client_ports,
uint16_t &_client_port) const {
+ bool is_configured(false);
_client_port = ILLEGAL_PORT;
- auto its_client = find_client(_service, _instance, _remote_port, _reliable);
-
- // If no client ports are configured, return true
- if (!its_client ||
- (its_client->ports_[_reliable].empty()
- && its_client->client_ports_[_reliable].first == ILLEGAL_PORT)) {
- return true;
- }
+ auto its_client = find_client(_service, _instance);
- // specific ports to service / instance are prioritized
- if (!its_client->ports_[_reliable].empty()) {
+ // Check for service, instance specific port configuration
+ if (its_client && !its_client->ports_[_reliable].empty()) {
+ is_configured = true;
for (auto its_port : its_client->ports_[_reliable]) {
// Found free configured port
if (_used_client_ports[_reliable].find(its_port) == _used_client_ports[_reliable].end()) {
@@ -1918,19 +1947,22 @@ bool configuration_impl::get_client_port(
}
}
- // If no client port ranges are configured use auto port assignment
- if (its_client->client_ports_[_reliable].first != ILLEGAL_PORT
- && its_client->client_ports_[_reliable].second != ILLEGAL_PORT) {
- // look for free port in configured client range
- for (uint16_t its_port = its_client->client_ports_[_reliable].first;
- its_port <= its_client->client_ports_[_reliable].second; its_port++ ) {
- if (_used_client_ports[_reliable].find(its_port) == _used_client_ports[_reliable].end()) {
- _client_port = its_port;
- return true;
- }
+ // No specific port configuration found, use generic configuration
+ uint16_t its_port(ILLEGAL_PORT);
+ if (find_port(its_port, _remote_port, _reliable, _used_client_ports)) {
+ is_configured = true;
+ if (its_port != ILLEGAL_PORT) {
+ _client_port = its_port;
+ return true;
}
}
+ if (!is_configured) {
+ // Neither specific not generic configurarion available,
+ // use dynamic port configuration!
+ return true;
+ }
+
// Configured ports do exist, but they are all in use
VSOMEIP_ERROR << "Cannot find free client port for communication to service: "
<< _service << " instance: "
@@ -2119,22 +2151,38 @@ uint8_t configuration_impl::get_threshold(service_t _service,
}
std::shared_ptr<client> configuration_impl::find_client(service_t _service,
- instance_t _instance, uint16_t _remote_port, bool _reliable) const {
- std::shared_ptr<client> its_client;
+ instance_t _instance) const {
std::list<std::shared_ptr<client>>::const_iterator it;
for (it = clients_.begin(); it != clients_.end(); ++it){
// client was configured for specific service / instance
if ((*it)->service_ == _service
&& (*it)->instance_ == _instance) {
- its_client = *it;
- break;
- } else if (is_in_port_range(_remote_port, (*it)->remote_ports_[_reliable])) {
- its_client = *it;
- break;
+ return *it;
}
}
- return its_client;
+ return nullptr;
+}
+
+bool configuration_impl::find_port(uint16_t &_port, uint16_t _remote, bool _reliable,
+ std::map<bool, std::set<uint16_t> > &_used_client_ports) const {
+ bool is_configured(false);
+ std::list<std::shared_ptr<client>>::const_iterator it;
+
+ for (it = clients_.begin(); it != clients_.end(); ++it) {
+ if (is_in_port_range(_remote, (*it)->remote_ports_[_reliable])) {
+ is_configured = true;
+ for (uint16_t its_port = (*it)->client_ports_[_reliable].first;
+ its_port <= (*it)->client_ports_[_reliable].second; its_port++ ) {
+ if (_used_client_ports[_reliable].find(its_port) == _used_client_ports[_reliable].end()) {
+ _port = its_port;
+ return true;
+ }
+ }
+ }
+ }
+
+ return is_configured;
}
bool configuration_impl::is_event_reliable(service_t _service,
@@ -2436,9 +2484,9 @@ bool configuration_impl::is_offer_allowed(client_t _client, service_t _service,
return !check_credentials_;
}
-std::map<plugin_type_e, std::string> configuration_impl::get_plugins(
+std::map<plugin_type_e, std::set<std::string>> configuration_impl::get_plugins(
const std::string &_name) const {
- std::map<plugin_type_e, std::string> result;
+ std::map<plugin_type_e, std::set<std::string>> result;
auto found_application = applications_.find(_name);
if (found_application != applications_.end()) {
@@ -2576,5 +2624,21 @@ std::map<e2exf::data_identifier, std::shared_ptr<cfg::e2e>> configuration_impl::
return e2e_configuration_;
}
+bool configuration_impl::log_memory() const {
+ return log_memory_;
+}
+
+uint32_t configuration_impl::get_log_memory_interval() const {
+ return log_memory_interval_;
+}
+
+bool configuration_impl::log_status() const {
+ return log_status_;
+}
+
+uint32_t configuration_impl::get_log_status_interval() const {
+ return log_status_interval_;
+}
+
} // namespace config
} // namespace vsomeip
diff --git a/implementation/endpoints/include/client_endpoint_impl.hpp b/implementation/endpoints/include/client_endpoint_impl.hpp
index b656f8b..b1bccfa 100644
--- a/implementation/endpoints/include/client_endpoint_impl.hpp
+++ b/implementation/endpoints/include/client_endpoint_impl.hpp
@@ -66,6 +66,7 @@ public:
public:
virtual void connect() = 0;
virtual void receive() = 0;
+ virtual void print_status() = 0;
protected:
virtual void send_queued() = 0;
diff --git a/implementation/endpoints/include/endpoint.hpp b/implementation/endpoints/include/endpoint.hpp
index 94a892e..62fe23b 100644
--- a/implementation/endpoints/include/endpoint.hpp
+++ b/implementation/endpoints/include/endpoint.hpp
@@ -50,6 +50,8 @@ public:
virtual void restart() = 0;
virtual void register_error_handler(error_handler_t _error) = 0;
+
+ virtual void print_status() = 0;
};
} // namespace vsomeip
diff --git a/implementation/endpoints/include/endpoint_impl.hpp b/implementation/endpoints/include/endpoint_impl.hpp
index 3e5ac22..cf98ed1 100644
--- a/implementation/endpoints/include/endpoint_impl.hpp
+++ b/implementation/endpoints/include/endpoint_impl.hpp
@@ -52,6 +52,7 @@ public:
uint32_t get_use_count();
void register_error_handler(error_handler_t _error_handler);
+ virtual void print_status() = 0;
public:
// required
diff --git a/implementation/endpoints/include/local_client_endpoint_impl.hpp b/implementation/endpoints/include/local_client_endpoint_impl.hpp
index 7ff96ff..dc56f23 100644
--- a/implementation/endpoints/include/local_client_endpoint_impl.hpp
+++ b/implementation/endpoints/include/local_client_endpoint_impl.hpp
@@ -47,6 +47,7 @@ public:
std::uint16_t get_remote_port() const;
void restart();
+ void print_status();
private:
void send_queued();
diff --git a/implementation/endpoints/include/local_server_endpoint_impl.hpp b/implementation/endpoints/include/local_server_endpoint_impl.hpp
index 33658fb..458d59f 100644
--- a/implementation/endpoints/include/local_server_endpoint_impl.hpp
+++ b/implementation/endpoints/include/local_server_endpoint_impl.hpp
@@ -67,6 +67,7 @@ public:
bool is_local() const;
void accept_client_func();
+ void print_status();
private:
class connection: public std::enable_shared_from_this<connection> {
@@ -87,6 +88,7 @@ private:
void send_queued(const queue_iterator_type _queue_iterator);
void set_bound_client(client_t _client);
+ std::size_t get_recv_buffer_capacity() const;
private:
connection(std::weak_ptr<local_server_endpoint_impl> _server,
@@ -126,8 +128,9 @@ private:
boost::asio::local::stream_protocol::acceptor acceptor_;
#endif
+ typedef std::map<endpoint_type, connection::ptr> connections_t;
std::mutex connections_mutex_;
- std::map<endpoint_type, connection::ptr> connections_;
+ connections_t connections_;
const std::uint32_t buffer_shrink_threshold_;
private:
diff --git a/implementation/endpoints/include/server_endpoint_impl.hpp b/implementation/endpoints/include/server_endpoint_impl.hpp
index ce89c6b..715c9b8 100644
--- a/implementation/endpoints/include/server_endpoint_impl.hpp
+++ b/implementation/endpoints/include/server_endpoint_impl.hpp
@@ -59,6 +59,8 @@ public:
virtual bool get_default_target(service_t _service,
endpoint_type &_target) const = 0;
+ virtual void print_status() = 0;
+
protected:
std::map<endpoint_type, message_buffer_ptr_t> packetizer_;
queue_type queues_;
diff --git a/implementation/endpoints/include/tcp_client_endpoint_impl.hpp b/implementation/endpoints/include/tcp_client_endpoint_impl.hpp
index e6b0a4a..7ba35aa 100644
--- a/implementation/endpoints/include/tcp_client_endpoint_impl.hpp
+++ b/implementation/endpoints/include/tcp_client_endpoint_impl.hpp
@@ -35,6 +35,7 @@ public:
std::uint16_t get_remote_port() const;
bool is_reliable() const;
bool is_local() const;
+ void print_status();
private:
void send_queued();
diff --git a/implementation/endpoints/include/tcp_server_endpoint_impl.hpp b/implementation/endpoints/include/tcp_server_endpoint_impl.hpp
index 09c2ae5..3d639d9 100644
--- a/implementation/endpoints/include/tcp_server_endpoint_impl.hpp
+++ b/implementation/endpoints/include/tcp_server_endpoint_impl.hpp
@@ -53,7 +53,7 @@ public:
// dummies to implement endpoint_impl interface
// TODO: think about a better design!
void receive();
-
+ void print_status();
private:
class connection: public std::enable_shared_from_this<connection> {
@@ -75,6 +75,8 @@ private:
void send_queued(const queue_iterator_type _queue_iterator);
void set_remote_info(const endpoint_type &_remote);
+ const std::string get_address_port_remote() const;
+ std::size_t get_recv_buffer_capacity() const;
private:
connection(std::weak_ptr<tcp_server_endpoint_impl> _server,
@@ -88,7 +90,6 @@ private:
void receive_cbk(boost::system::error_code const &_error,
std::size_t _bytes);
void calculate_shrink_count();
- const std::string get_address_port_remote() const;
const std::string get_address_port_local() const;
void handle_recv_buffer_exception(const std::exception &_e);
@@ -116,7 +117,8 @@ private:
std::mutex acceptor_mutex_;
boost::asio::ip::tcp::acceptor acceptor_;
std::mutex connections_mutex_;
- std::map<endpoint_type, connection::ptr> connections_;
+ typedef std::map<endpoint_type, connection::ptr> connections_t;
+ connections_t connections_;
const std::uint32_t buffer_shrink_threshold_;
const std::uint16_t local_port_;
diff --git a/implementation/endpoints/include/udp_client_endpoint_impl.hpp b/implementation/endpoints/include/udp_client_endpoint_impl.hpp
index 9f3e9b0..b83e2f1 100644
--- a/implementation/endpoints/include/udp_client_endpoint_impl.hpp
+++ b/implementation/endpoints/include/udp_client_endpoint_impl.hpp
@@ -41,12 +41,14 @@ public:
bool get_remote_address(boost::asio::ip::address &_address) const;
std::uint16_t get_remote_port() const;
bool is_local() const;
-
+ void print_status();
private:
void send_queued();
void connect();
void receive();
void set_local_port();
+ const std::string get_address_port_remote() const;
+ const std::string get_address_port_local() const;
message_buffer_t recv_buffer_;
diff --git a/implementation/endpoints/include/udp_server_endpoint_impl.hpp b/implementation/endpoints/include/udp_server_endpoint_impl.hpp
index aae7a6b..bed7c0c 100644
--- a/implementation/endpoints/include/udp_server_endpoint_impl.hpp
+++ b/implementation/endpoints/include/udp_server_endpoint_impl.hpp
@@ -50,11 +50,12 @@ public:
client_t get_client(std::shared_ptr<endpoint_definition> _endpoint);
-public:
void receive_cbk(boost::system::error_code const &_error,
std::size_t _size,
boost::asio::ip::address const &_destination);
+ void print_status();
+
private:
void set_broadcast();
bool is_joined(const std::string &_address) const;
diff --git a/implementation/endpoints/include/virtual_server_endpoint_impl.hpp b/implementation/endpoints/include/virtual_server_endpoint_impl.hpp
index e8b6258..259e91d 100644
--- a/implementation/endpoints/include/virtual_server_endpoint_impl.hpp
+++ b/implementation/endpoints/include/virtual_server_endpoint_impl.hpp
@@ -52,6 +52,7 @@ public:
void restart();
void register_error_handler(error_handler_t _handler);
+ void print_status();
private:
std::string address_;
diff --git a/implementation/endpoints/src/local_client_endpoint_impl.cpp b/implementation/endpoints/src/local_client_endpoint_impl.cpp
index 52970ca..64b6314 100644
--- a/implementation/endpoints/src/local_client_endpoint_impl.cpp
+++ b/implementation/endpoints/src/local_client_endpoint_impl.cpp
@@ -255,4 +255,24 @@ void local_client_endpoint_impl::set_local_port() {
// local_port_ is set to zero in ctor of client_endpoint_impl -> do nothing
}
+void local_client_endpoint_impl::print_status() {
+#ifndef _WIN32
+ std::string its_path = remote_.path();
+#else
+ std::string its_path("");
+#endif
+ std::size_t its_data_size(0);
+ std::size_t its_queue_size(0);
+ {
+ std::lock_guard<std::mutex> its_lock(mutex_);
+ its_queue_size = queue_.size();
+ for (const auto &m : queue_) {
+ its_data_size += m->size();
+ }
+ }
+
+ VSOMEIP_INFO << "status lce: " << its_path << " queue: "
+ << its_queue_size << " data: " << its_data_size;
+}
+
} // namespace vsomeip
diff --git a/implementation/endpoints/src/local_server_endpoint_impl.cpp b/implementation/endpoints/src/local_server_endpoint_impl.cpp
index aab09cf..cf6d8eb 100644
--- a/implementation/endpoints/src/local_server_endpoint_impl.cpp
+++ b/implementation/endpoints/src/local_server_endpoint_impl.cpp
@@ -153,7 +153,7 @@ void local_server_endpoint_impl::send_queued(
#endif
<< " dropping outstanding messages (" << std::dec
<< _queue_iterator->second.size() << ").";
- _queue_iterator->second.clear();
+ queues_.erase(_queue_iterator->first);
}
}
if (its_connection) {
@@ -629,4 +629,51 @@ void local_server_endpoint_impl::connection::handle_recv_buffer_exception(
}
}
+std::size_t
+local_server_endpoint_impl::connection::get_recv_buffer_capacity() const {
+ return recv_buffer_.capacity();
+}
+
+void local_server_endpoint_impl::print_status() {
+ std::lock_guard<std::mutex> its_lock(mutex_);
+ connections_t its_connections;
+ {
+ std::lock_guard<std::mutex> its_lock(connections_mutex_);
+ its_connections = connections_;
+ }
+#ifndef _WIN32
+ std::string its_local_path(local_.path());
+#else
+ std::string its_local_path("");
+#endif
+ VSOMEIP_INFO << "status lse: " << its_local_path << " connections: "
+ << std::dec << its_connections.size() << " queues: "
+ << std::dec << queues_.size();
+ for (const auto &c : its_connections) {
+#ifndef _WIN32
+ std::string its_remote_path(c.first.path());
+#else
+ std::string its_remote_path("");
+#endif
+ std::size_t its_data_size(0);
+ std::size_t its_queue_size(0);
+ std::size_t its_recv_size(0);
+ {
+ std::unique_lock<std::mutex> c_s_lock(c.second->get_socket_lock());
+ its_recv_size = c.second->get_recv_buffer_capacity();
+ }
+ auto found_queue = queues_.find(c.first);
+ if (found_queue != queues_.end()) {
+ its_queue_size = found_queue->second.size();
+ for (const auto &m : found_queue->second) {
+ its_data_size += m->size();
+ }
+ }
+ VSOMEIP_INFO << "status lse: client: " << its_remote_path
+ << " queue: " << std::dec << its_queue_size
+ << " data: " << std::dec << its_data_size
+ << " recv_buffer: " << std::dec << its_recv_size;
+ }
+}
+
} // namespace vsomeip
diff --git a/implementation/endpoints/src/server_endpoint_impl.cpp b/implementation/endpoints/src/server_endpoint_impl.cpp
index 39c6be2..8ffbfdb 100644
--- a/implementation/endpoints/src/server_endpoint_impl.cpp
+++ b/implementation/endpoints/src/server_endpoint_impl.cpp
@@ -212,7 +212,7 @@ void server_endpoint_impl<Protocol>::send_cbk(
} else {
// error: sending of outstanding responses isn't started again
// delete remaining outstanding responses
- _queue_iterator->second.clear();
+ queues_.erase(_queue_iterator);
}
}
diff --git a/implementation/endpoints/src/tcp_client_endpoint_impl.cpp b/implementation/endpoints/src/tcp_client_endpoint_impl.cpp
index 17c96c2..6a5df88 100644
--- a/implementation/endpoints/src/tcp_client_endpoint_impl.cpp
+++ b/implementation/endpoints/src/tcp_client_endpoint_impl.cpp
@@ -493,4 +493,29 @@ void tcp_client_endpoint_impl::handle_recv_buffer_exception(
}
}
+void tcp_client_endpoint_impl::print_status() {
+ std::size_t its_data_size(0);
+ std::size_t its_queue_size(0);
+ std::size_t its_receive_buffer_capacity(0);
+ {
+ std::lock_guard<std::mutex> its_lock(mutex_);
+ its_queue_size = queue_.size();
+ for (const auto &m : queue_) {
+ its_data_size += m->size();
+ }
+ }
+ std::string local;
+ {
+ std::lock_guard<std::mutex> its_lock(socket_mutex_);
+ local = get_address_port_local();
+ its_receive_buffer_capacity = recv_buffer_.capacity();
+ }
+
+ VSOMEIP_INFO << "status tce: " << local << " -> "
+ << get_address_port_remote()
+ << " queue: " << std::dec << its_queue_size
+ << " data: " << std::dec << its_data_size
+ << " recv_buffer: " << std::dec << its_receive_buffer_capacity;
+}
+
} // namespace vsomeip
diff --git a/implementation/endpoints/src/tcp_server_endpoint_impl.cpp b/implementation/endpoints/src/tcp_server_endpoint_impl.cpp
index dda45bf..2392f58 100644
--- a/implementation/endpoints/src/tcp_server_endpoint_impl.cpp
+++ b/implementation/endpoints/src/tcp_server_endpoint_impl.cpp
@@ -108,7 +108,7 @@ void tcp_server_endpoint_impl::send_queued(const queue_iterator_type _queue_iter
<< static_cast<std::uint16_t>(_queue_iterator->first.port())
<< " dropping outstanding messages (" << std::dec
<< _queue_iterator->second.size() << ").";
- _queue_iterator->second.clear();
+ queues_.erase(_queue_iterator->first);
}
}
if (its_connection) {
@@ -625,9 +625,48 @@ void tcp_server_endpoint_impl::connection::handle_recv_buffer_exception(
}
}
+std::size_t
+tcp_server_endpoint_impl::connection::get_recv_buffer_capacity() const {
+ return recv_buffer_.capacity();
+}
+
// Dummies
void tcp_server_endpoint_impl::receive() {
// intentionally left empty
}
+void tcp_server_endpoint_impl::print_status() {
+ std::lock_guard<std::mutex> its_lock(mutex_);
+ connections_t its_connections;
+ {
+ std::lock_guard<std::mutex> its_lock(connections_mutex_);
+ its_connections = connections_;
+ }
+
+ VSOMEIP_INFO << "status tse: " << std::dec << local_port_
+ << " connections: " << std::dec << its_connections.size()
+ << " queues: " << std::dec << queues_.size();
+ for (const auto &c : its_connections) {
+ std::size_t its_data_size(0);
+ std::size_t its_queue_size(0);
+ std::size_t its_recv_size(0);
+ {
+ std::unique_lock<std::mutex> c_s_lock(c.second->get_socket_lock());
+ its_recv_size = c.second->get_recv_buffer_capacity();
+ }
+ auto found_queue = queues_.find(c.first);
+ if (found_queue != queues_.end()) {
+ its_queue_size = found_queue->second.size();
+ for (const auto &m : found_queue->second) {
+ its_data_size += m->size();
+ }
+ }
+ VSOMEIP_INFO << "status tse: client: "
+ << c.second->get_address_port_remote()
+ << " queue: " << std::dec << its_queue_size
+ << " data: " << std::dec << its_data_size
+ << " recv_buffer: " << std::dec << its_recv_size;
+ }
+}
+
} // namespace vsomeip
diff --git a/implementation/endpoints/src/udp_client_endpoint_impl.cpp b/implementation/endpoints/src/udp_client_endpoint_impl.cpp
index ec4106d..28a4888 100644
--- a/implementation/endpoints/src/udp_client_endpoint_impl.cpp
+++ b/implementation/endpoints/src/udp_client_endpoint_impl.cpp
@@ -222,4 +222,54 @@ void udp_client_endpoint_impl::receive_cbk(
}
}
+const std::string udp_client_endpoint_impl::get_address_port_remote() const {
+ boost::system::error_code ec;
+ std::string its_address_port;
+ its_address_port.reserve(21);
+ boost::asio::ip::address its_address;
+ if (get_remote_address(its_address)) {
+ its_address_port += its_address.to_string();
+ }
+ its_address_port += ":";
+ its_address_port += std::to_string(remote_port_);
+ return its_address_port;
+}
+
+const std::string udp_client_endpoint_impl::get_address_port_local() const {
+ std::string its_address_port;
+ its_address_port.reserve(21);
+ boost::system::error_code ec;
+ if (socket_->is_open()) {
+ endpoint_type its_local_endpoint = socket_->local_endpoint(ec);
+ if (!ec) {
+ its_address_port += its_local_endpoint.address().to_string(ec);
+ its_address_port += ":";
+ its_address_port.append(std::to_string(its_local_endpoint.port()));
+ }
+ }
+ return its_address_port;
+}
+
+void udp_client_endpoint_impl::print_status() {
+ std::size_t its_data_size(0);
+ std::size_t its_queue_size(0);
+ {
+ std::lock_guard<std::mutex> its_lock(mutex_);
+ its_queue_size = queue_.size();
+ for (const auto &m : queue_) {
+ its_data_size += m->size();
+ }
+ }
+ std::string local;
+ {
+ std::lock_guard<std::mutex> its_lock(socket_mutex_);
+ local = get_address_port_local();
+ }
+
+ VSOMEIP_INFO << "status uce: " << local << " -> "
+ << get_address_port_remote()
+ << " queue: " << std::dec << its_queue_size
+ << " data: " << std::dec << its_data_size;
+}
+
} // namespace vsomeip
diff --git a/implementation/endpoints/src/udp_server_endpoint_impl.cpp b/implementation/endpoints/src/udp_server_endpoint_impl.cpp
index 7de96b4..b712266 100644
--- a/implementation/endpoints/src/udp_server_endpoint_impl.cpp
+++ b/implementation/endpoints/src/udp_server_endpoint_impl.cpp
@@ -395,4 +395,27 @@ client_t udp_server_endpoint_impl::get_client(std::shared_ptr<endpoint_definitio
return 0;
}
+void udp_server_endpoint_impl::print_status() {
+ std::lock_guard<std::mutex> its_lock(mutex_);
+
+ VSOMEIP_INFO << "status use: " << std::dec << local_port_
+ << " number queues: " << std::dec << queues_.size()
+ << " recv_buffer: " << std::dec << recv_buffer_.capacity();
+
+ for (const auto &c : queues_) {
+ std::size_t its_data_size(0);
+ std::size_t its_queue_size(0);
+ its_queue_size = c.second.size();
+ for (const auto &m : c.second) {
+ its_data_size += m->size();
+ }
+ boost::system::error_code ec;
+ VSOMEIP_INFO << "status use: client: "
+ << c.first.address().to_string(ec) << ":"
+ << std::dec << c.first.port()
+ << " queue: " << std::dec << its_queue_size
+ << " data: " << std::dec << its_data_size;
+ }
+}
+
} // namespace vsomeip
diff --git a/implementation/endpoints/src/virtual_server_endpoint_impl.cpp b/implementation/endpoints/src/virtual_server_endpoint_impl.cpp
index 6db9bc1..74bbab6 100644
--- a/implementation/endpoints/src/virtual_server_endpoint_impl.cpp
+++ b/implementation/endpoints/src/virtual_server_endpoint_impl.cpp
@@ -118,4 +118,8 @@ void virtual_server_endpoint_impl::register_error_handler(
(void)_handler;
}
+void virtual_server_endpoint_impl::print_status() {
+
+}
+
} // namespace vsomeip
diff --git a/implementation/plugin/include/plugin_manager.hpp b/implementation/plugin/include/plugin_manager.hpp
index 75ae8d7..98afd72 100644
--- a/implementation/plugin/include/plugin_manager.hpp
+++ b/implementation/plugin/include/plugin_manager.hpp
@@ -27,7 +27,7 @@ public:
VSOMEIP_EXPORT void load_plugins();
- VSOMEIP_EXPORT std::shared_ptr<plugin> get_plugin(plugin_type_e _type);
+ VSOMEIP_EXPORT std::shared_ptr<plugin> get_plugin(plugin_type_e _type, std::string _name);
VSOMEIP_EXPORT std::shared_ptr<plugin> load_plugin(
const std::string _library, plugin_type_e _type,
@@ -36,7 +36,7 @@ public:
VSOMEIP_EXPORT bool unload_plugin(plugin_type_e _type);
private:
- void add_plugin(const std::shared_ptr<plugin> &_plugin);
+ void add_plugin(const std::shared_ptr<plugin> &_plugin, const std::string _name);
void * load_library(const std::string &_path);
void * load_symbol(void * _handle, const std::string &_symbol);
@@ -44,9 +44,8 @@ private:
bool plugins_loaded_;
std::mutex loader_mutex_;
- std::map<plugin_type_e, std::vector<std::shared_ptr<plugin> > > plugins_;
- std::map<plugin_type_e, std::string> plugin_names_;
- std::map<plugin_type_e, void*> handles_;
+ std::map<plugin_type_e, std::map<std::string, std::shared_ptr<plugin> > > plugins_;
+ std::map<plugin_type_e, std::map<std::string, void*> > handles_;
std::mutex plugins_mutex_;
static std::shared_ptr<plugin_manager> the_plugin_manager__;
diff --git a/implementation/plugin/src/plugin_manager.cpp b/implementation/plugin/src/plugin_manager.cpp
index f81d7b2..e922fd6 100644
--- a/implementation/plugin/src/plugin_manager.cpp
+++ b/implementation/plugin/src/plugin_manager.cpp
@@ -35,14 +35,11 @@ std::shared_ptr<plugin_manager> plugin_manager::get() {
plugin_manager::plugin_manager() :
plugins_loaded_(false) {
- plugin_names_[plugin_type_e::CONFIGURATION_PLUGIN] = VSOMEIP_CFG_LIBRARY;
- plugin_names_[plugin_type_e::SD_RUNTIME_PLUGIN] = VSOMEIP_SD_LIBRARY;
}
plugin_manager::~plugin_manager() {
handles_.clear();
plugins_.clear();
- plugin_names_.clear();
}
void plugin_manager::load_plugins() {
@@ -76,12 +73,12 @@ void plugin_manager::load_plugins() {
if (its_create_func) {
auto its_plugin = (*its_create_func)();
if (its_plugin) {
- handles_[its_plugin->get_plugin_type()] = handle;
+ handles_[its_plugin->get_plugin_type()][plugin_name] = handle;
switch (its_plugin->get_plugin_type()) {
case plugin_type_e::APPLICATION_PLUGIN:
if (its_plugin->get_plugin_version()
== VSOMEIP_APPLICATION_PLUGIN_VERSION) {
- add_plugin(its_plugin);
+ add_plugin(its_plugin, plugin_name);
} else {
VSOMEIP_ERROR << "Plugin version mismatch. "
<< "Ignoring application plugin "
@@ -91,7 +88,7 @@ void plugin_manager::load_plugins() {
case plugin_type_e::PRE_CONFIGURATION_PLUGIN:
if (its_plugin->get_plugin_version()
== VSOMEIP_PRE_CONFIGURATION_PLUGIN_VERSION) {
- add_plugin(its_plugin);
+ add_plugin(its_plugin, plugin_name);
} else {
VSOMEIP_ERROR << "Plugin version mismatch. Ignoring "
<< "pre-configuration plugin "
@@ -107,17 +104,16 @@ void plugin_manager::load_plugins() {
}
}
-std::shared_ptr<plugin> plugin_manager::get_plugin(plugin_type_e _type) {
+std::shared_ptr<plugin> plugin_manager::get_plugin(plugin_type_e _type, std::string _name) {
std::lock_guard<std::mutex> its_lock_start_stop(plugins_mutex_);
- if (plugins_[_type].size()) {
- return plugins_[_type][0];
- } else {
- auto its_name = plugin_names_.find(_type);
- if (its_name != plugin_names_.end()) {
- return load_plugin(its_name->second, _type, 1);
+ auto its_type = plugins_.find(_type);
+ if (its_type != plugins_.end()) {
+ auto its_name = its_type->second.find(_name);
+ if (its_name != its_type->second.end()) {
+ return its_name->second;
}
}
- return nullptr;
+ return load_plugin(_name, _type, 1);
}
std::shared_ptr<plugin> plugin_manager::load_plugin(const std::string _library,
@@ -128,12 +124,12 @@ std::shared_ptr<plugin> plugin_manager::load_plugin(const std::string _library,
if (its_init_func) {
create_plugin_func its_create_func = (*its_init_func)();
if (its_create_func) {
- handles_[_type] = handle;
+ handles_[_type][_library] = handle;
auto its_plugin = (*its_create_func)();
if (its_plugin) {
if (its_plugin->get_plugin_type() == _type
&& its_plugin->get_plugin_version() == _version) {
- add_plugin(its_plugin);
+ add_plugin(its_plugin, _library);
return its_plugin;
} else {
VSOMEIP_ERROR << "Plugin version mismatch. Ignoring plugin "
@@ -149,13 +145,15 @@ bool plugin_manager::unload_plugin(plugin_type_e _type) {
std::lock_guard<std::mutex> its_lock_start_stop(plugins_mutex_);
const auto found_handle = handles_.find(_type);
if (found_handle != handles_.end()) {
+ for (auto its_name : found_handle->second) {
#ifdef _WIN32
- FreeLibrary((HMODULE)found_handle->second);
+ FreeLibrary((HMODULE)its_name.second);
#else
- if (dlclose(found_handle->second)) {
- VSOMEIP_ERROR << "Unloading failed: (" << dlerror() << ")";
- }
+ if (dlclose(its_name.second)) {
+ VSOMEIP_ERROR << "Unloading failed: (" << dlerror() << ")";
+ }
#endif
+ }
} else {
VSOMEIP_ERROR << "plugin_manager::unload_plugin didn't find plugin"
<< " type:" << (int)_type;
@@ -164,8 +162,8 @@ bool plugin_manager::unload_plugin(plugin_type_e _type) {
return plugins_.erase(_type);
}
-void plugin_manager::add_plugin(const std::shared_ptr<plugin> &_plugin) {
- plugins_[_plugin->get_plugin_type()].push_back(_plugin);
+void plugin_manager::add_plugin(const std::shared_ptr<plugin> &_plugin, const std::string _name) {
+ plugins_[_plugin->get_plugin_type()][_name] = _plugin;
}
void * plugin_manager::load_library(const std::string &_path) {
diff --git a/implementation/routing/include/routing_manager_base.hpp b/implementation/routing/include/routing_manager_base.hpp
index 36b6672..c134d7b 100644
--- a/implementation/routing/include/routing_manager_base.hpp
+++ b/implementation/routing/include/routing_manager_base.hpp
@@ -193,6 +193,8 @@ protected:
void send_identify_request(service_t _service, instance_t _instance,
major_version_t _major, bool _reliable);
+ std::map<client_t, std::shared_ptr<endpoint>> get_local_endpoints();
+
private:
std::shared_ptr<endpoint> create_local_unlocked(client_t _client);
std::shared_ptr<endpoint> find_local_unlocked(client_t _client);
diff --git a/implementation/routing/include/routing_manager_impl.hpp b/implementation/routing/include/routing_manager_impl.hpp
index 6969069..dbdf2b9 100644
--- a/implementation/routing/include/routing_manager_impl.hpp
+++ b/implementation/routing/include/routing_manager_impl.hpp
@@ -189,7 +189,7 @@ public:
uint16_t _unreliable_port);
void del_routing_info(service_t _service, instance_t _instance,
bool _has_reliable, bool _has_unreliable);
- std::chrono::milliseconds update_routing_info(std::chrono::milliseconds _elapsed);
+ void update_routing_info(std::chrono::milliseconds _elapsed);
remote_subscription_state_e on_remote_subscription(
service_t _service, instance_t _instance, eventgroup_t _eventgroup,
@@ -351,11 +351,16 @@ private:
client_t is_specific_endpoint_client(client_t _client, service_t _service, instance_t _instance);
std::unordered_set<client_t> get_specific_endpoint_clients(service_t _service, instance_t _instance);
+ void memory_log_timer_cbk(boost::system::error_code const & _error);
+ void status_log_timer_cbk(boost::system::error_code const & _error);
+
+
std::shared_ptr<routing_manager_stub> stub_;
std::shared_ptr<sd::service_discovery> discovery_;
// Server endpoints for local services
- std::map<uint16_t, std::map<bool, std::shared_ptr<endpoint> > > server_endpoints_;
+ typedef std::map<uint16_t, std::map<bool, std::shared_ptr<endpoint>>> server_endpoints_t;
+ server_endpoints_t server_endpoints_;
std::map<service_t, std::map<endpoint *, instance_t> > service_instances_;
// Multicast endpoint info (notifications)
@@ -365,10 +370,13 @@ private:
std::map<service_t,
std::map<instance_t, std::map<bool, std::shared_ptr<endpoint_definition> > > > remote_service_info_;
- std::map<service_t,
- std::map<instance_t, std::map<client_t, std::map<bool, std::shared_ptr<endpoint> > > > >remote_services_;
- std::map<boost::asio::ip::address,
- std::map<uint16_t, std::map<bool, std::shared_ptr<endpoint> > > > client_endpoints_by_ip_;
+ typedef std::map<service_t, std::map<instance_t, std::map<client_t,
+ std::map<bool, std::shared_ptr<endpoint>>>>> remote_services_t;
+ remote_services_t remote_services_;
+
+ typedef std::map<boost::asio::ip::address, std::map<uint16_t,
+ std::map<bool, std::shared_ptr<endpoint>>>> client_endpoints_by_ip_t;
+ client_endpoints_by_ip_t client_endpoints_by_ip_;
std::map<client_t,
std::map<service_t,
std::map<instance_t,
@@ -428,6 +436,12 @@ private:
std::map<e2exf::data_identifier, std::shared_ptr<e2e::profile_interface::protector>> custom_protectors;
std::map<e2exf::data_identifier, std::shared_ptr<e2e::profile_interface::checker>> custom_checkers;
+
+ std::mutex status_log_timer_mutex_;
+ boost::asio::steady_timer status_log_timer_;
+
+ std::mutex memory_log_timer_mutex_;
+ boost::asio::steady_timer memory_log_timer_;
};
} // namespace vsomeip
diff --git a/implementation/routing/include/routing_manager_stub.hpp b/implementation/routing/include/routing_manager_stub.hpp
index d4eb962..ec5dd4e 100644
--- a/implementation/routing/include/routing_manager_stub.hpp
+++ b/implementation/routing/include/routing_manager_stub.hpp
@@ -94,6 +94,7 @@ public:
void update_registration(client_t _client, registration_type_e _type);
+ void print_endpoint_status() const;
private:
void broadcast(const std::vector<byte_t> &_command) const;
diff --git a/implementation/routing/src/eventgroupinfo.cpp b/implementation/routing/src/eventgroupinfo.cpp
index 2d54516..1432aa2 100644
--- a/implementation/routing/src/eventgroupinfo.cpp
+++ b/implementation/routing/src/eventgroupinfo.cpp
@@ -150,13 +150,23 @@ bool eventgroupinfo::add_target(const eventgroupinfo::target_t &_target) {
bool eventgroupinfo::add_target(const eventgroupinfo::target_t &_target,
const eventgroupinfo::target_t &_subscriber) {
+ bool found(false);
bool add(false);
bool ret(false);
{
std::lock_guard<std::mutex> its_lock(targets_mutex_);
std::size_t its_size = targets_.size();
- if (std::find(targets_.begin(), targets_.end(), _subscriber)
- == targets_.end()) {
+
+ for (auto i = targets_.begin(); i != targets_.end(); i++) {
+ if (i->endpoint_->get_address() == _subscriber.endpoint_->get_address() &&
+ i->endpoint_->get_port() == _subscriber.endpoint_->get_port() &&
+ i->endpoint_->is_reliable() == _subscriber.endpoint_->is_reliable()) {
+ found = true;
+ break;
+ }
+ }
+
+ if (!found) {
targets_.push_back(_subscriber);
add = true;
}
@@ -172,14 +182,18 @@ bool eventgroupinfo::update_target(
const std::shared_ptr<endpoint_definition> &_target,
const std::chrono::steady_clock::time_point &_expiration) {
std::lock_guard<std::mutex> its_lock(targets_mutex_);
- for (auto i = targets_.begin(); i != targets_.end(); i++) {
- if (i->endpoint_->get_address() == _target->get_address() &&
- i->endpoint_->get_port() == _target->get_port()) {
- i->expiration_ = _expiration;
- return true;
- }
- }
- return false;
+ bool updated_target(false);
+
+ for (auto i = targets_.begin(); i != targets_.end(); i++) {
+ if (i->endpoint_->get_address() == _target->get_address() &&
+ i->endpoint_->get_port() == _target->get_port() &&
+ i->endpoint_->is_reliable() == _target->is_reliable() ) {
+ i->expiration_ = _expiration;
+ updated_target = true;
+ break;
+ }
+ }
+ return updated_target;
}
bool eventgroupinfo::remove_target(
@@ -188,7 +202,9 @@ bool eventgroupinfo::remove_target(
std::size_t its_size = targets_.size();
for (auto i = targets_.begin(); i != targets_.end(); i++) {
- if (i->endpoint_ == _target) {
+ if (i->endpoint_->get_address() == _target->get_address() &&
+ i->endpoint_->get_port() == _target->get_port() &&
+ i->endpoint_->is_reliable() == _target->is_reliable()) {
targets_.erase(i);
break;
}
diff --git a/implementation/routing/src/routing_manager_base.cpp b/implementation/routing/src/routing_manager_base.cpp
index 7b45889..9036e5a 100644
--- a/implementation/routing/src/routing_manager_base.cpp
+++ b/implementation/routing/src/routing_manager_base.cpp
@@ -1099,4 +1099,10 @@ void routing_manager_base::send_identify_request(service_t _service,
host_->send(message, true);
}
+std::map<client_t, std::shared_ptr<endpoint>>
+routing_manager_base::get_local_endpoints() {
+ std::lock_guard<std::mutex> its_lock(local_endpoint_mutex_);
+ return local_endpoints_;
+}
+
} // namespace vsomeip
diff --git a/implementation/routing/src/routing_manager_impl.cpp b/implementation/routing/src/routing_manager_impl.cpp
index 2405b8a..34398ad 100644
--- a/implementation/routing/src/routing_manager_impl.cpp
+++ b/implementation/routing/src/routing_manager_impl.cpp
@@ -9,6 +9,12 @@
#include <sstream>
#include <forward_list>
+#ifndef _WIN32
+#include <unistd.h>
+#include <cstdio>
+#include <time.h>
+#endif
+
#ifndef WITHOUT_SYSTEMD
#include <systemd/sd-daemon.h>
#endif
@@ -62,10 +68,12 @@ namespace vsomeip {
routing_manager_impl::routing_manager_impl(routing_manager_host *_host) :
routing_manager_base(_host),
version_log_timer_(_host->get_io()),
- if_state_running_(false)
+ if_state_running_(false),
#ifndef WITHOUT_SYSTEMD
- , watchdog_timer_(_host->get_io())
+ watchdog_timer_(_host->get_io()),
#endif
+ status_log_timer_(_host->get_io()),
+ memory_log_timer_(_host->get_io())
{
}
@@ -93,7 +101,7 @@ void routing_manager_impl::init() {
if (configuration_->is_sd_enabled()) {
VSOMEIP_INFO<< "Service Discovery enabled. Trying to load module.";
auto its_plugin = plugin_manager::get()->get_plugin(
- plugin_type_e::SD_RUNTIME_PLUGIN);
+ plugin_type_e::SD_RUNTIME_PLUGIN, VSOMEIP_SD_LIBRARY);
if (its_plugin) {
VSOMEIP_INFO << "Service Discovery module loaded.";
discovery_ = std::dynamic_pointer_cast<sd::runtime>(its_plugin)->create_service_discovery(this);
@@ -162,6 +170,24 @@ void routing_manager_impl::start() {
this, std::placeholders::_1));
}
#endif
+#ifndef _WIN32
+ if (configuration_->log_memory()) {
+ std::lock_guard<std::mutex> its_lock(memory_log_timer_mutex_);
+ boost::system::error_code ec;
+ memory_log_timer_.expires_from_now(std::chrono::seconds(0), ec);
+ memory_log_timer_.async_wait(
+ std::bind(&routing_manager_impl::memory_log_timer_cbk, this,
+ std::placeholders::_1));
+ }
+#endif
+ if (configuration_->log_status()) {
+ std::lock_guard<std::mutex> its_lock(status_log_timer_mutex_);
+ boost::system::error_code ec;
+ status_log_timer_.expires_from_now(std::chrono::seconds(0), ec);
+ status_log_timer_.async_wait(
+ std::bind(&routing_manager_impl::status_log_timer_cbk, this,
+ std::placeholders::_1));
+ }
}
void routing_manager_impl::stop() {
@@ -170,11 +196,21 @@ void routing_manager_impl::stop() {
version_log_timer_.cancel();
}
#ifndef _WIN32
+ {
+ boost::system::error_code ec;
+ std::lock_guard<std::mutex> its_lock(memory_log_timer_mutex_);
+ memory_log_timer_.cancel(ec);
+ }
if (netlink_connector_) {
netlink_connector_->stop();
}
#endif
+ {
+ std::lock_guard<std::mutex> its_lock(status_log_timer_mutex_);
+ boost::system::error_code ec;
+ status_log_timer_.cancel(ec);
+ }
#ifndef WITHOUT_SYSTEMD
{
std::lock_guard<std::mutex> its_lock(watchdog_timer_mutex_);
@@ -2275,10 +2311,7 @@ void routing_manager_impl::del_routing_info(service_t _service, instance_t _inst
}
}
-std::chrono::milliseconds routing_manager_impl::update_routing_info(std::chrono::milliseconds _elapsed) {
- const std::chrono::seconds default_ttl(DEFAULT_TTL);
- std::chrono::milliseconds its_smallest_ttl =
- std::chrono::duration_cast<std::chrono::milliseconds>(default_ttl);
+void routing_manager_impl::update_routing_info(std::chrono::milliseconds _elapsed) {
std::map<service_t, std::vector<instance_t> > its_expired_offers;
{
@@ -2294,8 +2327,6 @@ std::chrono::milliseconds routing_manager_impl::update_routing_info(std::chrono:
} else {
std::chrono::milliseconds its_new_ttl(precise_ttl - _elapsed);
i.second->set_precise_ttl(its_new_ttl);
- if (its_smallest_ttl > its_new_ttl)
- its_smallest_ttl = its_new_ttl;
}
}
}
@@ -2309,11 +2340,11 @@ std::chrono::milliseconds routing_manager_impl::update_routing_info(std::chrono:
}
del_routing_info(s.first, i, true, true);
VSOMEIP_INFO << "update_routing_info: elapsed=" << _elapsed.count()
- << " : delete service/instance " << std::hex << s.first << "/" << i;
+ << " : delete service/instance "
+ << std::hex << std::setw(4) << std::setfill('0') << s.first
+ << "." << std::hex << std::setw(4) << std::setfill('0') << i;
}
}
-
- return its_smallest_ttl;
}
void routing_manager_impl::expire_services(const boost::asio::ip::address &_address) {
@@ -2355,7 +2386,9 @@ void routing_manager_impl::expire_services(const boost::asio::ip::address &_addr
for (auto &s : its_expired_offers) {
for (auto &i : s.second) {
VSOMEIP_INFO << "expire_services for address: " << _address.to_string()
- << " : delete service/instance " << std::hex << s.first << "/" << i;
+ << " : delete service/instance "
+ << std::hex << std::setw(4) << std::setfill('0') << s.first
+ << "." << std::hex << std::setw(4) << std::setfill('0') << i;
del_routing_info(s.first, i, true, true);
}
}
@@ -2637,6 +2670,7 @@ void routing_manager_impl::on_subscribe_ack(client_t _client,
if (find_local_client(_service, _instance) == VSOMEIP_ROUTING_CLIENT) {
// service was stopped while subscription was pending
// send subscribe_nack back instead
+ eventgroup_lock.unlock();
on_subscribe_nack(_client, _service, _instance, _eventgroup,
_event, _subscription_id);
return;
@@ -4125,4 +4159,151 @@ void routing_manager_impl::send_initial_events(
}
}
+void routing_manager_impl::memory_log_timer_cbk(
+ boost::system::error_code const & _error) {
+ if (_error) {
+ return;
+ }
+#ifndef _WIN32
+ static const std::uint32_t its_pagesize = getpagesize() / 1024;
+#else
+ static const std::uint32_t its_pagesize = 4096 / 1024;
+#endif
+ std::FILE *its_file = std::fopen("/proc/self/statm", "r");
+ if (!its_file) {
+ VSOMEIP_ERROR << "memory_log_timer_cbk: couldn't open:"
+ << std::string(std::strerror(errno));
+ return;
+ }
+ std::uint64_t its_size(0);
+ std::uint64_t its_rsssize(0);
+ std::uint64_t its_sharedpages(0);
+ std::uint64_t its_text(0);
+ std::uint64_t its_lib(0);
+ std::uint64_t its_data(0);
+ std::uint64_t its_dirtypages(0);
+
+ if (EOF == std::fscanf(its_file, "%lu %lu %lu %lu %lu %lu %lu", &its_size,
+ &its_rsssize, &its_sharedpages, &its_text, &its_lib,
+ &its_data, &its_dirtypages)) {
+ VSOMEIP_ERROR<< "memory_log_timer_cbk: error reading:"
+ << std::string(std::strerror(errno));
+ }
+ std::fclose(its_file);
+#ifndef _WIN32
+ struct timespec cputs, monots;
+ clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &cputs);
+ clock_gettime(CLOCK_MONOTONIC, &monots);
+#endif
+
+ VSOMEIP_INFO << "memory usage: "
+ << "VmSize " << std::dec << its_size * its_pagesize << " kB, "
+ << "VmRSS " << std::dec << its_rsssize * its_pagesize << " kB, "
+ << "shared pages " << std::dec << its_sharedpages * its_pagesize << " kB, "
+ << "text " << std::dec << its_text * its_pagesize << " kB, "
+ << "data " << std::dec << its_data * its_pagesize << " kB "
+#ifndef _WIN32
+ << "| monotonic time: " << std::dec << monots.tv_sec << "."
+ << std::dec << monots.tv_nsec << " cpu time: "
+ << std::dec << cputs.tv_sec << "." << std::dec << cputs.tv_nsec
+#endif
+ ;
+
+ {
+ std::lock_guard<std::mutex> its_lock(memory_log_timer_mutex_);
+ boost::system::error_code ec;
+ memory_log_timer_.expires_from_now(std::chrono::seconds(
+ configuration_->get_log_memory_interval()), ec);
+ memory_log_timer_.async_wait(
+ std::bind(&routing_manager_impl::memory_log_timer_cbk, this,
+ std::placeholders::_1));
+ }
+}
+
+void routing_manager_impl::status_log_timer_cbk(
+ boost::system::error_code const & _error) {
+ if (_error) {
+ return;
+ }
+
+ // local client endpoints
+ {
+ std::map<client_t, std::shared_ptr<endpoint>> lces = get_local_endpoints();
+ VSOMEIP_INFO << "status local client endpoints: " << std::dec << lces.size();
+ for (const auto lce : lces) {
+ lce.second->print_status();
+ }
+ }
+
+ // udp and tcp client endpoints
+ {
+ client_endpoints_by_ip_t client_endpoints_by_ip;
+ remote_services_t remote_services;
+ server_endpoints_t server_endpoints;
+ {
+ std::lock_guard<std::recursive_mutex> its_lock(endpoint_mutex_);
+ client_endpoints_by_ip = client_endpoints_by_ip_;
+ remote_services = remote_services_;
+ server_endpoints = server_endpoints_;
+ }
+ VSOMEIP_INFO << "status start remote client endpoints:";
+ std::uint32_t num_remote_client_endpoints(0);
+ // normal endpoints
+ for (const auto &a : client_endpoints_by_ip) {
+ for (const auto p : a.second) {
+ for (const auto ru : p.second) {
+ ru.second->print_status();
+ num_remote_client_endpoints++;
+ }
+ }
+ }
+ VSOMEIP_INFO << "status end remote client endpoints: " << std::dec
+ << num_remote_client_endpoints;
+
+ // selective client endpoints
+ VSOMEIP_INFO << "status start selective remote client endpoints:";
+ std::uint32_t num_remote_selectiv_client_endpoints(0);
+ for (const auto s : remote_services) {
+ for (const auto i : s.second) {
+ for (const auto c : i.second) {
+ if (c.first != VSOMEIP_ROUTING_CLIENT) {
+ for (const auto ur : c.second) {
+ ur.second->print_status();
+ num_remote_selectiv_client_endpoints++;
+ }
+ }
+ }
+ }
+ }
+ VSOMEIP_INFO << "status end selective remote client endpoints: "
+ << std::dec << num_remote_selectiv_client_endpoints;
+
+ VSOMEIP_INFO << "status start server endpoints:";
+ std::uint32_t num_server_endpoints(1);
+ // local server endpoints
+ stub_->print_endpoint_status();
+
+ // server endpoints
+ for (const auto p : server_endpoints) {
+ for (const auto ru : p.second ) {
+ ru.second->print_status();
+ num_server_endpoints++;
+ }
+ }
+ VSOMEIP_INFO << "status end server endpoints:"
+ << std::dec << num_server_endpoints;
+ }
+
+
+ {
+ std::lock_guard<std::mutex> its_lock(status_log_timer_mutex_);
+ boost::system::error_code ec;
+ status_log_timer_.expires_from_now(std::chrono::seconds(
+ configuration_->get_log_status_interval()), ec);
+ status_log_timer_.async_wait(
+ std::bind(&routing_manager_impl::status_log_timer_cbk, this,
+ std::placeholders::_1));
+ }
+}
+
} // namespace vsomeip
diff --git a/implementation/routing/src/routing_manager_stub.cpp b/implementation/routing/src/routing_manager_stub.cpp
index d6099cc..08a91c7 100644
--- a/implementation/routing/src/routing_manager_stub.cpp
+++ b/implementation/routing/src/routing_manager_stub.cpp
@@ -1799,4 +1799,13 @@ void routing_manager_stub::on_client_id_timer_expired(boost::system::error_code
}
}
+void routing_manager_stub::print_endpoint_status() const {
+ if (local_receiver_) {
+ local_receiver_->print_status();
+ }
+ if (endpoint_) {
+ endpoint_->print_status();
+ }
+}
+
} // namespace vsomeip
diff --git a/implementation/runtime/src/application_impl.cpp b/implementation/runtime/src/application_impl.cpp
index 9c6629c..a282399 100644
--- a/implementation/runtime/src/application_impl.cpp
+++ b/implementation/runtime/src/application_impl.cpp
@@ -82,12 +82,6 @@ bool application_impl::init() {
}
std::string configuration_path;
- plugin_manager::get()->load_plugins();
- auto its_pre_config_plugin = plugin_manager::get()->get_plugin(plugin_type_e::PRE_CONFIGURATION_PLUGIN);
- if (its_pre_config_plugin) {
- configuration_path = std::dynamic_pointer_cast<pre_configuration_plugin>(its_pre_config_plugin)->
- get_configuration_path();
- }
// load configuration from module
std::string config_module = "";
@@ -96,7 +90,7 @@ bool application_impl::init() {
// TODO: Add loading of custom configuration module
} else { // load default module
auto its_plugin = plugin_manager::get()->get_plugin(
- plugin_type_e::CONFIGURATION_PLUGIN);
+ plugin_type_e::CONFIGURATION_PLUGIN, VSOMEIP_CFG_LIBRARY);
if (its_plugin) {
configuration_ = std::dynamic_pointer_cast<configuration>(its_plugin);
if (configuration_path.length()) {
@@ -247,17 +241,15 @@ bool application_impl::init() {
auto its_plugins = configuration_->get_plugins(name_);
auto its_app_plugin_info = its_plugins.find(plugin_type_e::APPLICATION_PLUGIN);
if (its_app_plugin_info != its_plugins.end()) {
- auto its_application_plugin = plugin_manager::get()->get_plugin(plugin_type_e::APPLICATION_PLUGIN);
- if (!its_application_plugin) {
- VSOMEIP_INFO << std::hex << "Client 0x" << get_client()
- << " : loading application plugin: " << its_app_plugin_info->second;
- its_application_plugin = plugin_manager::get()->load_plugin(
- its_app_plugin_info->second, plugin_type_e::APPLICATION_PLUGIN,
- VSOMEIP_APPLICATION_PLUGIN_VERSION);
- }
- if (its_application_plugin) {
- std::dynamic_pointer_cast<application_plugin>(its_application_plugin)->
- on_application_state_change(name_, application_plugin_state_e::STATE_INITIALIZED);
+ for (auto its_library : its_app_plugin_info->second) {
+ auto its_application_plugin = plugin_manager::get()->get_plugin(
+ plugin_type_e::APPLICATION_PLUGIN, its_library);
+ if (its_application_plugin) {
+ VSOMEIP_INFO << "Client 0x" << std::hex << get_client()
+ << " Loading plug-in library: " << its_library << " succeeded!";
+ std::dynamic_pointer_cast<application_plugin>(its_application_plugin)->
+ on_application_state_change(name_, application_plugin_state_e::STATE_INITIALIZED);
+ }
}
}
@@ -331,11 +323,15 @@ void application_impl::start() {
auto its_plugins = configuration_->get_plugins(name_);
auto its_app_plugin_info = its_plugins.find(plugin_type_e::APPLICATION_PLUGIN);
if (its_app_plugin_info != its_plugins.end()) {
- auto its_application_plugin = plugin_manager::get()->get_plugin(plugin_type_e::APPLICATION_PLUGIN);
- if (its_application_plugin) {
- std::dynamic_pointer_cast<application_plugin>(its_application_plugin)->
- on_application_state_change(name_, application_plugin_state_e::STATE_STARTED);
+ for (auto its_library : its_app_plugin_info->second) {
+ auto its_application_plugin = plugin_manager::get()->get_plugin(
+ plugin_type_e::APPLICATION_PLUGIN, its_library);
+ if (its_application_plugin) {
+ std::dynamic_pointer_cast<application_plugin>(its_application_plugin)->
+ on_application_state_change(name_, application_plugin_state_e::STATE_STARTED);
+ }
}
+
}
app_counter_mutex__.lock();
@@ -407,11 +403,15 @@ void application_impl::stop() {
auto its_plugins = configuration_->get_plugins(name_);
auto its_app_plugin_info = its_plugins.find(plugin_type_e::APPLICATION_PLUGIN);
if (its_app_plugin_info != its_plugins.end()) {
- auto its_application_plugin = plugin_manager::get()->get_plugin(plugin_type_e::APPLICATION_PLUGIN);
- if (its_application_plugin) {
- std::dynamic_pointer_cast<application_plugin>(its_application_plugin)->
- on_application_state_change(name_, application_plugin_state_e::STATE_STOPPED);
+ for (auto its_library : its_app_plugin_info->second) {
+ auto its_application_plugin = plugin_manager::get()->get_plugin(
+ plugin_type_e::APPLICATION_PLUGIN, its_library);
+ if (its_application_plugin) {
+ std::dynamic_pointer_cast<application_plugin>(its_application_plugin)->
+ on_application_state_change(name_, application_plugin_state_e::STATE_STOPPED);
+ }
}
+
}
stop_cv_.notify_one();
diff --git a/implementation/service_discovery/include/service_discovery_host.hpp b/implementation/service_discovery/include/service_discovery_host.hpp
index f6ab65d..74abfd5 100644
--- a/implementation/service_discovery/include/service_discovery_host.hpp
+++ b/implementation/service_discovery/include/service_discovery_host.hpp
@@ -56,8 +56,7 @@ public:
virtual void del_routing_info(service_t _service, instance_t _instance,
bool _has_reliable, bool _has_unreliable) = 0;
- virtual std::chrono::milliseconds update_routing_info(
- std::chrono::milliseconds _elapsed) = 0;
+ virtual void update_routing_info(std::chrono::milliseconds _elapsed) = 0;
virtual void on_unsubscribe(service_t _service, instance_t _instance,
eventgroup_t _eventgroup,
diff --git a/implementation/service_discovery/include/service_discovery_impl.hpp b/implementation/service_discovery/include/service_discovery_impl.hpp
index 68b159f..214450d 100644
--- a/implementation/service_discovery/include/service_discovery_impl.hpp
+++ b/implementation/service_discovery/include/service_discovery_impl.hpp
@@ -189,7 +189,7 @@ private:
std::shared_ptr<vsomeip::endpoint_definition> its_endpoint);
void start_ttl_timer();
- std::chrono::milliseconds stop_ttl_timer();
+ void stop_ttl_timer();
void check_ttl(const boost::system::error_code &_error);
@@ -348,7 +348,7 @@ private:
// TTL handling for services offered by other hosts
std::mutex ttl_timer_mutex_;
boost::asio::steady_timer ttl_timer_;
- std::chrono::milliseconds smallest_ttl_;
+ std::chrono::milliseconds ttl_timer_runtime_;
ttl_t ttl_;
// TTL handling for subscriptions done by other hosts
@@ -390,6 +390,7 @@ private:
std::atomic<bool> is_suspended_;
std::string sd_multicast_;
+ boost::asio::ip::address sd_multicast_address_;
boost::asio::ip::address current_remote_address_;
diff --git a/implementation/service_discovery/src/service_discovery_impl.cpp b/implementation/service_discovery/src/service_discovery_impl.cpp
index ca9aa5a..903afd6 100644
--- a/implementation/service_discovery/src/service_discovery_impl.cpp
+++ b/implementation/service_discovery/src/service_discovery_impl.cpp
@@ -50,7 +50,7 @@ service_discovery_impl::service_discovery_impl(service_discovery_host *_host)
std::make_shared<deserializer>(
host_->get_configuration()->get_buffer_shrink_threshold())),
ttl_timer_(_host->get_io()),
- smallest_ttl_(DEFAULT_TTL),
+ ttl_timer_runtime_(VSOMEIP_SD_DEFAULT_CYCLIC_OFFER_DELAY / 2),
ttl_(VSOMEIP_SD_DEFAULT_TTL),
subscription_expiration_timer_(_host->get_io()),
max_message_size_(VSOMEIP_MAX_UDP_SD_PAYLOAD),
@@ -65,9 +65,6 @@ service_discovery_impl::service_discovery_impl(service_discovery_host *_host)
main_phase_timer_(_host->get_io()),
is_suspended_(false),
is_diagnosis_(false) {
- std::chrono::seconds smallest_ttl(DEFAULT_TTL);
- smallest_ttl_ = std::chrono::duration_cast<std::chrono::milliseconds>(smallest_ttl);
-
// TODO: cleanup start condition!
next_subscription_expiration_ = std::chrono::steady_clock::now() + std::chrono::hours(24);
}
@@ -84,13 +81,15 @@ boost::asio::io_service & service_discovery_impl::get_io() {
}
void service_discovery_impl::init() {
- runtime_ = std::dynamic_pointer_cast<sd::runtime>(plugin_manager::get()->get_plugin(plugin_type_e::SD_RUNTIME_PLUGIN));
+ runtime_ = std::dynamic_pointer_cast<sd::runtime>(plugin_manager::get()->get_plugin(plugin_type_e::SD_RUNTIME_PLUGIN, VSOMEIP_SD_LIBRARY));
std::shared_ptr < configuration > its_configuration =
host_->get_configuration();
if (its_configuration) {
unicast_ = its_configuration->get_unicast_address();
sd_multicast_ = its_configuration->get_sd_multicast();
+ boost::system::error_code ec;
+ sd_multicast_address_ = boost::asio::ip::address::from_string(sd_multicast_, ec);
port_ = its_configuration->get_sd_port();
reliable_ = (its_configuration->get_sd_protocol()
@@ -131,6 +130,7 @@ void service_discovery_impl::init() {
its_configuration->get_sd_cyclic_offer_delay());
offer_debounce_time_ = std::chrono::milliseconds(
its_configuration->get_sd_offer_debounce_time());
+ ttl_timer_runtime_ = cyclic_offer_delay_ / 2;
} else {
VSOMEIP_ERROR << "SD: no configuration found!";
}
@@ -163,10 +163,12 @@ void service_discovery_impl::start() {
start_main_phase_timer();
start_offer_debounce_timer(true);
start_find_debounce_timer(true);
+ start_ttl_timer();
}
void service_discovery_impl::stop() {
is_suspended_ = true;
+ stop_ttl_timer();
}
void service_discovery_impl::request_service(service_t _service,
@@ -1112,16 +1114,37 @@ void service_discovery_impl::on_message(const byte_t *_data, length_t _length,
if(is_suspended_) {
return;
}
+ // ignore all SD messages with source address equal to node's unicast address
+ if (!check_source_address(_sender)) {
+ return;
+ }
+ if (_destination == sd_multicast_address_) {
+ static std::chrono::steady_clock::time_point last_msg_received =
+ std::chrono::steady_clock::now();
+ std::chrono::steady_clock::time_point now =
+ std::chrono::steady_clock::now();
+ std::chrono::milliseconds time_since_last_message(
+ std::chrono::duration_cast<std::chrono::milliseconds>(
+ now - last_msg_received));
+ if (time_since_last_message >
+ std::chrono::milliseconds(cyclic_offer_delay_ + (cyclic_offer_delay_ / 10))) {
+ // we didn't receive a multicast message within 110% of the cyclic_offer_delay_
+ VSOMEIP_WARNING << "Didn't receive a multicast SD message for " <<
+ std::dec << time_since_last_message.count() << "ms.";
+ // rejoin multicast group
+ if (endpoint_) {
+ endpoint_->join(sd_multicast_);
+ }
+ }
+ last_msg_received = now;
+ }
+
current_remote_address_ = _sender;
deserializer_->set_data(_data, _length);
std::shared_ptr < message_impl
> its_message(deserializer_->deserialize_sd_message());
deserializer_->reset();
if (its_message) {
- // ignore all SD messages with source address equal to node's unicast address
- if (!check_source_address(_sender)) {
- return;
- }
// ignore all messages which are sent with invalid header fields
if(!check_static_header_fields(its_message)) {
return;
@@ -1134,9 +1157,6 @@ void service_discovery_impl::on_message(const byte_t *_data, length_t _length,
host_->expire_services(_sender);
}
- std::chrono::milliseconds expired = stop_ttl_timer();
- smallest_ttl_ = host_->update_routing_info(expired);
-
std::vector < std::shared_ptr<option_impl> > its_options =
its_message->get_options();
@@ -1173,7 +1193,6 @@ void service_discovery_impl::on_message(const byte_t *_data, length_t _length,
> (*iter);
bool force_initial_events(false);
if (is_stop_subscribe_subscribe) {
- is_stop_subscribe_subscribe = false;
force_initial_events = true;
}
is_stop_subscribe_subscribe = check_stop_subscribe_subscribe(iter, its_end);
@@ -1203,7 +1222,6 @@ void service_discovery_impl::on_message(const byte_t *_data, length_t _length,
}
}
}
- start_ttl_timer();
} else {
VSOMEIP_ERROR << "service_discovery_impl::on_message: deserialization error.";
return;
@@ -1343,10 +1361,6 @@ void service_discovery_impl::process_offerservice_serviceentry(
_major, _minor, _ttl,
_reliable_address, _reliable_port,
_unreliable_address, _unreliable_port);
- const std::chrono::milliseconds its_precise_ttl(_ttl * 1000);
- if (its_precise_ttl < smallest_ttl_) {
- smallest_ttl_ = its_precise_ttl;
- }
std::lock_guard<std::mutex> its_lock(subscribed_mutex_);
auto found_service = subscribed_.find(_service);
@@ -2312,24 +2326,22 @@ void service_discovery_impl::serialize_and_send(
void service_discovery_impl::start_ttl_timer() {
std::lock_guard<std::mutex> its_lock(ttl_timer_mutex_);
- ttl_timer_.expires_from_now(std::chrono::milliseconds(smallest_ttl_));
+ boost::system::error_code ec;
+ ttl_timer_.expires_from_now(std::chrono::milliseconds(ttl_timer_runtime_), ec);
ttl_timer_.async_wait(
std::bind(&service_discovery_impl::check_ttl, shared_from_this(),
std::placeholders::_1));
}
-std::chrono::milliseconds service_discovery_impl::stop_ttl_timer() {
+void service_discovery_impl::stop_ttl_timer() {
std::lock_guard<std::mutex> its_lock(ttl_timer_mutex_);
- std::chrono::milliseconds remaining = std::chrono::duration_cast<
- std::chrono::milliseconds
- >(ttl_timer_.expires_from_now());
- ttl_timer_.cancel();
- return (smallest_ttl_ - remaining);
+ boost::system::error_code ec;
+ ttl_timer_.cancel(ec);
}
void service_discovery_impl::check_ttl(const boost::system::error_code &_error) {
if (!_error) {
- smallest_ttl_ = host_->update_routing_info(smallest_ttl_);
+ host_->update_routing_info(ttl_timer_runtime_);
start_ttl_timer();
}
}
diff --git a/test/client_id_tests/client_id_test_utility.cpp b/test/client_id_tests/client_id_test_utility.cpp
index f4e66c0..887646f 100644
--- a/test/client_id_tests/client_id_test_utility.cpp
+++ b/test/client_id_tests/client_id_test_utility.cpp
@@ -39,7 +39,7 @@ public:
std::shared_ptr<vsomeip::configuration> its_configuration;
auto its_plugin = vsomeip::plugin_manager::get()->get_plugin(
- vsomeip::plugin_type_e::CONFIGURATION_PLUGIN);
+ vsomeip::plugin_type_e::CONFIGURATION_PLUGIN, VSOMEIP_CFG_LIBRARY);
if (its_plugin) {
configuration_ = std::dynamic_pointer_cast<vsomeip::configuration>(its_plugin);
}
diff --git a/test/configuration_tests/configuration-test.cpp b/test/configuration_tests/configuration-test.cpp
index a7e8def..f9717c5 100644
--- a/test/configuration_tests/configuration-test.cpp
+++ b/test/configuration_tests/configuration-test.cpp
@@ -135,7 +135,7 @@ void check_file(const std::string &_config_file,
// 0. Create configuration object
std::shared_ptr<vsomeip::configuration> its_configuration;
auto its_plugin = vsomeip::plugin_manager::get()->get_plugin(
- vsomeip::plugin_type_e::CONFIGURATION_PLUGIN);
+ vsomeip::plugin_type_e::CONFIGURATION_PLUGIN, VSOMEIP_CFG_LIBRARY);
if (its_plugin) {
its_configuration = std::dynamic_pointer_cast<vsomeip::configuration>(its_plugin);
}
@@ -277,14 +277,13 @@ void check_file(const std::string &_config_file,
EXPECT_EQ(0x9933, its_configuration->get_id("other_application"));
- std::map<vsomeip::plugin_type_e, std::string> its_plugins =
+ std::map<vsomeip::plugin_type_e, std::set<std::string>> its_plugins =
its_configuration->get_plugins(EXPECTED_ROUTING_MANAGER_HOST);
EXPECT_EQ(1u, its_plugins.size());
for (const auto plugin : its_plugins) {
EXPECT_EQ(vsomeip::plugin_type_e::APPLICATION_PLUGIN, plugin.first);
- EXPECT_EQ(std::string("libtestlibraryname.so."
- + std::to_string(VSOMEIP_APPLICATION_PLUGIN_VERSION)),
- plugin.second);
+ for (auto its_library : plugin.second)
+ EXPECT_EQ(std::string("libtestlibraryname.so." + std::to_string(VSOMEIP_APPLICATION_PLUGIN_VERSION)), its_library);
}
EXPECT_EQ(vsomeip::plugin_type_e::CONFIGURATION_PLUGIN, its_plugin->get_plugin_type());
EXPECT_EQ("vsomeip cfg plugin", its_plugin->get_plugin_name());