Skip to content

Commit

Permalink
vsomeip 2.10.18
Browse files Browse the repository at this point in the history
  • Loading branch information
juergengehring committed May 22, 2018
1 parent 8826dda commit 8b950eb
Show file tree
Hide file tree
Showing 29 changed files with 556 additions and 180 deletions.
10 changes: 10 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
Changes
=======

v2.10.18
- Fix restarting of TCP connection on connection reset by the server
and mark services reachable through it as unavailable until
connection is established again.
- Fix bug which prevented restarting of TCP connections if the peer
instantly send a RST after the connection had been established.
- Fix bug which could cause missing initial events in conjunction with
service discovery messages containing new subscriptions and
resubscriptions.

v2.10.17
- Speedup initial subscriptions to unreliable remote services
- Fix deadlock in conjunction with configured client ports
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ project (vsomeip)

set (VSOMEIP_MAJOR_VERSION 2)
set (VSOMEIP_MINOR_VERSION 10)
set (VSOMEIP_PATCH_VERSION 17)
set (VSOMEIP_PATCH_VERSION 18)
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
7 changes: 4 additions & 3 deletions implementation/endpoints/include/client_endpoint_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class client_endpoint_impl: public endpoint_impl<Protocol>, public client_endpoi
bool flush();

virtual void stop();
virtual void restart() = 0;
virtual void restart(bool _force = false) = 0;

bool is_client() const;

Expand All @@ -61,7 +61,8 @@ class client_endpoint_impl: public endpoint_impl<Protocol>, public client_endpoi
public:
void connect_cbk(boost::system::error_code const &_error);
void wait_connect_cbk(boost::system::error_code const &_error);
void send_cbk(boost::system::error_code const &_error, std::size_t _bytes);
virtual void send_cbk(boost::system::error_code const &_error,
std::size_t _bytes, message_buffer_ptr_t _sent_msg);
void flush_cbk(boost::system::error_code const &_error);

public:
Expand Down Expand Up @@ -98,7 +99,7 @@ class client_endpoint_impl: public endpoint_impl<Protocol>, public client_endpoi

std::mutex mutex_;

bool was_not_connected_;
std::atomic<bool> was_not_connected_;

std::atomic<std::uint16_t> local_port_;

