Skip to content

Commit

Permalink
Merge pull request #3 from fawkesrobotics/tviehmann/client-disconnect…
Browse files Browse the repository at this point in the history
…-fix

client: disconnect only if not cancelled explicitly
  • Loading branch information
TarikViehmann authored Apr 5, 2024
2 parents 0526559 + e126704 commit 5b6c4ee
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.10.2)

project(protobuf_comm VERSION 0.9.1
project(protobuf_comm VERSION 0.9.2
DESCRIPTION "Protobuf wrapper for peer-to-peer communication")

find_package(Protobuf REQUIRED)
Expand Down
9 changes: 5 additions & 4 deletions client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ ProtobufStreamClient::handle_resolve(const boost::system::error_code &err,
boost::bind(&ProtobufStreamClient::handle_connect,
this,
boost::asio::placeholders::error));
} else {
} else if (err != boost::asio::error::operation_aborted) {
disconnect_nosig();
sig_disconnected_(err);
}
Expand Down Expand Up @@ -214,6 +214,7 @@ ProtobufStreamClient::disconnect_nosig()
{
boost::system::error_code err;
if (socket_.is_open()) {
socket_.cancel();
socket_.shutdown(ip::tcp::socket::shutdown_both, err);
socket_.close();
}
Expand Down Expand Up @@ -266,7 +267,7 @@ ProtobufStreamClient::handle_read_header(const boost::system::error_code &error)
boost::bind(&ProtobufStreamClient::handle_read_message,
this,
boost::asio::placeholders::error));
} else {
} else if (error != boost::asio::error::operation_aborted) {
disconnect_nosig();
sig_disconnected_(error);
}
Expand Down Expand Up @@ -311,7 +312,7 @@ ProtobufStreamClient::handle_read_message(const boost::system::error_code &error
}

start_recv();
} else {
} else if (error != boost::asio::error::operation_aborted) {
disconnect_nosig();
sig_disconnected_(error);
}
Expand Down Expand Up @@ -348,7 +349,7 @@ ProtobufStreamClient::handle_write(const boost::system::error_code &error,
} else {
outbound_active_ = false;
}
} else {
} else if (error != boost::asio::error::operation_aborted) {
disconnect_nosig();
sig_disconnected_(error);
}
Expand Down

0 comments on commit 5b6c4ee

Please sign in to comment.