diff --git a/src/network/rest/http/ClientConnection.h b/src/network/rest/http/ClientConnection.h
index d87838dd..2b9ddb18 100644
--- a/src/network/rest/http/ClientConnection.h
+++ b/src/network/rest/http/ClientConnection.h
@@ -83,6 +83,7 @@ namespace network
{
try
{
+ ensureNoLinger();
if (m_socket.is_open()) {
m_socket.close();
}
@@ -90,6 +91,14 @@ namespace network
catch(const std::exception&) { /* ignore */ }
}
+ /// Helper to enable the SO_LINGER socket option during shutdown.
+ void ensureNoLinger()
+ {
+ // enable SO_LINGER timeout 0
+ asio::socket_base::linger linger(true, 0);
+ m_socket.set_option(linger);
+ }
+
/// Perform an synchronous write operation.
void send(HTTPPayload request)
{
@@ -126,9 +135,7 @@ namespace network
}
}
else if (ec != asio::error::operation_aborted) {
- if (m_socket.is_open()) {
- m_socket.close();
- }
+ stop();
}
});
}
diff --git a/src/network/rest/http/HTTPClient.h b/src/network/rest/http/HTTPClient.h
index 526127e9..474d4998 100644
--- a/src/network/rest/http/HTTPClient.h
+++ b/src/network/rest/http/HTTPClient.h
@@ -164,14 +164,6 @@ namespace network
{
asio::connect(m_socket, endpoints);
- // enable SO_LINGER timeout 0
- asio::socket_base::linger linger(true, 0);
- m_socket.set_option(linger);
-
- // enable TCP_NODELAY
- asio::ip::tcp::no_delay noDelay(true);
- m_socket.set_option(noDelay);
-
m_connection = new_unique(ConnectionType, std::move(m_socket), m_requestHandler);
m_connection->start();
}
diff --git a/src/network/rest/http/ServerConnectionManager.h b/src/network/rest/http/ServerConnectionManager.h
index 4f1a1748..379fbfaa 100644
--- a/src/network/rest/http/ServerConnectionManager.h
+++ b/src/network/rest/http/ServerConnectionManager.h
@@ -90,7 +90,7 @@ namespace network
void stopAll()
{
for (auto c : m_connections)
- c->stop();
+ c->stop();
std::lock_guard guard(m_lock);
m_connections.clear();