fix http_connection timeout issue

This commit is contained in:
Arvid Norberg 2014-10-16 05:33:09 +00:00
parent a3b18b8a41
commit 2f077d8efa
2 changed files with 9 additions and 0 deletions

View File

@ -227,6 +227,9 @@ private:
bool m_ssl; bool m_ssl;
bool m_abort; bool m_abort;
// true while waiting for an async_connect
bool m_connecting;
}; };
} }

View File

@ -91,6 +91,7 @@ http_connection::http_connection(io_service& ios
, m_limiter_timer_active(false) , m_limiter_timer_active(false)
, m_ssl(false) , m_ssl(false)
, m_abort(false) , m_abort(false)
, m_connecting(false)
{ {
TORRENT_ASSERT(!m_handler.empty()); TORRENT_ASSERT(!m_handler.empty());
} }
@ -422,6 +423,7 @@ void http_connection::on_timeout(boost::weak_ptr<http_connection> p
{ {
error_code ec; error_code ec;
c->m_sock.close(ec); c->m_sock.close(ec);
if (!c->m_connecting) c->connect();
} }
else else
{ {
@ -578,6 +580,8 @@ void http_connection::connect()
#if defined TORRENT_ASIO_DEBUGGING #if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("http_connection::on_connect"); add_outstanding_async("http_connection::on_connect");
#endif #endif
TORRENT_ASSERT(!m_connecting);
m_connecting = true;
m_sock.async_connect(target_address, boost::bind(&http_connection::on_connect m_sock.async_connect(target_address, boost::bind(&http_connection::on_connect
, shared_from_this(), _1)); , shared_from_this(), _1));
} }
@ -587,6 +591,8 @@ void http_connection::on_connect(error_code const& e)
#if defined TORRENT_ASIO_DEBUGGING #if defined TORRENT_ASIO_DEBUGGING
complete_async("http_connection::on_connect"); complete_async("http_connection::on_connect");
#endif #endif
TORRENT_ASSERT(m_connecting);
m_connecting = false;
m_last_receive = time_now_hires(); m_last_receive = time_now_hires();
m_start_time = m_last_receive; m_start_time = m_last_receive;