forked from premiere/premiere-libtorrent
fixed a bug in client_test. fixed some problems related to the previous buffer bug fix. all tests pass now.
This commit is contained in:
parent
18cb6736ea
commit
d63ceac56c
|
@ -724,15 +724,19 @@ int main(int ac, char* av[])
|
|||
|
||||
std::stringstream out;
|
||||
for (handles_t::iterator i = handles.begin();
|
||||
i != handles.end(); ++i)
|
||||
i != handles.end();)
|
||||
{
|
||||
torrent_handle& h = i->second;
|
||||
if (!h.is_valid())
|
||||
{
|
||||
handles.erase(i);
|
||||
--i;
|
||||
handles.erase(i++);
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
++i;
|
||||
}
|
||||
|
||||
out << "name: " << esc("37");
|
||||
if (h.has_metadata()) out << h.get_torrent_info().name();
|
||||
else out << "-";
|
||||
|
|
|
@ -792,7 +792,7 @@ namespace libtorrent
|
|||
return;
|
||||
}
|
||||
|
||||
if (m_requests.size() > m_ses.m_settings.max_allowed_request_queue)
|
||||
if (int(m_requests.size()) > m_ses.m_settings.max_allowed_request_queue)
|
||||
{
|
||||
// don't allow clients to abuse our
|
||||
// memory consumption.
|
||||
|
@ -1468,7 +1468,7 @@ namespace libtorrent
|
|||
// if we have downloaded more than one piece more
|
||||
// than we have uploaded OR if we are a seed
|
||||
// have an unlimited upload rate
|
||||
if(!m_send_buffer[m_current_send_buffer].empty()
|
||||
if(send_buffer_size() > 0
|
||||
|| (!m_requests.empty() && !is_choked()))
|
||||
m_ul_bandwidth_quota.max = resource_request::inf;
|
||||
else
|
||||
|
@ -1738,7 +1738,7 @@ namespace libtorrent
|
|||
|
||||
assert(m_reading);
|
||||
assert(m_last_read_size > 0);
|
||||
assert(m_last_read_size >= bytes_transferred);
|
||||
assert(m_last_read_size >= int(bytes_transferred));
|
||||
m_reading = false;
|
||||
// correct the dl quota usage, if not all of the buffer was actually read
|
||||
m_dl_bandwidth_quota.used -= m_last_read_size - bytes_transferred;
|
||||
|
@ -1803,7 +1803,8 @@ namespace libtorrent
|
|||
// if we have requests or pending data to be sent or announcements to be made
|
||||
// we want to send data
|
||||
return ((!m_requests.empty() && !m_choked)
|
||||
|| !m_send_buffer[m_current_send_buffer].empty())
|
||||
|| !m_send_buffer[m_current_send_buffer].empty()
|
||||
|| !m_send_buffer[(m_current_send_buffer + 1) & 1].empty())
|
||||
&& m_ul_bandwidth_quota.left() > 0
|
||||
&& !m_connecting;
|
||||
}
|
||||
|
@ -1955,8 +1956,8 @@ namespace libtorrent
|
|||
}
|
||||
}
|
||||
|
||||
assert(m_write_pos <= m_send_buffer[
|
||||
(m_current_send_buffer + 1) & 1].size());
|
||||
assert(m_write_pos <= int(m_send_buffer[
|
||||
(m_current_send_buffer + 1) & 1].size()));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1047,16 +1047,6 @@ namespace libtorrent
|
|||
session_impl::mutex_t::scoped_lock l(m_impl.m_mutex);
|
||||
std::fill(m_impl.m_extension_enabled, m_impl.m_extension_enabled
|
||||
+ num_supported_extensions, false);
|
||||
|
||||
static char const printable[]
|
||||
= "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_.!~*'()";
|
||||
|
||||
// remove the 'ext' sufix in the peer_id
|
||||
for (unsigned char* i = m_impl.m_peer_id.begin() + 17;
|
||||
i != m_impl.m_peer_id.end(); ++i)
|
||||
{
|
||||
*i = printable[rand() % (sizeof(printable)-1)];
|
||||
}
|
||||
}
|
||||
|
||||
void session::set_ip_filter(ip_filter const& f)
|
||||
|
|
|
@ -17,7 +17,9 @@ void test_transfer(char const* tracker_url, libtorrent::torrent_info const& t)
|
|||
using namespace libtorrent;
|
||||
|
||||
session ses1;
|
||||
ses1.set_severity_level(alert::debug);
|
||||
session ses2(fingerprint("LT", 0, 1, 0, 0), std::make_pair(49000, 50000));
|
||||
ses2.set_severity_level(alert::debug);
|
||||
|
||||
// they should not use the same save dir, because the
|
||||
// file pool will complain if two torrents are trying to
|
||||
|
@ -47,12 +49,21 @@ void test_transfer(char const* tracker_url, libtorrent::torrent_info const& t)
|
|||
// make sure this function can be called on
|
||||
// torrents without metadata
|
||||
tor2.status();
|
||||
std::auto_ptr<alert> a;
|
||||
a = ses1.pop_alert();
|
||||
if (a.get())
|
||||
std::cerr << "ses1: " << a->msg() << "\n";
|
||||
|
||||
a = ses2.pop_alert();
|
||||
if (a.get())
|
||||
std::cerr << "ses2: " << a->msg() << "\n";
|
||||
|
||||
if (tor2.has_metadata()) break;
|
||||
sleep(100);
|
||||
}
|
||||
|
||||
std::cerr << "metadata received. waiting for transfer to complete\n";
|
||||
TEST_CHECK(tor2.has_metadata());
|
||||
std::cerr << "metadata received. waiting for transfer to complete\n";
|
||||
|
||||
for (int i = 0; i < 50; ++i)
|
||||
{
|
||||
|
@ -61,8 +72,8 @@ void test_transfer(char const* tracker_url, libtorrent::torrent_info const& t)
|
|||
sleep(100);
|
||||
}
|
||||
|
||||
std::cerr << "done\n";
|
||||
TEST_CHECK(tor2.is_seed());
|
||||
std::cerr << "done\n";
|
||||
}
|
||||
|
||||
int test_main()
|
||||
|
|
Loading…
Reference in New Issue