fixed division by zero in get_peer_info()

This commit is contained in:
Arvid Norberg 2009-10-03 15:24:59 +00:00
parent 0e1183f45e
commit ac2ef7dd39
2 changed files with 13 additions and 4 deletions

View File

@ -81,6 +81,7 @@ release 0.14.7
* improved invalid filename character replacement
* improved forward compatibility in DHT
* added set_piece_hashes that takes a callback to the python binding
* fixed division by zero in get_peer_info()
release 0.14.6

View File

@ -3250,13 +3250,21 @@ namespace libtorrent
p.write_state = m_channel_state[upload_channel];
p.read_state = m_channel_state[download_channel];
// pieces may be empty if we don't have metadata yet
if (p.pieces.size() == 0)
{
p.progress = 0.f;
p.progress_ppm = 0;
}
else
{
#if TORRENT_NO_FPU
p.progress = 0.f;
p.progress = 0.f;
#else
p.progress = (float)p.pieces.count() / (float)p.pieces.size();
p.progress = (float)p.pieces.count() / (float)p.pieces.size();
#endif
p.progress_ppm = p.pieces.count() * 1000000 / p.pieces.size();
p.progress_ppm = p.pieces.count() * 1000000 / p.pieces.size();
}
}
// allocates a disk buffer of size 'disk_buffer_size' and replaces the