Expand Down
2 changes: 1 addition & 1 deletion implementation/endpoints/include/endpoint.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class endpoint {
virtual void decrement_use_count() = 0;
virtual uint32_t get_use_count() = 0;

virtual void restart() = 0;
virtual void restart(bool _force = false) = 0;

virtual void register_error_handler(error_handler_t _error) = 0;

Expand Down
4 changes: 2 additions & 2 deletions implementation/endpoints/include/endpoint_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class endpoint_impl: public virtual endpoint {
// required
virtual bool is_client() const = 0;
virtual void receive() = 0;
virtual void restart() = 0;
virtual void restart(bool _force) = 0;

protected:
uint32_t find_magic_cookie(byte_t *_buffer, size_t _size);
Expand All @@ -82,7 +82,7 @@ class endpoint_impl: public virtual endpoint {

uint32_t use_count_;

bool sending_blocked_;
std::atomic<bool> sending_blocked_;

std::mutex local_mutex_;
endpoint_type local_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class local_client_endpoint_impl: public local_client_endpoint_base_impl {
bool get_remote_address(boost::asio::ip::address &_address) const;
std::uint16_t get_remote_port() const;

void restart();
void restart(bool _force);
void print_status();

private:
Expand Down
2 changes: 1 addition & 1 deletion implementation/endpoints/include/server_endpoint_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class server_endpoint_impl: public endpoint_impl<Protocol>,
virtual ~server_endpoint_impl();

bool is_client() const;
void restart();
void restart(bool _force);
bool is_connected() const;
void set_connected(bool _connected);
bool send(const uint8_t *_data, uint32_t _size, bool _flush);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,16 @@ class tcp_client_endpoint_impl: public tcp_client_endpoint_base_impl {
virtual ~tcp_client_endpoint_impl();

void start();
void restart();
void restart(bool _force);

bool get_remote_address(boost::asio::ip::address &_address) const;
std::uint16_t get_remote_port() const;
bool is_reliable() const;
bool is_local() const;
void print_status();

void send_cbk(boost::system::error_code const &_error, std::size_t _bytes,
message_buffer_ptr_t _sent_msg);
private:
void send_queued();
bool is_magic_cookie(const message_buffer_ptr_t& _recv_buffer,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class udp_client_endpoint_impl: virtual public udp_client_endpoint_base_impl {
virtual ~udp_client_endpoint_impl();

void start();
void restart();
void restart(bool _force);

void receive_cbk(boost::system::error_code const &_error,
std::size_t _bytes);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class virtual_server_endpoint_impl : public endpoint {
void decrement_use_count();
uint32_t get_use_count();

void restart();
void restart(bool _force);

void register_error_handler(error_handler_t _handler);
void print_status();
Expand Down
109 changes: 53 additions & 56 deletions implementation/endpoints/src/client_endpoint_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,12 @@ bool client_endpoint_impl<Protocol>::is_connected() const {
template<typename Protocol>
void client_endpoint_impl<Protocol>::set_connected(bool _connected) {
if (_connected) {
state_ = cei_state_e::ESTABLISHED;
std::lock_guard<std::mutex> its_lock(socket_mutex_);
if (socket_->is_open()) {
state_ = cei_state_e::ESTABLISHED;
} else {
state_ = cei_state_e::CLOSED;
}
} else {
state_ = cei_state_e::CLOSED;
}}
Expand Down Expand Up @@ -222,15 +227,15 @@ void client_endpoint_impl<Protocol>::connect_cbk(
if (its_host) {
if (_error && _error != boost::asio::error::already_connected) {
shutdown_and_close_socket(true);
start_connect_timer();
// Double the timeout as long as the maximum allowed is larger
if (connect_timeout_ < VSOMEIP_MAX_CONNECT_TIMEOUT)
connect_timeout_ = (connect_timeout_ << 1);

if (state_ != cei_state_e::ESTABLISHED) {
state_ = cei_state_e::CLOSED;
its_host->on_disconnect(this->shared_from_this());
}
start_connect_timer();
// Double the timeout as long as the maximum allowed is larger
if (connect_timeout_ < VSOMEIP_MAX_CONNECT_TIMEOUT)
connect_timeout_ = (connect_timeout_ << 1);
} else {
{
std::lock_guard<std::mutex> its_lock(connect_timer_mutex_);
Expand All @@ -244,11 +249,13 @@ void client_endpoint_impl<Protocol>::connect_cbk(

receive();

{
if (was_not_connected_) {
was_not_connected_ = false;
std::lock_guard<std::mutex> its_lock(mutex_);
if (queue_.size() > 0 && was_not_connected_) {
was_not_connected_ = false;
if (queue_.size() > 0) {
send_queued();
VSOMEIP_WARNING << __func__ << ": resume sending to: "
<< get_remote_information();
}
}
}
Expand All @@ -258,14 +265,15 @@ void client_endpoint_impl<Protocol>::connect_cbk(
template<typename Protocol>
void client_endpoint_impl<Protocol>::wait_connect_cbk(
boost::system::error_code const &_error) {
if (!_error) {
if (!_error && !client_endpoint_impl<Protocol>::sending_blocked_) {
connect();
}
}

template<typename Protocol>
void client_endpoint_impl<Protocol>::send_cbk(
boost::system::error_code const &_error, std::size_t _bytes) {
boost::system::error_code const &_error, std::size_t _bytes,
message_buffer_ptr_t _sent_msg) {
(void)_bytes;
if (!_error) {
std::lock_guard<std::mutex> its_lock(mutex_);
Expand All @@ -284,27 +292,23 @@ void client_endpoint_impl<Protocol>::send_cbk(
queue_.clear();
queue_size_ = 0;
} else {
message_buffer_ptr_t its_buffer;
if (queue_.size()) {
its_buffer = queue_.front();
}
service_t its_service(0);
method_t its_method(0);
client_t its_client(0);
session_t its_session(0);
if (its_buffer && its_buffer->size() > VSOMEIP_SESSION_POS_MAX) {
if (_sent_msg && _sent_msg->size() > VSOMEIP_SESSION_POS_MAX) {
its_service = VSOMEIP_BYTES_TO_WORD(
(*its_buffer)[VSOMEIP_SERVICE_POS_MIN],
(*its_buffer)[VSOMEIP_SERVICE_POS_MAX]);
(*_sent_msg)[VSOMEIP_SERVICE_POS_MIN],
(*_sent_msg)[VSOMEIP_SERVICE_POS_MAX]);
its_method = VSOMEIP_BYTES_TO_WORD(
(*its_buffer)[VSOMEIP_METHOD_POS_MIN],
(*its_buffer)[VSOMEIP_METHOD_POS_MAX]);
(*_sent_msg)[VSOMEIP_METHOD_POS_MIN],
(*_sent_msg)[VSOMEIP_METHOD_POS_MAX]);
its_client = VSOMEIP_BYTES_TO_WORD(
(*its_buffer)[VSOMEIP_CLIENT_POS_MIN],
(*its_buffer)[VSOMEIP_CLIENT_POS_MAX]);
(*_sent_msg)[VSOMEIP_CLIENT_POS_MIN],
(*_sent_msg)[VSOMEIP_CLIENT_POS_MAX]);
its_session = VSOMEIP_BYTES_TO_WORD(
(*its_buffer)[VSOMEIP_SESSION_POS_MIN],
(*its_buffer)[VSOMEIP_SESSION_POS_MAX]);
(*_sent_msg)[VSOMEIP_SESSION_POS_MIN],
(*_sent_msg)[VSOMEIP_SESSION_POS_MAX]);
}
VSOMEIP_WARNING << "cei::send_cbk received error: "
<< _error.message() << " (" << std::dec
Expand Down Expand Up @@ -338,40 +342,33 @@ void client_endpoint_impl<Protocol>::send_cbk(
<< get_remote_information();
was_not_connected_ = true;
} else {
{
std::lock_guard<std::mutex> its_lock(mutex_);
message_buffer_ptr_t its_buffer;
if (queue_.size()) {
its_buffer = queue_.front();
}
service_t its_service(0);
method_t its_method(0);
client_t its_client(0);
session_t its_session(0);
if (its_buffer && its_buffer->size() > VSOMEIP_SESSION_POS_MAX) {
its_service = VSOMEIP_BYTES_TO_WORD(
(*its_buffer)[VSOMEIP_SERVICE_POS_MIN],
(*its_buffer)[VSOMEIP_SERVICE_POS_MAX]);
its_method = VSOMEIP_BYTES_TO_WORD(
(*its_buffer)[VSOMEIP_METHOD_POS_MIN],
(*its_buffer)[VSOMEIP_METHOD_POS_MAX]);
its_client = VSOMEIP_BYTES_TO_WORD(
(*its_buffer)[VSOMEIP_CLIENT_POS_MIN],
(*its_buffer)[VSOMEIP_CLIENT_POS_MAX]);
its_session = VSOMEIP_BYTES_TO_WORD(
(*its_buffer)[VSOMEIP_SESSION_POS_MIN],
(*its_buffer)[VSOMEIP_SESSION_POS_MAX]);
}
VSOMEIP_WARNING << "cei::send_cbk received error: " << _error.message()
<< " (" << std::dec << _error.value() << ") "
<< get_remote_information() << " "
<< " " << std::dec << queue_.size()
<< " " << std::dec << queue_size_ << " ("
<< std::hex << std::setw(4) << std::setfill('0') << its_client <<"): ["
<< std::hex << std::setw(4) << std::setfill('0') << its_service << "."
<< std::hex << std::setw(4) << std::setfill('0') << its_method << "."
<< std::hex << std::setw(4) << std::setfill('0') << its_session << "]";
service_t its_service(0);
method_t its_method(0);
client_t its_client(0);
session_t its_session(0);
if (_sent_msg && _sent_msg->size() > VSOMEIP_SESSION_POS_MAX) {
its_service = VSOMEIP_BYTES_TO_WORD(
(*_sent_msg)[VSOMEIP_SERVICE_POS_MIN],
(*_sent_msg)[VSOMEIP_SERVICE_POS_MAX]);
its_method = VSOMEIP_BYTES_TO_WORD(
(*_sent_msg)[VSOMEIP_METHOD_POS_MIN],
(*_sent_msg)[VSOMEIP_METHOD_POS_MAX]);
its_client = VSOMEIP_BYTES_TO_WORD(
(*_sent_msg)[VSOMEIP_CLIENT_POS_MIN],
(*_sent_msg)[VSOMEIP_CLIENT_POS_MAX]);
its_session = VSOMEIP_BYTES_TO_WORD(
(*_sent_msg)[VSOMEIP_SESSION_POS_MIN],
(*_sent_msg)[VSOMEIP_SESSION_POS_MAX]);
}
VSOMEIP_WARNING << "cei::send_cbk received error: " << _error.message()
<< " (" << std::dec << _error.value() << ") "
<< get_remote_information() << " "
<< " " << std::dec << queue_.size()
<< " " << std::dec << queue_size_ << " ("
<< std::hex << std::setw(4) << std::setfill('0') << its_client <<"): ["
<< std::hex << std::setw(4) << std::setfill('0') << its_service << "."
<< std::hex << std::setw(4) << std::setfill('0') << its_method << "."
<< std::hex << std::setw(4) << std::setfill('0') << its_session << "]";
print_status();
}
}
Expand Down
7 changes: 4 additions & 3 deletions implementation/endpoints/src/local_client_endpoint_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ bool local_client_endpoint_impl::is_local() const {
return true;
}

void local_client_endpoint_impl::restart() {
if (state_ == cei_state_e::CONNECTING) {
void local_client_endpoint_impl::restart(bool _force) {
if (!_force && state_ == cei_state_e::CONNECTING) {
return;
}
state_ = cei_state_e::CONNECTING;
Expand Down Expand Up @@ -206,7 +206,8 @@ VSOMEIP_INFO << msg.str();
local_client_endpoint_impl
>(shared_from_this()),
std::placeholders::_1,
std::placeholders::_2
std::placeholders::_2,
its_buffer
)
);
}
Expand Down
3 changes: 2 additions & 1 deletion implementation/endpoints/src/server_endpoint_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ bool server_endpoint_impl<Protocol>::is_client() const {
}

template<typename Protocol>
void server_endpoint_impl<Protocol>::restart() {
void server_endpoint_impl<Protocol>::restart(bool _force) {
(void)_force;
// intentionally left blank
}

Expand Down
Loading

0 comments on commit 8b950eb

Please sign in to comment.