From 0b582261ecea9aa93aa2118253fb6206546da972 Mon Sep 17 00:00:00 2001 From: Marcos Pinto Date: Fri, 16 Nov 2007 00:52:10 +0000 Subject: [PATCH] lt sync 1727 --- libtorrent/src/broadcast_socket.cpp | 2 +- libtorrent/src/http_connection.cpp | 10 ++++++++++ libtorrent/src/torrent.cpp | 1 - 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/libtorrent/src/broadcast_socket.cpp b/libtorrent/src/broadcast_socket.cpp index a9d27eff4..e03ad2274 100644 --- a/libtorrent/src/broadcast_socket.cpp +++ b/libtorrent/src/broadcast_socket.cpp @@ -182,7 +182,7 @@ namespace libtorrent void broadcast_socket::on_receive(socket_entry* s, asio::error_code const& ec , std::size_t bytes_transferred) { - if (ec || bytes_transferred == 0) return; + if (ec || bytes_transferred == 0 || !m_on_receive) return; m_on_receive(s->remote, s->buffer, bytes_transferred); s->socket->async_receive_from(asio::buffer(s->buffer, sizeof(s->buffer)) , s->remote, bind(&broadcast_socket::on_receive, this, s, _1, _2)); diff --git a/libtorrent/src/http_connection.cpp b/libtorrent/src/http_connection.cpp index 08be387cc..c96bb05dd 100644 --- a/libtorrent/src/http_connection.cpp +++ b/libtorrent/src/http_connection.cpp @@ -121,6 +121,8 @@ void http_connection::on_timeout(boost::weak_ptr p return; } + if (!c->m_sock.is_open()) return; + c->m_timer.expires_at(c->m_last_receive + c->m_timeout); c->m_timer.async_wait(bind(&http_connection::on_timeout, p, _1)); } @@ -135,6 +137,10 @@ void http_connection::close() if (m_connection_ticket > -1) m_cc.done(m_connection_ticket); m_connection_ticket = -1; + + if (m_called) return; + m_called = true; + m_handler(asio::error::operation_aborted, m_parser, 0, 0); } void http_connection::on_resolve(asio::error_code const& e @@ -360,6 +366,8 @@ void http_connection::on_assign_bandwidth(asio::error_code const& e) if (amount_to_read > m_download_quota) amount_to_read = m_download_quota; + if (!m_sock.is_open()) return; + m_sock.async_read_some(asio::buffer(&m_recvbuffer[0] + m_read_pos , amount_to_read) , bind(&http_connection::on_read @@ -373,6 +381,8 @@ void http_connection::on_assign_bandwidth(asio::error_code const& e) void http_connection::rate_limit(int limit) { + if (!m_sock.is_open()) return; + if (!m_limiter_timer_active) { m_limiter_timer_active = true; diff --git a/libtorrent/src/torrent.cpp b/libtorrent/src/torrent.cpp index b2dafb291..8a5626216 100755 --- a/libtorrent/src/torrent.cpp +++ b/libtorrent/src/torrent.cpp @@ -1406,7 +1406,6 @@ namespace libtorrent void torrent::replace_trackers(std::vector const& urls) { - TORRENT_ASSERT(!urls.empty()); m_trackers = urls; if (m_currently_trying_tracker >= (int)m_trackers.size()) m_currently_trying_tracker = (int)m_trackers.size()-1;