*** empty log message ***

This commit is contained in:
Arvid Norberg 2004-02-24 12:45:05 +00:00
parent 4cb125a694
commit cea75e3723
4 changed files with 72 additions and 55 deletions

View File

@ -214,7 +214,8 @@ namespace libtorrent
// quota is unlimited. // quota is unlimited.
int send_quota_left() const { return m_send_quota_left; } int send_quota_left() const { return m_send_quota_left; }
void update_send_quota_left() { void update_send_quota_left()
{
m_send_quota_left = upload_bandwidth.given; m_send_quota_left = upload_bandwidth.given;
if (m_send_quota_left > 0) send_buffer_updated(); if (m_send_quota_left > 0) send_buffer_updated();
} }

View File

@ -35,7 +35,8 @@ POSSIBILITY OF SUCH DAMAGE.
#include <algorithm> #include <algorithm>
#include <boost/limits.hpp> #include <boost/limits.hpp>
namespace libtorrent { namespace libtorrent
{
namespace namespace
{ {
int saturated_add(int a, int b) int saturated_add(int a, int b)
@ -99,20 +100,25 @@ namespace libtorrent {
assert(total_wanted>=0); assert(total_wanted>=0);
return total_wanted; return total_wanted;
} }
}
#ifndef NDEBUG #ifndef NDEBUG
class allocate_resources_contract_check class allocate_resources_contract_check
{ {
int resources; int resources;
std::vector<resource_request *> & requests; std::vector<resource_request *> & requests;
public: public:
allocate_resources_contract_check(int resources_,std::vector<resource_request *> & requests_)
allocate_resources_contract_check(
int resources_
, std::vector<resource_request *>& requests_)
: resources(resources_) : resources(resources_)
, requests(requests_) , requests(requests_)
{ {
assert(resources >= 0); assert(resources >= 0);
for(int i=0;i<(int)requests.size();i++) for (int i = 0; i < (int)requests.size(); ++i)
{ {
assert(requests[i]->used >= 0); assert(requests[i]->used >= 0);
assert(requests[i]->wanted >= 0); assert(requests[i]->wanted >= 0);
@ -124,7 +130,7 @@ namespace libtorrent {
{ {
int sum_given = 0; int sum_given = 0;
int sum_wanted = 0; int sum_wanted = 0;
for(int i=0;i<(int)requests.size();i++) for (int i = 0; i < (int)requests.size(); ++i)
{ {
assert(requests[i]->used >= 0); assert(requests[i]->used >= 0);
assert(requests[i]->wanted >= 0); assert(requests[i]->wanted >= 0);
@ -137,10 +143,12 @@ namespace libtorrent {
assert(sum_given == std::min(resources,sum_wanted)); assert(sum_given == std::min(resources,sum_wanted));
} }
}; };
#endif
void allocate_resources(int resources, #endif
std::vector<resource_request *> & requests) } // namespace unnamed
void allocate_resources(int resources
, std::vector<resource_request *>& requests)
{ {
#ifndef NDEBUG #ifndef NDEBUG
allocate_resources_contract_check allocate_resources_contract_check
@ -158,7 +166,7 @@ namespace libtorrent {
{ {
// Resources are scarce // Resources are scarce
for(int i=0;i < (int)requests.size();i++) for (int i = 0; i < (int)requests.size(); ++i)
requests[i]->given = 0; requests[i]->given = 0;
if (resources == 0) if (resources == 0)
@ -178,7 +186,11 @@ namespace libtorrent {
std::sort(requests.begin(), requests.end(), by_used); std::sort(requests.begin(), requests.end(), by_used);
while(resources_to_distribute > 0) while(resources_to_distribute > 0)
for(int i = 0; i < (int)requests.size() && resources_to_distribute>0; i++) {
for(int i = 0;
i < (int)requests.size() && resources_to_distribute > 0;
++i)
{
resources_to_distribute -= resources_to_distribute -=
give( give(
requests[i], requests[i],
@ -187,6 +199,8 @@ namespace libtorrent {
round_up_division( round_up_division(
(int)resources_to_distribute, (int)resources_to_distribute,
(int)requests.size()-i))); (int)requests.size()-i)));
}
}
assert(resources_to_distribute == 0); assert(resources_to_distribute == 0);
} }
} }

View File

@ -1268,7 +1268,7 @@ namespace libtorrent
enum { block_limit = 2 }; // how many blocks difference is considered unfair enum { block_limit = 2 }; // how many blocks difference is considered unfair
// if the peer has been choked, send tha current piece // if the peer has been choked, send the current piece
// as fast as possible // as fast as possible
if (diff > block_limit*m_torrent->block_size() || m_torrent->is_seed() || is_choked()) if (diff > block_limit*m_torrent->block_size() || m_torrent->is_seed() || is_choked())
{ {

View File

@ -480,7 +480,8 @@ namespace libtorrent
boost::shared_ptr<peer_connection> c( boost::shared_ptr<peer_connection> c(
new peer_connection(*this, m_selector, s)); new peer_connection(*this, m_selector, s));
if (m_upload_rate != -1) { if (m_upload_rate != -1)
{
c->upload_bandwidth.given = 0; c->upload_bandwidth.given = 0;
c->update_send_quota_left(); c->update_send_quota_left();
} }
@ -636,8 +637,8 @@ namespace libtorrent
else if (i->second->should_request()) else if (i->second->should_request())
{ {
m_tracker_manager.queue_request( m_tracker_manager.queue_request(
i->second->generate_tracker_request(m_listen_port), i->second->generate_tracker_request(m_listen_port)
boost::get_pointer(i->second)); , boost::get_pointer(i->second));
} }
i->second->second_tick(); i->second->second_tick();
@ -647,7 +648,8 @@ namespace libtorrent
// distribute the maximum upload rate among the peers // distribute the maximum upload rate among the peers
control_upload_rates(m_upload_rate == -1 control_upload_rates(
m_upload_rate == -1
? std::numeric_limits<int>::max() ? std::numeric_limits<int>::max()
: m_upload_rate : m_upload_rate
, m_connections); , m_connections);