*** empty log message ***

This commit is contained in:
Arvid Norberg 2005-08-23 09:59:56 +00:00
parent e930580f13
commit 84ddeacea0
6 changed files with 129 additions and 23 deletions

View File

@ -318,7 +318,7 @@ int main(int argc, char* argv[])
session ses;
ses.listen_on(std::make_pair(6880, 6889));
// ses.set_upload_rate_limit(512 * 1024);
//ses.set_upload_rate_limit(512 * 1024);
ses.set_http_settings(settings);
ses.set_severity_level(alert::debug);
// ses.set_severity_level(alert::info);

View File

@ -33,6 +33,8 @@ POSSIBILITY OF SUCH DAMAGE.
#ifndef TORRENT_RESOURCE_REQUEST_HPP_INCLUDED
#define TORRENT_RESOURCE_REQUEST_HPP_INCLUDED
#include <boost/integer_traits.hpp>
#ifdef min
#undef min
#endif
@ -60,6 +62,7 @@ namespace libtorrent
return given - used;
}
static const int inf = boost::integer_traits<int>::const_max;
// I'm right now actively using:
int used;

View File

@ -69,11 +69,11 @@ namespace libtorrent
{
assert(a >= 0);
assert(b >= 0);
assert(std::numeric_limits<int>::max() + std::numeric_limits<int>::max() < 0);
assert(resource_request::inf + resource_request::inf < 0);
int sum = a + b;
if(sum < 0)
sum = std::numeric_limits<int>::max();
sum = resource_request::inf;
assert(sum >= a && sum >= b);
return sum;
@ -165,7 +165,7 @@ namespace libtorrent
, res);
#endif
if(resources == std::numeric_limits<int>::max())
if(resources == resource_request::inf)
{
// No competition for resources.
// Just give everyone what they want.
@ -183,7 +183,7 @@ namespace libtorrent
for (It i = start; i != end; ++i)
{
sum_max = saturated_add(sum_max, ((*i).*res).max);
assert(((*i).*res).min < std::numeric_limits<int>::max());
assert(((*i).*res).min < resource_request::inf);
assert(((*i).*res).min >= 0);
assert(((*i).*res).min <= ((*i).*res).max);
sum_min += ((*i).*res).min;
@ -229,10 +229,10 @@ namespace libtorrent
assert(r.given < r.max);
size_type used = (size_type)r.used + 1;
size_type toGive = used * kNumer / kDenom;
if(toGive > std::numeric_limits<int>::max())
toGive = std::numeric_limits<int>::max();
resources_to_distribute -= give(r, (int)toGive);
size_type to_give = used * kNumer / kDenom;
if(to_give > resource_request::inf)
to_give = resource_request::inf;
resources_to_distribute -= give(r, (int)to_give);
}
assert(resources_to_distribute >= 0);

View File

@ -30,10 +30,6 @@ POSSIBILITY OF SUCH DAMAGE.
*/
#include <boost/filesystem/operations.hpp>
#include "libtorrent/file.hpp"
#include <sstream>
#ifdef _WIN32
// windows part
#include "libtorrent/utf8.hpp"
@ -56,8 +52,17 @@ typedef int mode_t;
#include <sys/types.h>
#include <errno.h>
#include <boost/static_assert.hpp>
// make sure the _FILE_OFFSET_BITS define worked
// on this platform
BOOST_STATIC_ASSERT(sizeof(lseek(0, 0, 0)) >= 8);
#endif
#include <boost/filesystem/operations.hpp>
#include "libtorrent/file.hpp"
#include <sstream>
#ifndef O_BINARY
#define O_BINARY 0
#endif

View File

@ -126,12 +126,32 @@ namespace libtorrent
// these numbers are used the first second of connection.
// then the given upload limits will be applied by running
// allocate_resources().
m_ul_bandwidth_quota.min = 10;
m_ul_bandwidth_quota.max = std::numeric_limits<int>::max();
m_ul_bandwidth_quota.given = std::numeric_limits<int>::max();
m_ul_bandwidth_quota.max = resource_request::inf;
if (m_torrent->m_ul_bandwidth_quota.given == resource_request::inf)
{
m_ul_bandwidth_quota.given = resource_request::inf;
}
else
{
// just enough to get started with the handshake and bitmask
m_ul_bandwidth_quota.given = 400;
}
m_dl_bandwidth_quota.min = 10;
m_dl_bandwidth_quota.max = std::numeric_limits<int>::max();
m_dl_bandwidth_quota.given = 400;
m_dl_bandwidth_quota.max = resource_request::inf;
if (m_torrent->m_dl_bandwidth_quota.given == resource_request::inf)
{
m_dl_bandwidth_quota.given = resource_request::inf;
}
else
{
// just enough to get started with the handshake and bitmask
m_dl_bandwidth_quota.given = 400;
}
assert(!m_socket->is_blocking());
assert(m_torrent != 0);
@ -219,13 +239,32 @@ namespace libtorrent
// after one second, allocate_resources() will be called
// and the correct bandwidth limits will be set on all
// connections.
m_ul_bandwidth_quota.min = 10;
m_ul_bandwidth_quota.max = std::numeric_limits<int>::max();
m_ul_bandwidth_quota.given = std::numeric_limits<int>::max();
m_ul_bandwidth_quota.max = resource_request::inf;
if (m_ses.m_upload_rate == -1)
{
m_ul_bandwidth_quota.given = resource_request::inf;
}
else
{
// just enough to get started with the handshake and bitmask
m_ul_bandwidth_quota.given = 400;
}
m_dl_bandwidth_quota.min = 10;
m_dl_bandwidth_quota.max = std::numeric_limits<int>::max();
m_dl_bandwidth_quota.given = 400;
m_dl_bandwidth_quota.max = resource_request::inf;
if (m_ses.m_download_rate == -1)
{
m_dl_bandwidth_quota.given = resource_request::inf;
}
else
{
// just enough to get started with the handshake and bitmask
m_dl_bandwidth_quota.given = 400;
}
assert(!m_socket->is_blocking());
@ -1840,7 +1879,7 @@ namespace libtorrent
// than we have uploaded OR if we are a seed
// have an unlimited upload rate
if(!m_send_buffer.empty() || (!m_requests.empty() && !is_choked()))
m_ul_bandwidth_quota.max = std::numeric_limits<int>::max();
m_ul_bandwidth_quota.max = resource_request::inf;
else
m_ul_bandwidth_quota.max = m_ul_bandwidth_quota.min;
}

