cover more potential exception states withn the REST service;

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

@ -94,11 +94,21 @@ namespace network
/// <summary>Helper to enable the SO_LINGER socket option during shutdown.</summary>
void ensureNoLinger()
{
try
{
// 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>
void send(HTTPPayload request)
@ -158,10 +168,14 @@ namespace network
if (ec) {
::LogError(LOG_REST, "%s, code = %u", ec.message().c_str(), ec.value());
try
{
// 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,10 +168,14 @@ namespace network
}
else {
if (!ec) {
try
{
// 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) {

Loading…
Cancel
Save

Powered by TurnKey Linux.