fixed bugs reported by Massaroddel. Tracker request peer-count could be incorrect. Empty files were not created in full allocation mode.

This commit is contained in:
Arvid Norberg 2006-07-08 19:41:39 +00:00
parent 175fb8770b
commit 4403eac97b
6 changed files with 40 additions and 4 deletions

View File

@ -1,5 +1,8 @@
release 0.10
* fixed a bug where the requested number of peers in a tracker request could
be too big.
* fixed a bug where empty files were not created in full allocation mode.
* fixed a bug in storage that would, in rare cases, fail to do a
complete check.
* exposed more settings for tweaking parameters in the piece-picker,

View File

@ -171,7 +171,7 @@ namespace libtorrent
int num_peers() const
{
return m_num_peers;
return m_peers.size();
}
int num_uploads() const
@ -223,7 +223,6 @@ namespace libtorrent
std::vector<peer> m_peers;
int m_num_peers;
torrent* m_torrent;
// the number of unchoked peers

View File

@ -212,6 +212,11 @@ namespace libtorrent
assert(m_open_mode & mode_out);
assert(m_fd != -1);
// Test this a bit more, what happens with random failures in
// the files?
// if ((rand() % 100) > 80)
// throw file_error("debug");
size_type ret = ::write(m_fd, buf, num_bytes);
if (ret == -1)
{

View File

@ -44,6 +44,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/alert_types.hpp"
#include "libtorrent/invariant_check.hpp"
#include "libtorrent/io.hpp"
#include "libtorrent/file.hpp"
#include "libtorrent/version.hpp"
using namespace boost::posix_time;
@ -1763,6 +1764,25 @@ namespace libtorrent
setup_receive();
}
catch (file_error& e)
{
session_impl::mutex_t::scoped_lock l(m_ses.m_mutex);
boost::shared_ptr<torrent> t = m_torrent.lock();
if (!t)
{
m_ses.connection_failed(m_socket, remote(), e.what());
return;
}
if (t->alerts().should_post(alert::fatal))
{
t->alerts().post_alert(
file_error_alert(t->get_handle()
, std::string("torrent paused: ") + e.what()));
}
t->pause();
}
catch (std::exception& e)
{
session_impl::mutex_t::scoped_lock l(m_ses.m_mutex);

View File

@ -350,8 +350,7 @@ namespace
namespace libtorrent
{
policy::policy(torrent* t)
: m_num_peers(0)
, m_torrent(t)
: m_torrent(t)
// , m_max_uploads(std::numeric_limits<int>::max())
// , m_max_connections(std::numeric_limits<int>::max())
, m_num_unchoked(0)

View File

@ -1482,6 +1482,13 @@ namespace libtorrent
end_iter = m_info.end_files(); file_iter != end_iter; ++file_iter)
{
path dir = (m_save_path / file_iter->path).branch_path();
// if the file is empty, just create it. But also make sure
// the directory exits.
if (dir == last_path
&& file_iter->size == 0)
file(m_save_path / file_iter->path, file::out);
if (dir == last_path) continue;
last_path = dir;
@ -1492,6 +1499,9 @@ namespace libtorrent
if (!exists(last_path))
create_directories(last_path);
#endif
if (file_iter->size == 0)
file(m_save_path / file_iter->path, file::out);
}
m_current_slot = 0;
m_state = state_full_check;