lt sync 3129

This commit is contained in:
Andrew Resch 2009-01-04 08:48:46 +00:00
parent 5c839a6b20
commit d850b71561
6 changed files with 25 additions and 8 deletions

View File

@ -300,6 +300,7 @@ void bind_session()
.def("stop_dht", allow_threads(&session::stop_dht), session_stop_dht_doc)
.def("dht_state", allow_threads(&session::dht_state), session_dht_state_doc)
.def("set_dht_proxy", allow_threads(&session::set_dht_proxy))
.def("dht_proxy", allow_threads(&session::dht_proxy), return_value_policy<copy_const_reference>())
#endif
.def("add_torrent", &add_torrent, session_add_torrent_doc)
#ifndef TORRENT_NO_DEPRECATE
@ -373,6 +374,9 @@ void bind_session()
.def("set_peer_proxy", allow_threads(&session::set_peer_proxy))
.def("set_tracker_proxy", allow_threads(&session::set_tracker_proxy))
.def("set_web_seed_proxy", allow_threads(&session::set_web_seed_proxy))
.def("peer_proxy", allow_threads(&session::peer_proxy), return_value_policy<copy_const_reference>())
.def("tracker_proxy", allow_threads(&session::tracker_proxy), return_value_policy<copy_const_reference>())
.def("web_seed_proxy", allow_threads(&session::web_seed_proxy), return_value_policy<copy_const_reference>())
.def("start_upnp", &start_upnp, session_start_upnp_doc)
.def("stop_upnp", allow_threads(&session::stop_upnp), session_stop_upnp_doc)
.def("start_lsd", allow_threads(&session::start_lsd), session_start_lsd_doc)

View File

@ -452,7 +452,7 @@ namespace libtorrent
{
l.unlock();
ret += p.storage->read_impl(p.blocks[i], p.piece, piece_offset, block_size);
if (!p.storage->error()) { return -1; }
if (p.storage->error()) { return -1; }
l.lock();
++m_cache_stats.reads;
}

View File

@ -298,7 +298,7 @@ namespace libtorrent { namespace dht
int peers = 0;
std::for_each(m_dht.begin_data(), m_dht.end_data(), count_peers(peers));
std::ofstream pc("libtorrent_logs/dht_stats.log", std::ios_base::app);
std::ofstream pc("libtorrent_logs/dht_stats.log", first ? std::ios_base::trunc : std::ios_base::app);
if (first)
{
first = false;

View File

@ -263,7 +263,7 @@ bool rpc_manager::incoming(msg const& m)
}
#ifdef TORRENT_DHT_VERBOSE_LOGGING
std::ofstream reply_stats("libtorrent_logs/round_trip_ms.log", std::ios::app);
std::ofstream reply_stats("round_trip_ms.log", std::ios::app);
reply_stats << m.addr << "\t" << total_milliseconds(time_now() - o->sent)
<< std::endl;
#endif

View File

@ -3421,6 +3421,8 @@ namespace libtorrent
TORRENT_ASSERT(m_torrent_file->is_valid());
INVARIANT_CHECK;
if (m_abort) return;
// we might be finished already, in which case we should
// not switch to downloading mode.
if (m_state != torrent_status::finished)

View File

@ -74,13 +74,12 @@ namespace
str += 0x80 | (chr & 0x3f);
}
void verify_encoding(file_entry& target)
bool verify_encoding(std::string& target)
{
std::string tmp_path;
std::string file_path = target.path.string();
bool valid_encoding = true;
for (std::string::iterator i = file_path.begin()
, end(file_path.end()); i != end; ++i)
for (std::string::iterator i = target.begin()
, end(target.end()); i != end; ++i)
{
// valid ascii-character
if ((*i & 0x80) == 0)
@ -153,7 +152,14 @@ namespace
// save the original encoding and replace the
// commonly used path with the correctly
// encoded string
if (!valid_encoding) target.path = tmp_path;
if (!valid_encoding) target = tmp_path;
return valid_encoding;
}
void verify_encoding(file_entry& target)
{
std::string p = target.path.string();
if (!verify_encoding(p)) target.path = p;
}
bool extract_single_file(lazy_entry const& dict, file_entry& target
@ -420,6 +426,9 @@ namespace libtorrent
error = "invalid 'name' of torrent (possible exploit attempt)";
return false;
}
// correct utf-8 encoding errors
verify_encoding(name);
// extract file list
lazy_entry const* i = info.dict_find_list("files");
@ -573,9 +582,11 @@ namespace libtorrent
m_comment = torrent_file.dict_find_string_value("comment.utf-8");
if (m_comment.empty()) m_comment = torrent_file.dict_find_string_value("comment");
verify_encoding(m_comment);
m_created_by = torrent_file.dict_find_string_value("created by.utf-8");
if (m_created_by.empty()) m_created_by = torrent_file.dict_find_string_value("created by");
verify_encoding(m_created_by);
lazy_entry const* info = torrent_file.dict_find_dict("info");
if (info == 0)