summaryrefslogtreecommitdiff
path: root/implementation/endpoints/src
diff options
context:
space:
mode:
Diffstat (limited to 'implementation/endpoints/src')
-rw-r--r--implementation/endpoints/src/endpoint_impl.cpp7
-rw-r--r--implementation/endpoints/src/local_client_endpoint_impl.cpp13
-rw-r--r--implementation/endpoints/src/tcp_client_endpoint_impl.cpp11
-rw-r--r--implementation/endpoints/src/tcp_server_endpoint_impl.cpp26
-rw-r--r--implementation/endpoints/src/virtual_server_endpoint_impl.cpp5
5 files changed, 53 insertions, 9 deletions
diff --git a/implementation/endpoints/src/endpoint_impl.cpp b/implementation/endpoints/src/endpoint_impl.cpp
index 1707502..1d16d05 100644
--- a/implementation/endpoints/src/endpoint_impl.cpp
+++ b/implementation/endpoints/src/endpoint_impl.cpp
@@ -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>;
diff --git a/implementation/endpoints/src/local_client_endpoint_impl.cpp b/implementation/endpoints/src/local_client_endpoint_impl.cpp
index 6535ec6..4c79047 100644
--- a/implementation/endpoints/src/local_client_endpoint_impl.cpp
+++ b/implementation/endpoints/src/local_client_endpoint_impl.cpp
@@ -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();
}
@@ -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
diff --git a/implementation/endpoints/src/tcp_client_endpoint_impl.cpp b/implementation/endpoints/src/tcp_client_endpoint_impl.cpp
index 916c78a..4afe3ef 100644
--- a/implementation/endpoints/src/tcp_client_endpoint_impl.cpp
+++ b/implementation/endpoints/src/tcp_client_endpoint_impl.cpp
@@ -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
@@ -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();
diff --git a/implementation/endpoints/src/tcp_server_endpoint_impl.cpp b/implementation/endpoints/src/tcp_server_endpoint_impl.cpp
index 39f2802..85766ef 100644
--- a/implementation/endpoints/src/tcp_server_endpoint_impl.cpp
+++ b/implementation/endpoints/src/tcp_server_endpoint_impl.cpp
@@ -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,
@@ -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) {
{
@@ -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();
diff --git a/implementation/endpoints/src/virtual_server_endpoint_impl.cpp b/implementation/endpoints/src/virtual_server_endpoint_impl.cpp
index 4ea9ed2..6f20929 100644
--- a/implementation/endpoints/src/virtual_server_endpoint_impl.cpp
+++ b/implementation/endpoints/src/virtual_server_endpoint_impl.cpp
@@ -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