Skip to content

Commit

Permalink
vSomeIP 2.6.2
Browse files Browse the repository at this point in the history
  • Loading branch information
juergengehring committed Apr 7, 2017
1 parent c35b82a commit 5315798
Show file tree
Hide file tree
Showing 45 changed files with 1,706 additions and 372 deletions.
8 changes: 8 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -288,3 +288,11 @@ v2.6.0

v2.6.1
- Fixed clearing of subscribers on stop offer service

v2.6.2
- Service-Disovery performance improvements
- Made Routing Manager restartable
- Fixed file handle leak caused by remote ECU reboot
- Activate TCP-Keep-Alive for TCP endpoints
- Debouncing of request-service messages (routing info performance)
- Fixed false session-id handling of identification request
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ project (vsomeip)

set (VSOMEIP_MAJOR_VERSION 2)
set (VSOMEIP_MINOR_VERSION 6)
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)
Expand Down
8 changes: 8 additions & 0 deletions documentation/vsomeipUserGuide
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,14 @@ callbacks if max_dispatchers is configured greater than 0).
The number of internal threads to process messages and events within an application.
Valid values are 1-255. Default is 2.
+
** 'request_debounce_time' (optional)
+
Specifies a debounce-time interval in ms in which request-service messages are sent to
the routing manager. If an application requests many services in short same time
the load of sent messages to the routing manager and furthermore the replies from the
routing manager (which contains the routing info for the requested service if available)
can be heavily reduced. The default value if not specified is 10ms.
+
* `services` (array)
+
Contains the services of the service provider.
Expand Down
1 change: 1 addition & 0 deletions implementation/configuration/include/configuration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ class VSOMEIP_IMPORT_EXPORT_CONFIG configuration {
virtual std::size_t get_max_dispatchers(const std::string &_name) const = 0;
virtual std::size_t get_max_dispatch_time(const std::string &_name) const = 0;
virtual std::size_t get_io_thread_count(const std::string &_name) const = 0;
virtual std::size_t get_request_debouncing(const std::string &_name) const = 0;

virtual std::uint32_t get_max_message_size_local() const = 0;
virtual std::uint32_t get_message_size_reliable(const std::string& _address,
Expand Down
3 changes: 2 additions & 1 deletion implementation/configuration/include/configuration_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ class configuration_impl: public configuration, public std::enable_shared_from_t
VSOMEIP_EXPORT std::size_t get_max_dispatchers(const std::string &_name) const;
VSOMEIP_EXPORT std::size_t get_max_dispatch_time(const std::string &_name) const;
VSOMEIP_EXPORT std::size_t get_io_thread_count(const std::string &_name) const;
VSOMEIP_EXPORT std::size_t get_request_debouncing(const std::string &_name) const;

VSOMEIP_EXPORT std::set<std::pair<service_t, instance_t> > get_remote_services() const;

Expand Down Expand Up @@ -227,7 +228,7 @@ class configuration_impl: public configuration, public std::enable_shared_from_t
std::string logfile_;
boost::log::trivial::severity_level loglevel_;

std::map<std::string, std::tuple<client_t, std::size_t, std::size_t, size_t>> applications_;
std::map<std::string, std::tuple<client_t, std::size_t, std::size_t, std::size_t, std::size_t>> applications_;
std::set<client_t> client_identifiers_;

std::map<service_t,
Expand Down
20 changes: 20 additions & 0 deletions implementation/configuration/include/internal.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include <cstdint>
#include <limits>
#include <vsomeip/primitive_types.hpp>

#define VSOMEIP_ENV_APPLICATION_NAME "VSOMEIP_APPLICATION_NAME"
#define VSOMEIP_ENV_CONFIGURATION "VSOMEIP_CONFIGURATION"
Expand Down Expand Up @@ -56,6 +57,8 @@

#define VSOMEIP_MAX_DESERIALIZER 5

#define VSOMEIP_REQUEST_DEBOUNCE_TIME 10

#define VSOMEIP_COMMAND_HEADER_SIZE 7

#define VSOMEIP_COMMAND_TYPE_POS 0
Expand Down Expand Up @@ -89,6 +92,7 @@
#define VSOMEIP_REGISTER_EVENT 0x1B
#define VSOMEIP_UNREGISTER_EVENT 0x1C
#define VSOMEIP_ID_RESPONSE 0x1D
#define VSOMEIP_ID_REQUEST 0x1E

#define VSOMEIP_OFFER_SERVICE_COMMAND_SIZE 16
#define VSOMEIP_REQUEST_SERVICE_COMMAND_SIZE 17
Expand All @@ -101,6 +105,7 @@
#define VSOMEIP_REGISTER_EVENT_COMMAND_SIZE 15
#define VSOMEIP_UNREGISTER_EVENT_COMMAND_SIZE 14
#define VSOMEIP_ID_RESPONSE_COMMAND_SIZE 12
#define VSOMEIP_ID_REQUEST_COMMAND_SIZE 13

#ifndef _WIN32
#include <pthread.h>
Expand All @@ -126,10 +131,25 @@ typedef enum {
RIE_DEL_CLIENT = 0x3,
} routing_info_entry_e;

struct service_data_t {
service_t service_;
instance_t instance_;
major_version_t major_;
minor_version_t minor_;
bool use_exclusive_proxy_; // only used for requests!

bool operator<(const service_data_t &_other) const {
return (service_ < _other.service_
|| (service_ == _other.service_
&& instance_ < _other.instance_));
}
};

struct configuration_data_t {
#ifndef _WIN32
volatile char initialized_;
pthread_mutex_t mutex_;
pid_t pid_;
#endif
unsigned short client_base_;

Expand Down
21 changes: 20 additions & 1 deletion implementation/configuration/src/configuration_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,7 @@ void configuration_impl::load_application_data(
std::size_t its_max_dispatchers(VSOMEIP_MAX_DISPATCHERS);
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);
for (auto i = _tree.begin(); i != _tree.end(); ++i) {
std::string its_key(i->first);
std::string its_value(i->second.data());
Expand Down Expand Up @@ -470,6 +471,13 @@ void configuration_impl::load_application_data(
VSOMEIP_WARNING << "Max. number of threads per application is 255";
its_io_thread_count = 255;
}
} else if (its_key == "request_debounce_time") {
its_converter << std::dec << its_value;
its_converter >> its_request_debounce_time;
if (its_request_debounce_time > 10000) {
VSOMEIP_WARNING << "Max. request debounce time is 10.000ms";
its_request_debounce_time = 10000;
}
}
}
if (its_name != "") {
Expand All @@ -487,7 +495,8 @@ void configuration_impl::load_application_data(
}
applications_[its_name]
= std::make_tuple(its_id, its_max_dispatchers,
its_max_dispatch_time, its_io_thread_count);
its_max_dispatch_time, its_io_thread_count,
its_request_debounce_time);
} else {
VSOMEIP_WARNING << "Multiple configurations for application "
<< its_name << ". Ignoring a configuration from "
Expand Down Expand Up @@ -1797,6 +1806,16 @@ bool configuration_impl::is_configured_client_id(client_t _id) const {
return (client_identifiers_.find(_id) != client_identifiers_.end());
}

std::size_t configuration_impl::get_request_debouncing(const std::string &_name) const {
size_t debounce_time = VSOMEIP_REQUEST_DEBOUNCE_TIME;
auto found_application = applications_.find(_name);
if (found_application != applications_.end()) {
debounce_time = std::get<4>(found_application->second);
}

return debounce_time;
}

std::size_t configuration_impl::get_io_thread_count(const std::string &_name) const {
std::size_t its_io_thread_count = VSOMEIP_IO_THREAD_COUNT;

Expand Down
4 changes: 4 additions & 0 deletions implementation/endpoints/include/endpoint.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ class endpoint_definition;

class endpoint {
public:
typedef std::function<void()> error_handler_t;

virtual ~endpoint() {}

virtual void start() = 0;
Expand Down Expand Up @@ -46,6 +48,8 @@ class endpoint {
virtual uint32_t get_use_count() = 0;

virtual void restart() = 0;

virtual void register_error_handler(error_handler_t _error) = 0;
};

} // namespace vsomeip
Expand Down
5 changes: 5 additions & 0 deletions implementation/endpoints/include/endpoint_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ class endpoint_impl: public virtual endpoint {
void decrement_use_count();
uint32_t get_use_count();

void register_error_handler(error_handler_t _error_handler);

public:
// required
virtual bool is_client() const = 0;
Expand Down Expand Up @@ -81,6 +83,9 @@ class endpoint_impl: public virtual endpoint {

std::mutex local_mutex_;
endpoint_type local_;

error_handler_t error_handler_;
std::mutex error_handler_mutex_;
};

} // namespace vsomeip
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ typedef client_endpoint_impl<

class local_client_endpoint_impl: public local_client_endpoint_base_impl {
public:
typedef std::function<void()> error_handler_t;

local_client_endpoint_impl(std::shared_ptr<endpoint_host> _host,
endpoint_type _remote,
boost::asio::io_service &_io,
Expand All @@ -47,8 +45,6 @@ class local_client_endpoint_impl: public local_client_endpoint_base_impl {
bool get_remote_address(boost::asio::ip::address &_address) const;
unsigned short get_remote_port() const;

void register_error_handler(error_handler_t _error_handler);

void restart();

private:
Expand All @@ -62,8 +58,6 @@ class local_client_endpoint_impl: public local_client_endpoint_base_impl {
std::size_t _bytes);

message_buffer_t recv_buffer_;

error_handler_t error_handler_;
};

} // namespace vsomeip
Expand Down
2 changes: 2 additions & 0 deletions implementation/endpoints/include/tcp_server_endpoint_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ class tcp_server_endpoint_impl: public tcp_server_endpoint_base_impl {
void start();
void stop();

void stop_all_connections(const boost::asio::ip::address &_address);

bool send_to(const std::shared_ptr<endpoint_definition> _target,
const byte_t *_data, uint32_t _size, bool _flush);
void send_queued(queue_iterator_type _queue_iterator);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ class virtual_server_endpoint_impl : public endpoint {

void restart();

void register_error_handler(error_handler_t _handler);

private:
std::string address_;
uint16_t port_;
Expand Down
7 changes: 7 additions & 0 deletions implementation/endpoints/src/endpoint_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,13 @@ uint32_t endpoint_impl<Protocol>::get_use_count() {
return use_count_;
}

template<typename Protocol>
void endpoint_impl<Protocol>::register_error_handler(error_handler_t _error_handler) {
std::lock_guard<std::mutex> its_lock(error_handler_mutex_);
this->error_handler_ = _error_handler;
}


// Instantiate template
#ifndef _WIN32
template class endpoint_impl<boost::asio::local::stream_protocol>;
Expand Down
13 changes: 7 additions & 6 deletions implementation/endpoints/src/local_client_endpoint_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,13 @@ void local_client_endpoint_impl::receive_cbk(
// routing manager. For the routing manager proxies, the corresponding
// client endpoint (that connect to the same client) are removed
// after the proxy has received the routing info.
if (error_handler_)
error_handler_();
error_handler_t handler;
{
std::lock_guard<std::mutex> its_lock(error_handler_mutex_);
handler = error_handler_;
}
if (handler)
handler();
} else {
receive();
}
Expand All @@ -200,8 +205,4 @@ unsigned short local_client_endpoint_impl::get_remote_port() const {
return 0;
}

void local_client_endpoint_impl::register_error_handler(error_handler_t _error_handler) {
error_handler_ = _error_handler;
}

} // namespace vsomeip
11 changes: 9 additions & 2 deletions implementation/endpoints/src/tcp_client_endpoint_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ void tcp_client_endpoint_impl::connect() {
<< "Nagle algorithm: " << its_error.message();
}

socket_.set_option(boost::asio::socket_base::keep_alive(true), its_error);
if (its_error) {
VSOMEIP_WARNING << "tcp_client_endpoint::connect: couldn't enable "
<< "keep_alive: " << its_error.message();
}

// Enable SO_REUSEADDR to avoid bind problems with services going offline
// and coming online again and the user has specified only a small number
// of ports in the clients section for one service instance
Expand Down Expand Up @@ -351,8 +357,9 @@ void tcp_client_endpoint_impl::receive_cbk(
receive();
} else {
if (_error == boost::asio::error::connection_reset ||
_error == boost::asio::error::eof) {
VSOMEIP_TRACE << "tcp_client_endpoint: connection_reseted/EOF ~> close socket!";
_error == boost::asio::error::eof ||
_error == boost::asio::error::timed_out) {
VSOMEIP_WARNING << "tcp_client_endpoint receive_cbk error detected: " << _error.message();
shutdown_and_close_socket();
} else {
receive();
Expand Down
26 changes: 25 additions & 1 deletion implementation/endpoints/src/tcp_server_endpoint_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,22 @@ void tcp_server_endpoint_impl::stop() {
}
}

void tcp_server_endpoint_impl::stop_all_connections(const boost::asio::ip::address &_address) {
std::lock_guard<std::mutex> its_lock(connections_mutex_);
endpoint_type type;

for (const auto &c : connections_) {
if(c.first.address() == _address) {
VSOMEIP_INFO << "Stopping connections for " << _address.to_string()
<< " : " << std::dec << c.first.port();
c.second->stop();
type = c.first;
}
}
connections_.erase(type);
}


bool tcp_server_endpoint_impl::send_to(
const std::shared_ptr<endpoint_definition> _target,
const byte_t *_data,
Expand Down Expand Up @@ -162,6 +178,12 @@ void tcp_server_endpoint_impl::accept_cbk(connection::ptr _connection,
_connection->set_remote_info(remote);
// Nagle algorithm off
new_connection_socket.set_option(ip::tcp::no_delay(true), its_error);

new_connection_socket.set_option(boost::asio::socket_base::keep_alive(true), its_error);
if (its_error) {
VSOMEIP_WARNING << "tcp_server_endpoint::connect: couldn't enable "
<< "keep_alive: " << its_error.message();
}
}
if (!its_error) {
{
Expand Down Expand Up @@ -485,7 +507,9 @@ void tcp_server_endpoint_impl::connection::receive_cbk(
}
}
if (_error == boost::asio::error::eof
|| _error == boost::asio::error::connection_reset) {
|| _error == boost::asio::error::connection_reset
|| _error == boost::asio::error::timed_out) {
VSOMEIP_WARNING << "tcp_server_endpoint receive_cbk error detected: " << _error.message();
{
std::lock_guard<std::mutex> its_lock(its_server->connections_mutex_);
stop();
Expand Down
5 changes: 5 additions & 0 deletions implementation/endpoints/src/virtual_server_endpoint_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,9 @@ void virtual_server_endpoint_impl::restart() {

}

void virtual_server_endpoint_impl::register_error_handler(
error_handler_t _handler) {
(void)_handler;
}

} // namespace vsomeip
7 changes: 7 additions & 0 deletions implementation/routing/include/routing_manager_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ class routing_manager_base : public routing_manager,
endpoint *_receiver,
const boost::asio::ip::address &_remote_address,
std::uint16_t _remote_port) = 0;

#ifndef _WIN32
virtual bool check_credentials(client_t _client, uid_t _uid, gid_t _gid);
#endif
Expand All @@ -119,6 +120,9 @@ class routing_manager_base : public routing_manager,
virtual std::shared_ptr<event> find_event(service_t _service, instance_t _instance,
event_t _event) const;

virtual void register_client_error_handler(client_t _client,
const std::shared_ptr<endpoint> &_endpoint) = 0;

protected:
std::shared_ptr<serviceinfo> find_service(service_t _service, instance_t _instance) const;
std::shared_ptr<serviceinfo> create_service_info(service_t _service,
Expand Down Expand Up @@ -182,6 +186,9 @@ class routing_manager_base : public routing_manager,
instance_t _instance,
eventgroup_t _eventgroup, event_t _event);

void send_identify_request(service_t _service, instance_t _instance,
major_version_t _major, bool _reliable);

private:
std::shared_ptr<endpoint> create_local_unlocked(client_t _client);
std::shared_ptr<endpoint> find_local_unlocked(client_t _client);
Expand Down
Loading

0 comments on commit 5315798

Please sign in to comment.