*** empty log message ***

This commit is contained in:
Magnus Jonsson 2004-02-24 23:48:02 +00:00
parent 13b2590c0b
commit ed7c5e6d13
6 changed files with 82 additions and 17 deletions

View File

@ -242,7 +242,7 @@ int main(int argc, char* argv[])
std::vector<torrent_handle> handles;
session ses(std::make_pair(6881, 6889));
ses.set_upload_rate_limit(40 * 1024);
ses.set_upload_rate_limit(20 * 1024);
ses.set_http_settings(settings);
ses.set_severity_level(alert::debug);

View File

@ -46,7 +46,7 @@ namespace libtorrent
class stat
{
friend class invariant_access;
enum { history = 10 };
enum { history = 5 };
public:
stat()

View File

@ -186,7 +186,7 @@ namespace libtorrent
while(resources_to_distribute > 0)
{
#if 1
#if 0
int num_active=0;
for(int i = 0;i < (int)requests.size();++i)
{
@ -208,7 +208,7 @@ namespace libtorrent
int toGive = 1+std::min(max_give-1,r->used);
resources_to_distribute-=give(r,toGive);
}
#else
#elif 1
size_type total_used=0;
size_type max_used=0;
for(int i = 0;i < (int)requests.size();++i)
@ -266,6 +266,74 @@ namespace libtorrent
toGive=std::numeric_limits<int>::max();
resources_to_distribute-=give(r,(int)toGive);
}
#else
size_type total_used=0;
size_type max_used=0;
for(int i = 0;i < (int)requests.size();++i)
{
resource_request *r=requests[i];
if(r->given == r->wanted)
continue;
assert(r->given < r->wanted);
max_used = std::max(max_used, (size_type)r->used + 1);
total_used += (size_type)r->used + 1;
}
size_type kNumer=resources_to_distribute;
size_type kDenom=total_used;
if(kNumer*max_used <= kDenom)
{
kNumer=1;
kDenom=max_used;
}
if(kNumer > kDenom)
{
kNumer=1;
kDenom=1;
}
for(int i = 0;i < (int)requests.size() && resources_to_distribute;++i)
{
resource_request *r=requests[i];
if(r->given == r->wanted)
continue;
assert(r->given < r->wanted);
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);
}
/*
while(resources_to_distribute != 0)
{
int num_active=0;
for(int i = 0;i < (int)requests.size();++i)
{
resource_request *r=requests[i];
if(r->given == r->wanted)
continue;
num_active++;
}
int max_give=resources_to_distribute/num_active;
max_give=std::max(max_give,1);
for(int i = 0;i < (int)requests.size() && resources_to_distribute;++i)
{
resource_request *r=requests[i];
if(r->given == r->wanted)
continue;
int toGive = 1+std::min(max_give-1,r->used);
resources_to_distribute-=give(r,toGive);
}
}
*/
#endif
assert(resources_to_distribute >= 0);
}

View File

@ -1238,10 +1238,10 @@ 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.empty() || (!m_requests.empty() && !is_choked()))
if(!m_send_buffer.empty() || (!m_requests.empty() && !is_choked()))
upload_bandwidth.wanted = std::numeric_limits<int>::max();
// else
// upload_bandwidth.wanted = 0;
else
upload_bandwidth.wanted = 0;
}
else
{

View File

@ -110,9 +110,7 @@ namespace
c != connections.end(); ++c)
{
boost::shared_ptr<peer_connection> p = c->second;
p->upload_bandwidth.used = (int) ((p->statistics().upload_rate()+p->upload_bandwidth.used) / 2);
// p->has_data() ? (int) (p->upload_bandwidth.given - p->send_quota_left()) //ceil(p->statistics().upload_rate())
// : 0;
p->upload_bandwidth.used = (int)ceil(p->statistics().upload_rate());
requests.push_back(&p->upload_bandwidth);
}

View File

@ -39,6 +39,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/stat.hpp"
#include "libtorrent/invariant_check.hpp"
#include <algorithm>
using namespace libtorrent;
@ -46,13 +47,11 @@ void libtorrent::stat::second_tick()
{
INVARIANT_CHECK;
std::copy(m_download_per_second_history,
m_download_per_second_history+history-1,
m_download_per_second_history+1);
std::copy(m_upload_per_second_history,
m_upload_per_second_history+history-1,
m_upload_per_second_history+1);
for(int i=history-2;i>=0;--i)
{
m_download_per_second_history[i+1]=m_download_per_second_history[i];
m_upload_per_second_history[i+1]=m_upload_per_second_history[i];
}
m_download_per_second_history[0] = m_downloaded_payload + m_downloaded_protocol;
m_upload_per_second_history[0] = m_uploaded_payload + m_uploaded_protocol;