adds more robust proxy timeout behavior

This commit is contained in:
Peter Thorson
2013-05-10 08:43:37 -05:00
parent 80990aaec9
commit 4adfc452d0
3 changed files with 37 additions and 5 deletions

View File

@@ -457,6 +457,7 @@ protected:
} else {
m_alog.write(log::alevel::devel,
"asio handle_proxy_write timer expired");
socket_con_type::cancel_socket();
callback(make_error_code(transport::error::timeout));
}
}
@@ -469,14 +470,25 @@ protected:
}
m_bufs.clear();
// Timer expired or the operation was aborted for some reason.
// Whatever aborted it will be issuing the callback so we are safe to
// return
if (ec == boost::asio::error::operation_aborted ||
m_proxy_data->timer->expires_from_now().is_negative())
{
m_elog.write(log::elevel::devel,"write operation aborted");
return;
}
if (ec) {
log_err(log::elevel::info,"asio handle_proxy_write",ec);
m_proxy_data->timer->cancel();
callback(make_error_code(error::pass_through));
} else {
proxy_read(callback);
callback(make_error_code(error::pass_through));
return;
}
proxy_read(callback);
}
void proxy_read(init_handler callback) {
@@ -513,6 +525,16 @@ protected:
m_alog.write(log::alevel::devel,"asio connection handle_proxy_read");
}
// Timer expired or the operation was aborted for some reason.
// Whatever aborted it will be issuing the callback so we are safe to
// return
if (ec == boost::asio::error::operation_aborted ||
m_proxy_data->timer->expires_from_now().is_negative())
{
m_elog.write(log::elevel::devel,"read operation aborted");
return;
}
// At this point there is no need to wait for the timer anymore
m_proxy_data->timer->cancel();

View File

@@ -204,7 +204,12 @@ protected:
void set_handle(connection_hdl hdl) {
m_hdl = hdl;
}
/// Cancel all async operations on this socket
void cancel_socket() {
m_socket->cancel();
}
void async_shutdown(socket_shutdown_handler h) {
boost::system::error_code ec;
m_socket->shutdown(boost::asio::ip::tcp::socket::shutdown_both,ec);

View File

@@ -291,6 +291,11 @@ protected:
callback(lib::error_code());
}
/// Cancel all async operations on this socket
void cancel_socket() {
get_raw_socket().cancel();
}
void async_shutdown(socket_shutdown_handler h) {
m_socket->async_shutdown(
lib::bind(