View File

@ -187,6 +187,32 @@ namespace libtorrent
m_uploads_quota.max = std::numeric_limits<int>::max();
m_connections_quota.max = std::numeric_limits<int>::max();
m_dl_bandwidth_quota.min = 100;
m_dl_bandwidth_quota.max = resource_request::inf;
if (m_ses.m_download_rate == -1)
{
m_dl_bandwidth_quota.given = resource_request::inf;
}
else
{
m_dl_bandwidth_quota.given = 400;
}
m_ul_bandwidth_quota.min = 100;
m_ul_bandwidth_quota.max = resource_request::inf;
if (m_ses.m_upload_rate == -1)
{
m_ul_bandwidth_quota.given = resource_request::inf;
}
else
{
m_ul_bandwidth_quota.given = 400;
}
m_policy.reset(new policy(this));
bencode(std::back_inserter(m_metadata), metadata["info"]);
init();
@ -240,6 +266,33 @@ namespace libtorrent
m_uploads_quota.max = std::numeric_limits<int>::max();
m_connections_quota.max = std::numeric_limits<int>::max();
m_dl_bandwidth_quota.min = 100;
m_dl_bandwidth_quota.max = resource_request::inf;
if (m_ses.m_download_rate == -1)
{
m_dl_bandwidth_quota.given = resource_request::inf;
}
else
{
m_dl_bandwidth_quota.given = 400;
}
m_ul_bandwidth_quota.min = 100;
m_ul_bandwidth_quota.max = resource_request::inf;
if (m_ses.m_upload_rate == -1)
{
m_ul_bandwidth_quota.given = resource_request::inf;
}
else
{
m_ul_bandwidth_quota.given = 400;
}
m_trackers.push_back(announce_entry(tracker_url));
m_requested_metadata.resize(256, 0);
m_policy.reset(new policy(this));
@ -1106,9 +1159,15 @@ namespace libtorrent
m_ul_bandwidth_quota.max
= std::min(m_ul_bandwidth_quota.max, m_upload_bandwidth_limit);
if (m_upload_bandwidth_limit == resource_request::inf)
m_ul_bandwidth_quota.max = resource_request::inf;
m_dl_bandwidth_quota.max
= std::min(m_dl_bandwidth_quota.max, m_download_bandwidth_limit);
if (m_download_bandwidth_limit == resource_request::inf)
m_dl_bandwidth_quota.max = resource_request::inf;
accumulator += m_stat;
m_stat.second_tick();
}
@ -1131,7 +1190,7 @@ namespace libtorrent
allocate_resources(m_dl_bandwidth_quota.given
, m_connections
, &peer_connection::m_dl_bandwidth_quota);
using boost::bind;
// tell all peers to reset their used quota. This is