cover more potential exception states withn the REST service;

3.56-maint
Bryan Biedenkapp 2 years ago
parent 1d498fc48f
commit 58780d9e3d

@ -95,9 +95,19 @@ namespace network
/// <summary>Helper to enable the SO_LINGER socket option during shutdown.</summary> /// <summary>Helper to enable the SO_LINGER socket option during shutdown.</summary>
void ensureNoLinger() void ensureNoLinger()
{ {
// enable SO_LINGER timeout 0 try
asio::socket_base::linger linger(true, 0); {
m_socket.set_option(linger); // enable SO_LINGER timeout 0
asio::socket_base::linger linger(true, 0);
m_socket.set_option(linger);
}
catch(const asio::system_error& e)
{
asio::error_code ec = e.code();
if (ec) {
::LogError(LOG_REST, "%s, code = %u", ec.message().c_str(), ec.value());
}
}
} }
/// <summary>Perform an synchronous write operation.</summary> /// <summary>Perform an synchronous write operation.</summary>
@ -158,9 +168,13 @@ namespace network
if (ec) { if (ec) {
::LogError(LOG_REST, "%s, code = %u", ec.message().c_str(), ec.value()); ::LogError(LOG_REST, "%s, code = %u", ec.message().c_str(), ec.value());
// initiate graceful connection closure try
asio::error_code ignored_ec; {
m_socket.shutdown(asio::ip::tcp::socket::shutdown_both, ignored_ec); // initiate graceful connection closure
asio::error_code ignored_ec;
m_socket.shutdown(asio::ip::tcp::socket::shutdown_both, ignored_ec);
}
catch(const std::exception& e) { ::LogError(LOG_REST, "%s", ec.message().c_str()); }
} }
} }
} }

@ -168,9 +168,13 @@ namespace network
} }
else { else {
if (!ec) { if (!ec) {
// initiate graceful connection closure try
asio::error_code ignored_ec; {
m_socket.shutdown(asio::ip::tcp::socket::shutdown_both, ignored_ec); // initiate graceful connection closure
asio::error_code ignored_ec;
m_socket.shutdown(asio::ip::tcp::socket::shutdown_both, ignored_ec);
}
catch(const std::exception& e) { ::LogError(LOG_REST, "%s", ec.message().c_str()); }
} }
if (ec != asio::error::operation_aborted) { if (ec != asio::error::operation_aborted) {

Loading…
Cancel
Save

Powered by TurnKey Linux.