bandwidth management fix + improved string conversion fallback in case strings are incorrect in torrent
This commit is contained in:
@@ -207,6 +207,8 @@ namespace libtorrent
|
|||||||
void expire_bandwidth(int channel, int amount);
|
void expire_bandwidth(int channel, int amount);
|
||||||
void assign_bandwidth(int channel, int amount);
|
void assign_bandwidth(int channel, int amount);
|
||||||
|
|
||||||
|
int bandwidth_throttle(int channel) const;
|
||||||
|
|
||||||
// --------------------------------------------
|
// --------------------------------------------
|
||||||
// PEER MANAGEMENT
|
// PEER MANAGEMENT
|
||||||
|
|
||||||
|
@@ -218,6 +218,10 @@ namespace libtorrent
|
|||||||
t->expire_bandwidth(m_channel, -1);
|
t->expire_bandwidth(m_channel, -1);
|
||||||
continue;
|
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
|
// so, hand out max_assignable, but no more than
|
||||||
// the available bandwidth (amount) and no more
|
// the available bandwidth (amount) and no more
|
||||||
|
@@ -91,11 +91,13 @@ namespace libtorrent
|
|||||||
catch (std::exception)
|
catch (std::exception)
|
||||||
{
|
{
|
||||||
std::wstring ret;
|
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;
|
wchar_t c = '.';
|
||||||
c = '.';
|
int result = std::mbtowc(&c, i, end - i);
|
||||||
std::mbtowc(&c, i, 1);
|
if (result > 0) i += result;
|
||||||
|
else ++i;
|
||||||
ret += c;
|
ret += c;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
@@ -1861,7 +1861,12 @@ namespace libtorrent
|
|||||||
int max_assignable = m_bandwidth_limit[channel].max_assignable();
|
int max_assignable = m_bandwidth_limit[channel].max_assignable();
|
||||||
return max_assignable > max_bandwidth_block_size
|
return max_assignable > max_bandwidth_block_size
|
||||||
|| (m_bandwidth_limit[channel].throttle() < 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
|
void torrent::request_bandwidth(int channel
|
||||||
|
Reference in New Issue
Block a user