Always log errors during socket cancel

cancel_socket_checked(), which logs any received errors, is now called
consistently instead of the lower-level cancel_socket().
This commit is contained in:
Jacob Champion
2015-12-15 11:24:04 -08:00
parent 999add0c4b
commit 5f52127cf7
2 changed files with 18 additions and 12 deletions
+17 -11
View File
@@ -578,15 +578,7 @@ protected:
}
m_alog.write(log::alevel::devel, "Asio transport post-init timed out");
lib::asio::error_code cec = socket_con_type::cancel_socket();
if (cec) {
if (cec == lib::asio::error::operation_not_supported) {
// cancel not supported on this OS, ignore and log at dev level
m_alog.write(log::alevel::devel, "socket cancel not supported");
} else {
log_err(log::elevel::warn, "socket cancel failed", cec);
}
}
cancel_socket_checked();
callback(ret_ec);
}
@@ -690,7 +682,7 @@ protected:
} else {
m_alog.write(log::alevel::devel,
"asio handle_proxy_write timer expired");
socket_con_type::cancel_socket();
cancel_socket_checked();
callback(make_error_code(transport::error::timeout));
}
}
@@ -1105,7 +1097,7 @@ protected:
m_alog.write(log::alevel::devel,
"Asio transport socket shutdown timed out");
socket_con_type::cancel_socket();
cancel_socket_checked();
callback(ret_ec);
}
@@ -1154,6 +1146,20 @@ protected:
}
callback(tec);
}
/// Cancel the underlying socket and log any errors
void cancel_socket_checked() {
lib::asio::error_code cec = socket_con_type::cancel_socket();
if (cec) {
if (cec == lib::asio::error::operation_not_supported) {
// cancel not supported on this OS, ignore and log at dev level
m_alog.write(log::alevel::devel, "socket cancel not supported");
} else {
log_err(log::elevel::warn, "socket cancel failed", cec);
}
}
}
private:
/// Convenience method for logging the code and message for an error_code
template <typename error_type>
+1 -1
View File
@@ -1027,7 +1027,7 @@ protected:
}
m_alog->write(log::alevel::devel,"TCP connect timed out");
tcon->cancel_socket();
tcon->cancel_socket_checked();
callback(ret_ec);
}