get rid of read-recurse hack

This commit is contained in:
Arvid Norberg 2011-11-30 20:07:18 +00:00
parent 3515199eb5
commit 8e8f798905
2 changed files with 9 additions and 33 deletions

View File

@ -1041,10 +1041,6 @@ namespace libtorrent
// requesting too many pieces while being choked
boost::uint8_t m_choke_rejects;
// counts the number of recursive calls to on_receive_data
// used to limit recursion
boost::uint8_t m_read_recurse:5;
// if this is true, the disconnection
// timestamp is not updated when the connection
// is closed. This means the time until we can

View File

@ -138,7 +138,6 @@ namespace libtorrent
, m_prefer_whole_pieces(0)
, m_desired_queue_size(2)
, m_choke_rejects(0)
, m_read_recurse(0)
, m_fast_reconnect(false)
, m_active(outgoing)
, m_peer_interested(false)
@ -289,7 +288,6 @@ namespace libtorrent
, m_prefer_whole_pieces(0)
, m_desired_queue_size(2)
, m_choke_rejects(0)
, m_read_recurse(0)
, m_fast_reconnect(false)
, m_active(outgoing)
, m_peer_interested(false)
@ -2481,7 +2479,6 @@ namespace libtorrent
int write_queue_size = fs.async_write(p, data, boost::bind(&peer_connection::on_disk_write_complete
, self(), _1, _2, p, t));
m_outstanding_writing_bytes += p.length;
TORRENT_ASSERT((m_channel_state[download_channel] & peer_info::bw_network) == 0);
m_download_queue.erase(b);
if (write_queue_size / 16 / 1024 > m_ses.m_settings.cache_size / 2
@ -4833,31 +4830,6 @@ namespace libtorrent
return;
}
error_code ec;
if (sync == read_sync && m_read_recurse < 10)
{
size_t bytes_transferred = try_read(read_sync, ec);
if (ec != asio::error::would_block)
{
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("peer_connection::on_receive_data");
#endif
++m_read_recurse;
TORRENT_ASSERT((m_channel_state[download_channel] & peer_info::bw_network) == 0);
m_channel_state[download_channel] |= peer_info::bw_network;
on_receive_data(ec, bytes_transferred);
--m_read_recurse;
return;
}
}
#ifdef TORRENT_VERBOSE_LOGGING
if (m_read_recurse >= 10)
{
peer_log("*** reached recursion limit");
}
#endif
try_read(read_async, ec);
}
@ -5124,8 +5096,11 @@ namespace libtorrent
#if defined TORRENT_ASIO_DEBUGGING
complete_async("peer_connection::on_receive_data");
#endif
// leave this bit set until we're done looping, reading from the socket.
// that way we don't trigger any async read calls until the end of this
// function.
TORRENT_ASSERT(m_channel_state[download_channel] & peer_info::bw_network);
m_channel_state[download_channel] &= ~peer_info::bw_network;
int bytes_in_loop = bytes_transferred;
@ -5222,6 +5197,11 @@ namespace libtorrent
}
m_statistics.trancieve_ip_packet(bytes_in_loop, m_remote.address().is_v6());
// allow reading from the socket again
TORRENT_ASSERT(m_channel_state[download_channel] & peer_info::bw_network);
m_channel_state[download_channel] &= ~peer_info::bw_network;
setup_receive(read_async);
}