forked from premiere/premiere-libtorrent
bandwidth management fix + improved string conversion fallback in case strings are incorrect in torrent
This commit is contained in:
parent
f5fe27e691
commit
4f86042b97
|
@ -207,6 +207,8 @@ namespace libtorrent
|
|||
void expire_bandwidth(int channel, int amount);
|
||||
void assign_bandwidth(int channel, int amount);
|
||||
|
||||
int bandwidth_throttle(int channel) const;
|
||||
|
||||
// --------------------------------------------
|
||||
// PEER MANAGEMENT
|
||||
|
||||
|
|
|
@ -218,6 +218,10 @@ namespace libtorrent
|
|||
t->expire_bandwidth(m_channel, -1);
|
||||
continue;
|
||||
}
|
||||
// don't hand out chunks larger than the throttle
|
||||
// per second on the torrent
|
||||
if (max_assignable > t->bandwidth_throttle(m_channel))
|
||||
max_assignable = t->bandwidth_throttle(m_channel);
|
||||
|
||||
// so, hand out max_assignable, but no more than
|
||||
// the available bandwidth (amount) and no more
|
||||
|
|
|
@ -91,11 +91,13 @@ namespace libtorrent
|
|||
catch (std::exception)
|
||||
{
|
||||
std::wstring ret;
|
||||
for (const char* i = &s[0]; i < &s[0] + s.size(); ++i)
|
||||
const char* end = &s[0] + s.size();
|
||||
for (const char* i = &s[0]; i < end;)
|
||||
{
|
||||
wchar_t c;
|
||||
c = '.';
|
||||
std::mbtowc(&c, i, 1);
|
||||
wchar_t c = '.';
|
||||
int result = std::mbtowc(&c, i, end - i);
|
||||
if (result > 0) i += result;
|
||||
else ++i;
|
||||
ret += c;
|
||||
}
|
||||
return ret;
|
||||
|
|
|
@ -1861,7 +1861,12 @@ namespace libtorrent
|
|||
int max_assignable = m_bandwidth_limit[channel].max_assignable();
|
||||
return max_assignable > max_bandwidth_block_size
|
||||
|| (m_bandwidth_limit[channel].throttle() < max_bandwidth_block_size
|
||||
&& max_assignable > 0);
|
||||
&& max_assignable == m_bandwidth_limit[channel].throttle());
|
||||
}
|
||||
|
||||
int torrent::bandwidth_throttle(int channel) const
|
||||
{
|
||||
return m_bandwidth_limit[channel].throttle();
|
||||
}
|
||||
|
||||
void torrent::request_bandwidth(int channel
|
||||
|
|
Loading…
Reference in New Issue