forked from premiere/premiere-libtorrent
error_code fix. added is_error_code_enum template specialization and using the abbreviated syntax to build error_codes
This commit is contained in:
parent
6070c59b46
commit
1f5859d31f
|
@ -211,7 +211,7 @@ namespace libtorrent
|
|||
inline void throw_type_error()
|
||||
{
|
||||
throw libtorrent_exception(error_code(errors::invalid_entry_type
|
||||
, libtorrent_category));
|
||||
, get_libtorrent_category()));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -200,13 +200,35 @@ namespace libtorrent
|
|||
error_code_max
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#if BOOST_VERSION >= 103500
|
||||
|
||||
namespace boost { namespace system {
|
||||
|
||||
template<> struct is_error_code_enum<libtorrent::errors::error_code_enum>
|
||||
{ static const bool value = true; };
|
||||
|
||||
template<> struct is_error_condition_enum<libtorrent::errors::error_code_enum>
|
||||
{ static const bool value = true; };
|
||||
} }
|
||||
|
||||
#endif
|
||||
|
||||
namespace libtorrent
|
||||
{
|
||||
|
||||
#if BOOST_VERSION < 103500
|
||||
typedef asio::error_code error_code;
|
||||
inline asio::error::error_category get_posix_category() { return asio::error::system_category; }
|
||||
inline asio::error::error_category get_system_category() { return asio::error::system_category; }
|
||||
|
||||
extern TORRENT_EXPORT asio::error::error_category libtorrent_category;
|
||||
boost::system::error_category const& get_libtorrent_category()
|
||||
{
|
||||
static ::asio::error::error_category libtorrent_category(20);
|
||||
return libtorrent_category;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
struct TORRENT_EXPORT libtorrent_error_category : boost::system::error_category
|
||||
|
@ -217,7 +239,19 @@ namespace libtorrent
|
|||
{ return boost::system::error_condition(ev, *this); }
|
||||
};
|
||||
|
||||
extern TORRENT_EXPORT libtorrent_error_category libtorrent_category;
|
||||
inline boost::system::error_category& get_libtorrent_category()
|
||||
{
|
||||
static libtorrent_error_category libtorrent_category;
|
||||
return libtorrent_category;
|
||||
}
|
||||
|
||||
namespace errors
|
||||
{
|
||||
inline boost::system::error_code make_error_code(error_code_enum e)
|
||||
{
|
||||
return boost::system::error_code(e, get_libtorrent_category());
|
||||
}
|
||||
}
|
||||
|
||||
using boost::system::error_code;
|
||||
inline boost::system::error_category const& get_system_category()
|
||||
|
@ -227,8 +261,8 @@ namespace libtorrent
|
|||
{ return boost::system::get_posix_category(); }
|
||||
#else
|
||||
{ return boost::system::get_generic_category(); }
|
||||
#endif
|
||||
#endif
|
||||
#endif // BOOST_VERSION < 103600
|
||||
#endif // BOOST_VERSION < 103500
|
||||
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
struct TORRENT_EXPORT libtorrent_exception: std::exception
|
||||
|
|
|
@ -393,7 +393,7 @@ namespace libtorrent
|
|||
m_dh_key_exchange.reset(new (std::nothrow) dh_key_exchange);
|
||||
if (!m_dh_key_exchange || !m_dh_key_exchange->good())
|
||||
{
|
||||
disconnect(error_code(errors::no_memory, libtorrent_category));
|
||||
disconnect(errors::no_memory);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -406,7 +406,7 @@ namespace libtorrent
|
|||
buffer::interval send_buf = allocate_send_buffer(dh_key_len + pad_size);
|
||||
if (send_buf.begin == 0)
|
||||
{
|
||||
disconnect(error_code(errors::no_memory, libtorrent_category));
|
||||
disconnect(errors::no_memory);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -624,7 +624,7 @@ namespace libtorrent
|
|||
m_RC4_handler.reset(new (std::nothrow) RC4_handler(local_key, remote_key));
|
||||
if (!m_RC4_handler)
|
||||
{
|
||||
disconnect(error_code(errors::no_memory, libtorrent_category));
|
||||
disconnect(errors::no_memory);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -887,7 +887,7 @@ namespace libtorrent
|
|||
m_statistics.received_bytes(0, received);
|
||||
if (packet_size() != 1)
|
||||
{
|
||||
disconnect(error_code(errors::invalid_choke, libtorrent_category), 2);
|
||||
disconnect(errors::invalid_choke, 2);
|
||||
return;
|
||||
}
|
||||
if (!packet_finished()) return;
|
||||
|
@ -937,7 +937,7 @@ namespace libtorrent
|
|||
m_statistics.received_bytes(0, received);
|
||||
if (packet_size() != 1)
|
||||
{
|
||||
disconnect(error_code(errors::invalid_unchoke, libtorrent_category), 2);
|
||||
disconnect(errors::invalid_unchoke, 2);
|
||||
return;
|
||||
}
|
||||
if (!packet_finished()) return;
|
||||
|
@ -957,7 +957,7 @@ namespace libtorrent
|
|||
m_statistics.received_bytes(0, received);
|
||||
if (packet_size() != 1)
|
||||
{
|
||||
disconnect(error_code(errors::invalid_interested, libtorrent_category), 2);
|
||||
disconnect(errors::invalid_interested, 2);
|
||||
return;
|
||||
}
|
||||
if (!packet_finished()) return;
|
||||
|
@ -977,7 +977,7 @@ namespace libtorrent
|
|||
m_statistics.received_bytes(0, received);
|
||||
if (packet_size() != 1)
|
||||
{
|
||||
disconnect(error_code(errors::invalid_not_interested, libtorrent_category), 2);
|
||||
disconnect(errors::invalid_not_interested, 2);
|
||||
return;
|
||||
}
|
||||
if (!packet_finished()) return;
|
||||
|
@ -997,7 +997,7 @@ namespace libtorrent
|
|||
m_statistics.received_bytes(0, received);
|
||||
if (packet_size() != 5)
|
||||
{
|
||||
disconnect(error_code(errors::invalid_have, libtorrent_category), 2);
|
||||
disconnect(errors::invalid_have, 2);
|
||||
return;
|
||||
}
|
||||
if (!packet_finished()) return;
|
||||
|
@ -1029,7 +1029,7 @@ namespace libtorrent
|
|||
if (t->valid_metadata()
|
||||
&& packet_size() - 1 != (t->torrent_file().num_pieces() + 7) / 8)
|
||||
{
|
||||
disconnect(error_code(errors::invalid_bitfield_size, libtorrent_category), 2);
|
||||
disconnect(errors::invalid_bitfield_size, 2);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1056,7 +1056,7 @@ namespace libtorrent
|
|||
m_statistics.received_bytes(0, received);
|
||||
if (packet_size() != 13)
|
||||
{
|
||||
disconnect(error_code(errors::invalid_request, libtorrent_category), 2);
|
||||
disconnect(errors::invalid_request, 2);
|
||||
return;
|
||||
}
|
||||
if (!packet_finished()) return;
|
||||
|
@ -1111,7 +1111,7 @@ namespace libtorrent
|
|||
|
||||
if (list_size > packet_size() - 13)
|
||||
{
|
||||
disconnect(error_code(errors::invalid_hash_list, libtorrent_category), 2);
|
||||
disconnect(errors::invalid_hash_list, 2);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1209,7 +1209,7 @@ namespace libtorrent
|
|||
lazy_entry hash_list;
|
||||
if (lazy_bdecode(recv_buffer.begin + 13, recv_buffer.end + 13 + list_size, hash_list) != 0)
|
||||
{
|
||||
disconnect(error_code(errors::invalid_hash_piece, libtorrent_category), 2);
|
||||
disconnect(errors::invalid_hash_piece, 2);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1217,7 +1217,7 @@ namespace libtorrent
|
|||
// [ [node-index, hash], [node-index, hash], ... ]
|
||||
if (hash_list.type() != lazy_entry::list_t)
|
||||
{
|
||||
disconnect(error_code(errors::invalid_hash_list, libtorrent_category), 2);
|
||||
disconnect(errors::invalid_hash_list, 2);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1243,7 +1243,7 @@ namespace libtorrent
|
|||
#endif
|
||||
if (!nodes.empty() && !t->add_merkle_nodes(nodes, p.piece))
|
||||
{
|
||||
disconnect(error_code(errors::invalid_hash_piece, libtorrent_category), 2);
|
||||
disconnect(errors::invalid_hash_piece, 2);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -1264,7 +1264,7 @@ namespace libtorrent
|
|||
m_statistics.received_bytes(0, received);
|
||||
if (packet_size() != 13)
|
||||
{
|
||||
disconnect(error_code(errors::invalid_cancel, libtorrent_category), 2);
|
||||
disconnect(errors::invalid_cancel, 2);
|
||||
return;
|
||||
}
|
||||
if (!packet_finished()) return;
|
||||
|
@ -1292,12 +1292,12 @@ namespace libtorrent
|
|||
m_statistics.received_bytes(0, received);
|
||||
if (!m_supports_dht_port)
|
||||
{
|
||||
disconnect(error_code(errors::invalid_dht_port, libtorrent_category), 2);
|
||||
disconnect(errors::invalid_dht_port, 2);
|
||||
return;
|
||||
}
|
||||
if (packet_size() != 3)
|
||||
{
|
||||
disconnect(error_code(errors::invalid_dht_port, libtorrent_category), 2);
|
||||
disconnect(errors::invalid_dht_port, 2);
|
||||
return;
|
||||
}
|
||||
if (!packet_finished()) return;
|
||||
|
@ -1317,7 +1317,7 @@ namespace libtorrent
|
|||
m_statistics.received_bytes(0, received);
|
||||
if (!m_supports_fast)
|
||||
{
|
||||
disconnect(error_code(errors::invalid_suggest, libtorrent_category), 2);
|
||||
disconnect(errors::invalid_suggest, 2);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1337,7 +1337,7 @@ namespace libtorrent
|
|||
m_statistics.received_bytes(0, received);
|
||||
if (!m_supports_fast)
|
||||
{
|
||||
disconnect(error_code(errors::invalid_have_all, libtorrent_category), 2);
|
||||
disconnect(errors::invalid_have_all, 2);
|
||||
return;
|
||||
}
|
||||
incoming_have_all();
|
||||
|
@ -1350,7 +1350,7 @@ namespace libtorrent
|
|||
m_statistics.received_bytes(0, received);
|
||||
if (!m_supports_fast)
|
||||
{
|
||||
disconnect(error_code(errors::invalid_have_none, libtorrent_category), 2);
|
||||
disconnect(errors::invalid_have_none, 2);
|
||||
return;
|
||||
}
|
||||
incoming_have_none();
|
||||
|
@ -1363,7 +1363,7 @@ namespace libtorrent
|
|||
m_statistics.received_bytes(0, received);
|
||||
if (!m_supports_fast)
|
||||
{
|
||||
disconnect(error_code(errors::invalid_reject, libtorrent_category), 2);
|
||||
disconnect(errors::invalid_reject, 2);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1387,7 +1387,7 @@ namespace libtorrent
|
|||
m_statistics.received_bytes(0, received);
|
||||
if (!m_supports_fast)
|
||||
{
|
||||
disconnect(error_code(errors::invalid_allow_fast, libtorrent_category), 2);
|
||||
disconnect(errors::invalid_allow_fast, 2);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1411,13 +1411,13 @@ namespace libtorrent
|
|||
m_statistics.received_bytes(0, received);
|
||||
if (packet_size() < 2)
|
||||
{
|
||||
disconnect(error_code(errors::invalid_extended, libtorrent_category), 2);
|
||||
disconnect(errors::invalid_extended, 2);
|
||||
return;
|
||||
}
|
||||
|
||||
if (associated_torrent().expired())
|
||||
{
|
||||
disconnect(error_code(errors::invalid_extended, libtorrent_category), 2);
|
||||
disconnect(errors::invalid_extended, 2);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1452,7 +1452,7 @@ namespace libtorrent
|
|||
}
|
||||
#endif
|
||||
|
||||
disconnect(error_code(errors::invalid_message, libtorrent_category), 2);
|
||||
disconnect(errors::invalid_message, 2);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1544,7 +1544,7 @@ namespace libtorrent
|
|||
// if we're finished and this peer is uploading only
|
||||
// disconnect it
|
||||
if (t->is_finished() && upload_only())
|
||||
disconnect(error_code(errors::upload_upload_connection, libtorrent_category));
|
||||
disconnect(errors::upload_upload_connection);
|
||||
}
|
||||
|
||||
bool bt_peer_connection::dispatch_message(int received)
|
||||
|
@ -1581,7 +1581,7 @@ namespace libtorrent
|
|||
#endif
|
||||
|
||||
m_statistics.received_bytes(0, received);
|
||||
disconnect(error_code(errors::invalid_message, libtorrent_category));
|
||||
disconnect(errors::invalid_message);
|
||||
return packet_finished();
|
||||
}
|
||||
|
||||
|
@ -2086,7 +2086,7 @@ namespace libtorrent
|
|||
// read dh key, generate shared secret
|
||||
if (m_dh_key_exchange->compute_secret(recv_buffer.begin) == -1)
|
||||
{
|
||||
disconnect(error_code(errors::no_memory, libtorrent_category));
|
||||
disconnect(errors::no_memory);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2143,7 +2143,7 @@ namespace libtorrent
|
|||
m_statistics.received_bytes(0, bytes_transferred);
|
||||
|
||||
if (packet_finished())
|
||||
disconnect(error_code(errors::sync_hash_not_found, libtorrent_category), 2);
|
||||
disconnect(errors::sync_hash_not_found, 2);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2160,7 +2160,7 @@ namespace libtorrent
|
|||
if (!m_sync_hash)
|
||||
{
|
||||
m_statistics.received_bytes(0, bytes_transferred);
|
||||
disconnect(error_code(errors::no_memory, libtorrent_category));
|
||||
disconnect(errors::no_memory);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -2177,7 +2177,7 @@ namespace libtorrent
|
|||
m_sync_bytes_read += bytes_processed;
|
||||
if (m_sync_bytes_read >= 512)
|
||||
{
|
||||
disconnect(error_code(errors::sync_hash_not_found, libtorrent_category), 2);
|
||||
disconnect(errors::sync_hash_not_found, 2);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2251,7 +2251,7 @@ namespace libtorrent
|
|||
|
||||
if (!m_RC4_handler.get())
|
||||
{
|
||||
disconnect(error_code(errors::invalid_info_hash, libtorrent_category), 2);
|
||||
disconnect(errors::invalid_info_hash, 2);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2263,7 +2263,7 @@ namespace libtorrent
|
|||
const char sh_vc[] = {0,0,0,0, 0,0,0,0};
|
||||
if (!std::equal(sh_vc, sh_vc+8, recv_buffer.begin + 20))
|
||||
{
|
||||
disconnect(error_code(errors::invalid_encryption_constant, libtorrent_category), 2);
|
||||
disconnect(errors::invalid_encryption_constant, 2);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2286,7 +2286,7 @@ namespace libtorrent
|
|||
{
|
||||
m_statistics.received_bytes(0, bytes_transferred);
|
||||
if (packet_finished())
|
||||
disconnect(error_code(errors::invalid_encryption_constant, libtorrent_category), 2);
|
||||
disconnect(errors::invalid_encryption_constant, 2);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2298,7 +2298,7 @@ namespace libtorrent
|
|||
m_sync_vc.reset(new (std::nothrow) char[8]);
|
||||
if (!m_sync_vc)
|
||||
{
|
||||
disconnect(error_code(errors::no_memory, libtorrent_category));
|
||||
disconnect(errors::no_memory);
|
||||
return;
|
||||
}
|
||||
std::fill(m_sync_vc.get(), m_sync_vc.get() + 8, 0);
|
||||
|
@ -2318,7 +2318,7 @@ namespace libtorrent
|
|||
|
||||
if (m_sync_bytes_read >= 512)
|
||||
{
|
||||
disconnect(error_code(errors::invalid_encryption_constant, libtorrent_category), 2);
|
||||
disconnect(errors::invalid_encryption_constant, 2);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2388,7 +2388,7 @@ namespace libtorrent
|
|||
case pe_settings::plaintext:
|
||||
if (!(crypto_field & 0x01))
|
||||
{
|
||||
disconnect(error_code(errors::no_plaintext_mode, libtorrent_category), 1);
|
||||
disconnect(errors::no_plaintext_mode, 1);
|
||||
return;
|
||||
}
|
||||
crypto_select = 0x01;
|
||||
|
@ -2396,7 +2396,7 @@ namespace libtorrent
|
|||
case pe_settings::rc4:
|
||||
if (!(crypto_field & 0x02))
|
||||
{
|
||||
disconnect(error_code(errors::no_rc4_mode, libtorrent_category), 1);
|
||||
disconnect(errors::no_rc4_mode, 1);
|
||||
return;
|
||||
}
|
||||
crypto_select = 0x02;
|
||||
|
@ -2418,7 +2418,7 @@ namespace libtorrent
|
|||
}
|
||||
if (!crypto_select)
|
||||
{
|
||||
disconnect(error_code(errors::unsupported_encryption_mode, libtorrent_category), 1);
|
||||
disconnect(errors::unsupported_encryption_mode, 1);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
@ -2436,8 +2436,7 @@ namespace libtorrent
|
|||
{
|
||||
if (allowed_enc_level == pe_settings::plaintext)
|
||||
{
|
||||
disconnect(error_code(errors::unsupported_encryption_mode_selected
|
||||
, libtorrent_category), 2);
|
||||
disconnect(errors::unsupported_encryption_mode_selected, 2);
|
||||
return;
|
||||
}
|
||||
m_rc4_encrypted = true;
|
||||
|
@ -2446,16 +2445,14 @@ namespace libtorrent
|
|||
{
|
||||
if (allowed_enc_level == pe_settings::rc4)
|
||||
{
|
||||
disconnect(error_code(errors::unsupported_encryption_mode_selected
|
||||
, libtorrent_category), 2);
|
||||
disconnect(errors::unsupported_encryption_mode_selected, 2);
|
||||
return;
|
||||
}
|
||||
m_rc4_encrypted = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
disconnect(error_code(errors::unsupported_encryption_mode_selected
|
||||
, libtorrent_category), 2);
|
||||
disconnect(errors::unsupported_encryption_mode_selected, 2);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -2463,7 +2460,7 @@ namespace libtorrent
|
|||
int len_pad = detail::read_int16(recv_buffer.begin);
|
||||
if (len_pad < 0 || len_pad > 512)
|
||||
{
|
||||
disconnect(error_code(errors::invalid_pad_size, libtorrent_category), 2);
|
||||
disconnect(errors::invalid_pad_size, 2);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2503,7 +2500,7 @@ namespace libtorrent
|
|||
|
||||
if (len_ia < 0)
|
||||
{
|
||||
disconnect(error_code(errors::invalid_encrypt_handshake, libtorrent_category), 2);
|
||||
disconnect(errors::invalid_encrypt_handshake, 2);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2622,7 +2619,7 @@ namespace libtorrent
|
|||
#ifndef TORRENT_DISABLE_ENCRYPTION
|
||||
if (!is_local() && m_ses.get_pe_settings().in_enc_policy == pe_settings::disabled)
|
||||
{
|
||||
disconnect(error_code(errors::no_incoming_encrypted, libtorrent_category));
|
||||
disconnect(errors::no_incoming_encrypted);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2641,7 +2638,7 @@ namespace libtorrent
|
|||
|
||||
TORRENT_ASSERT((!is_local() && m_encrypted) || is_local());
|
||||
#endif // #ifndef TORRENT_DISABLE_ENCRYPTION
|
||||
disconnect(error_code(errors::invalid_info_hash, libtorrent_category), 2);
|
||||
disconnect(errors::invalid_info_hash, 2);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2652,7 +2649,7 @@ namespace libtorrent
|
|||
(m_ses.get_pe_settings().in_enc_policy == pe_settings::forced) &&
|
||||
!m_encrypted)
|
||||
{
|
||||
disconnect(error_code(errors::no_incoming_regular, libtorrent_category));
|
||||
disconnect(errors::no_incoming_regular);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
@ -2727,7 +2724,7 @@ namespace libtorrent
|
|||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
(*m_logger) << " received invalid info_hash\n";
|
||||
#endif
|
||||
disconnect(error_code(errors::invalid_info_hash, libtorrent_category), 2);
|
||||
disconnect(errors::invalid_info_hash, 2);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2806,12 +2803,11 @@ namespace libtorrent
|
|||
// if not, we should close the outgoing one.
|
||||
if (pid < m_ses.get_peer_id() && is_local())
|
||||
{
|
||||
(*i)->connection->disconnect(error_code(errors::duplicate_peer_id
|
||||
, libtorrent_category));
|
||||
(*i)->connection->disconnect(errors::duplicate_peer_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
disconnect(error_code(errors::duplicate_peer_id, libtorrent_category));
|
||||
disconnect(errors::duplicate_peer_id);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -2822,7 +2818,7 @@ namespace libtorrent
|
|||
if (pid == m_ses.get_peer_id())
|
||||
{
|
||||
if (peer_info_struct()) t->get_policy().ban_peer(peer_info_struct());
|
||||
disconnect(error_code(errors::self_connection, libtorrent_category), 1);
|
||||
disconnect(errors::self_connection, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2913,7 +2909,7 @@ namespace libtorrent
|
|||
{
|
||||
m_statistics.received_bytes(0, bytes_transferred);
|
||||
// packet too large
|
||||
disconnect(error_code(errors::packet_too_large, libtorrent_category), 2);
|
||||
disconnect(errors::packet_too_large, 2);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2945,7 +2941,7 @@ namespace libtorrent
|
|||
if (!t)
|
||||
{
|
||||
m_statistics.received_bytes(0, bytes_transferred);
|
||||
disconnect(error_code(errors::torrent_removed, libtorrent_category), 1);
|
||||
disconnect(errors::torrent_removed, 1);
|
||||
return;
|
||||
}
|
||||
#ifdef TORRENT_DEBUG
|
||||
|
|
|
@ -887,7 +887,7 @@ namespace libtorrent
|
|||
{
|
||||
// this means the file wasn't big enough for this read
|
||||
p.storage->get_storage_impl()->set_error(""
|
||||
, error_code(errors::file_too_short, libtorrent_category));
|
||||
, errors::file_too_short);
|
||||
free_piece(p, l);
|
||||
return -1;
|
||||
}
|
||||
|
@ -918,7 +918,7 @@ namespace libtorrent
|
|||
{
|
||||
// this means the file wasn't big enough for this read
|
||||
p.storage->get_storage_impl()->set_error(""
|
||||
, error_code(errors::file_too_short, libtorrent_category));
|
||||
, errors::file_too_short);
|
||||
free_piece(p, l);
|
||||
return -1;
|
||||
}
|
||||
|
@ -1612,7 +1612,7 @@ namespace libtorrent
|
|||
if (ret == -3)
|
||||
{
|
||||
j.storage->mark_failed(j.piece);
|
||||
j.error = error_code(errors::failed_hash_check, libtorrent_category);
|
||||
j.error = errors::failed_hash_check;
|
||||
j.str.clear();
|
||||
j.buffer = 0;
|
||||
break;
|
||||
|
@ -1680,7 +1680,7 @@ namespace libtorrent
|
|||
{
|
||||
// this means the file wasn't big enough for this read
|
||||
j.buffer = 0;
|
||||
j.error = error_code(errors::file_too_short, libtorrent_category);
|
||||
j.error = errors::file_too_short;
|
||||
j.error_file.clear();
|
||||
j.str.clear();
|
||||
ret = -1;
|
||||
|
|
|
@ -191,12 +191,6 @@ namespace libtorrent
|
|||
return msgs[ev];
|
||||
}
|
||||
|
||||
TORRENT_EXPORT libtorrent_error_category libtorrent_category;
|
||||
|
||||
#else
|
||||
|
||||
TORRENT_EXPORT ::asio::error::error_category libtorrent_category(20);
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
|
|
@ -166,7 +166,7 @@ namespace libtorrent
|
|||
++i;
|
||||
if (i == s.end())
|
||||
{
|
||||
ec = error_code(errors::invalid_escaped_string, libtorrent_category);
|
||||
ec = errors::invalid_escaped_string;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -176,14 +176,14 @@ namespace libtorrent
|
|||
else if(*i >= 'a' && *i <= 'f') high = *i + 10 - 'a';
|
||||
else
|
||||
{
|
||||
ec = error_code(errors::invalid_escaped_string, libtorrent_category);
|
||||
ec = errors::invalid_escaped_string;
|
||||
return ret;
|
||||
}
|
||||
|
||||
++i;
|
||||
if (i == s.end())
|
||||
{
|
||||
ec = error_code(errors::invalid_escaped_string, libtorrent_category);
|
||||
ec = errors::invalid_escaped_string;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -193,7 +193,7 @@ namespace libtorrent
|
|||
else if(*i >= 'a' && *i <= 'f') low = *i + 10 - 'a';
|
||||
else
|
||||
{
|
||||
ec = error_code(errors::invalid_escaped_string, libtorrent_category);
|
||||
ec = errors::invalid_escaped_string;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ namespace libtorrent
|
|||
// this means that another instance of the storage
|
||||
// is using the exact same file.
|
||||
#if BOOST_VERSION >= 103500
|
||||
ec = error_code(errors::file_collision, libtorrent_category);
|
||||
ec = errors::file_collision;
|
||||
#endif
|
||||
return boost::shared_ptr<file>();
|
||||
}
|
||||
|
|
|
@ -79,7 +79,7 @@ void http_connection::get(std::string const& url, time_duration timeout, int pri
|
|||
#endif
|
||||
)
|
||||
{
|
||||
error_code ec(errors::unsupported_url_protocol, libtorrent_category);
|
||||
error_code ec(errors::unsupported_url_protocol);
|
||||
m_resolver.get_io_service().post(boost::bind(&http_connection::callback
|
||||
, this, ec, (char*)0, 0));
|
||||
return;
|
||||
|
@ -215,7 +215,7 @@ void http_connection::start(std::string const& hostname, std::string const& port
|
|||
if (is_i2p && i2p_conn->proxy().type != proxy_settings::i2p_proxy)
|
||||
{
|
||||
m_resolver.get_io_service().post(boost::bind(&http_connection::callback
|
||||
, this, error_code(errors::no_i2p_router, libtorrent_category), (char*)0, 0));
|
||||
, this, error_code(errors::no_i2p_router, get_libtorrent_category()), (char*)0, 0));
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -278,7 +278,7 @@ namespace libtorrent
|
|||
TORRENT_ASSERT(!m_requests.empty());
|
||||
if (m_requests.empty())
|
||||
{
|
||||
disconnect(error_code(errors::http_error, libtorrent_category), 2);
|
||||
disconnect(errors::http_error, 2);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -297,7 +297,7 @@ namespace libtorrent
|
|||
|
||||
if (error)
|
||||
{
|
||||
disconnect(error_code(errors::http_parse_error, libtorrent_category), 2);
|
||||
disconnect(errors::http_parse_error, 2);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -327,7 +327,7 @@ namespace libtorrent
|
|||
m_ses.m_alerts.post_alert(url_seed_alert(t->get_handle(), url()
|
||||
, error_msg));
|
||||
}
|
||||
disconnect(error_code(errors::http_error, libtorrent_category), 1);
|
||||
disconnect(errors::http_error, 1);
|
||||
return;
|
||||
}
|
||||
if (!m_parser.header_finished())
|
||||
|
@ -351,14 +351,14 @@ namespace libtorrent
|
|||
{
|
||||
// we should not try this server again.
|
||||
t->remove_web_seed(m_url, web_seed_entry::http_seed);
|
||||
disconnect(error_code(errors::missing_location, libtorrent_category), 2);
|
||||
disconnect(errors::missing_location, 2);
|
||||
return;
|
||||
}
|
||||
|
||||
// add the redirected url and remove the current one
|
||||
t->add_web_seed(location, web_seed_entry::http_seed);
|
||||
t->remove_web_seed(m_url, web_seed_entry::http_seed);
|
||||
disconnect(error_code(errors::redirecting, libtorrent_category), 2);
|
||||
disconnect(errors::redirecting, 2);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -377,7 +377,7 @@ namespace libtorrent
|
|||
{
|
||||
// we should not try this server again.
|
||||
t->remove_web_seed(m_url, web_seed_entry::http_seed);
|
||||
disconnect(error_code(errors::no_content_length, libtorrent_category), 2);
|
||||
disconnect(errors::no_content_length, 2);
|
||||
return;
|
||||
}
|
||||
if (payload > m_response_left) payload = m_response_left;
|
||||
|
@ -413,7 +413,7 @@ namespace libtorrent
|
|||
// temporarily unavailable, retry later
|
||||
t->retry_web_seed(m_url, web_seed_entry::http_seed, retry_time);
|
||||
t->remove_web_seed(m_url, web_seed_entry::http_seed);
|
||||
disconnect(error_code(errors::http_error, libtorrent_category), 1);
|
||||
disconnect(errors::http_error, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -194,7 +194,7 @@ namespace libtorrent { namespace
|
|||
int ret = lazy_bdecode(body.begin, body.end, msg);
|
||||
if (ret != 0 || msg.type() != lazy_entry::dict_t)
|
||||
{
|
||||
m_pc.disconnect(error_code(errors::invalid_lt_tracker_message, libtorrent_category), 2);
|
||||
m_pc.disconnect(errors::invalid_lt_tracker_message, 2);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -152,13 +152,13 @@ namespace libtorrent
|
|||
std::string btih = url_has_argument(uri, "xt");
|
||||
if (btih.empty())
|
||||
{
|
||||
ec = error_code(errors::missing_info_hash_in_uri, libtorrent_category);
|
||||
ec = errors::missing_info_hash_in_uri;
|
||||
return torrent_handle();
|
||||
}
|
||||
|
||||
if (btih.compare(0, 9, "urn:btih:") != 0)
|
||||
{
|
||||
ec = error_code(errors::missing_info_hash_in_uri, libtorrent_category);
|
||||
ec = errors::missing_info_hash_in_uri;
|
||||
return torrent_handle();
|
||||
}
|
||||
|
||||
|
|
|
@ -367,7 +367,7 @@ namespace libtorrent { namespace
|
|||
|
||||
if (length > 500 * 1024)
|
||||
{
|
||||
m_pc.disconnect(error_code(errors::metadata_too_large, libtorrent_category), 2);
|
||||
m_pc.disconnect(errors::metadata_too_large, 2);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -392,7 +392,7 @@ namespace libtorrent { namespace
|
|||
if (length != 3)
|
||||
{
|
||||
// invalid metadata request
|
||||
m_pc.disconnect(error_code(errors::invalid_metadata_request, libtorrent_category), 2);
|
||||
m_pc.disconnect(errors::invalid_metadata_request, 2);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -417,22 +417,22 @@ namespace libtorrent { namespace
|
|||
|
||||
if (total_size > 500 * 1024)
|
||||
{
|
||||
m_pc.disconnect(error_code(errors::metadata_too_large, libtorrent_category), 2);
|
||||
m_pc.disconnect(errors::metadata_too_large, 2);
|
||||
return true;
|
||||
}
|
||||
if (total_size <= 0)
|
||||
{
|
||||
m_pc.disconnect(error_code(errors::invalid_metadata_size, libtorrent_category), 2);
|
||||
m_pc.disconnect(errors::invalid_metadata_size, 2);
|
||||
return true;
|
||||
}
|
||||
if (offset > total_size || offset < 0)
|
||||
{
|
||||
m_pc.disconnect(error_code(errors::invalid_metadata_offset, libtorrent_category), 2);
|
||||
m_pc.disconnect(errors::invalid_metadata_offset, 2);
|
||||
return true;
|
||||
}
|
||||
if (offset + data_size > total_size)
|
||||
{
|
||||
m_pc.disconnect(error_code(errors::invalid_metadata_message, libtorrent_category), 2);
|
||||
m_pc.disconnect(errors::invalid_metadata_message, 2);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -460,7 +460,7 @@ namespace libtorrent { namespace
|
|||
break;
|
||||
default:
|
||||
{
|
||||
m_pc.disconnect(error_code(errors::invalid_metadata_message, libtorrent_category), 2);
|
||||
m_pc.disconnect(errors::invalid_metadata_message, 2);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -463,13 +463,13 @@ void natpmp::on_reply(error_code const& e
|
|||
|
||||
m->expires = time_now() + hours(2);
|
||||
l.unlock();
|
||||
m_callback(index, 0, error_code(ev, libtorrent_category));
|
||||
m_callback(index, 0, error_code(ev, get_libtorrent_category()));
|
||||
l.lock();
|
||||
}
|
||||
else if (m->action == mapping_t::action_add)
|
||||
{
|
||||
l.unlock();
|
||||
m_callback(index, m->external_port, error_code(errors::no_error, libtorrent_category));
|
||||
m_callback(index, m->external_port, error_code(errors::no_error, get_libtorrent_category()));
|
||||
l.lock();
|
||||
}
|
||||
|
||||
|
|
|
@ -62,19 +62,19 @@ namespace libtorrent
|
|||
|
||||
if (end == url.end())
|
||||
{
|
||||
ec = error_code(errors::unsupported_url_protocol, libtorrent_category);
|
||||
ec = errors::unsupported_url_protocol;
|
||||
goto exit;
|
||||
}
|
||||
++end;
|
||||
if (end == url.end() || *end != '/')
|
||||
{
|
||||
ec = error_code(errors::unsupported_url_protocol, libtorrent_category);
|
||||
ec = errors::unsupported_url_protocol;
|
||||
goto exit;
|
||||
}
|
||||
++end;
|
||||
if (end == url.end() || *end != '/')
|
||||
{
|
||||
ec = error_code(errors::unsupported_url_protocol, libtorrent_category);
|
||||
ec = errors::unsupported_url_protocol;
|
||||
goto exit;
|
||||
}
|
||||
++end;
|
||||
|
@ -100,7 +100,7 @@ namespace libtorrent
|
|||
port_pos = std::find(start, url.end(), ']');
|
||||
if (port_pos == url.end())
|
||||
{
|
||||
ec = error_code(errors::expected_close_bracket_in_address, libtorrent_category);
|
||||
ec = errors::expected_close_bracket_in_address;
|
||||
goto exit;
|
||||
}
|
||||
port_pos = std::find(port_pos, url.end(), ':');
|
||||
|
|
|
@ -622,8 +622,7 @@ namespace libtorrent
|
|||
}
|
||||
|
||||
if (interesting) t->get_policy().peer_is_interesting(*this);
|
||||
else if (upload_only()) disconnect(error_code(
|
||||
errors::upload_upload_connection, libtorrent_category));
|
||||
else if (upload_only()) disconnect(errors::upload_upload_connection);
|
||||
}
|
||||
|
||||
void peer_connection::init()
|
||||
|
@ -989,7 +988,7 @@ namespace libtorrent
|
|||
(*m_logger) << " " << i->second->torrent_file().info_hash() << "\n";
|
||||
}
|
||||
#endif
|
||||
disconnect(error_code(errors::invalid_info_hash, libtorrent_category), 2);
|
||||
disconnect(errors::invalid_info_hash, 2);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1000,7 +999,7 @@ namespace libtorrent
|
|||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
|
||||
(*m_logger) << " rejected connection to paused torrent\n";
|
||||
#endif
|
||||
disconnect(error_code(errors::torrent_paused, libtorrent_category), 2);
|
||||
disconnect(errors::torrent_paused, 2);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1013,7 +1012,7 @@ namespace libtorrent
|
|||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
|
||||
(*m_logger) << " rejected regular connection to i2p torrent\n";
|
||||
#endif
|
||||
disconnect(error_code(errors::peer_banned, libtorrent_category), 2);
|
||||
disconnect(errors::peer_banned, 2);
|
||||
return;
|
||||
}
|
||||
#endif // TORRENT_USE_I2P
|
||||
|
@ -1482,7 +1481,7 @@ namespace libtorrent
|
|||
// if we got an invalid message, abort
|
||||
if (index >= int(m_have_piece.size()) || index < 0)
|
||||
{
|
||||
disconnect(error_code(errors::invalid_have, libtorrent_category), 2);
|
||||
disconnect(errors::invalid_have, 2);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1602,7 +1601,7 @@ namespace libtorrent
|
|||
if (t->valid_metadata()
|
||||
&& (bits.size() + 7) / 8 != (m_have_piece.size() + 7) / 8)
|
||||
{
|
||||
disconnect(error_code(errors::invalid_bitfield_size, libtorrent_category), 2);
|
||||
disconnect(errors::invalid_bitfield_size, 2);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1671,8 +1670,7 @@ namespace libtorrent
|
|||
m_num_pieces = num_pieces;
|
||||
|
||||
if (interesting) t->get_policy().peer_is_interesting(*this);
|
||||
else if (upload_only()) disconnect(error_code(
|
||||
errors::upload_upload_connection, libtorrent_category));
|
||||
else if (upload_only()) disconnect(errors::upload_upload_connection);
|
||||
}
|
||||
|
||||
void peer_connection::disconnect_if_redundant()
|
||||
|
@ -1686,7 +1684,7 @@ namespace libtorrent
|
|||
|
||||
if (m_upload_only && t->is_finished())
|
||||
{
|
||||
disconnect(error_code(errors::upload_upload_connection, libtorrent_category));
|
||||
disconnect(errors::upload_upload_connection);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1695,7 +1693,7 @@ namespace libtorrent
|
|||
&& m_bitfield_received
|
||||
&& t->are_files_checked())
|
||||
{
|
||||
disconnect(error_code(errors::uninteresting_upload_peer, libtorrent_category));
|
||||
disconnect(errors::uninteresting_upload_peer);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -1836,7 +1834,7 @@ namespace libtorrent
|
|||
|
||||
if (m_choke_rejects > m_ses.settings().max_rejects)
|
||||
{
|
||||
disconnect(error_code(errors::too_many_requests_when_choked, libtorrent_category));
|
||||
disconnect(errors::too_many_requests_when_choked);
|
||||
return;
|
||||
}
|
||||
else if ((m_choke_rejects & 0xf) == 0)
|
||||
|
@ -1926,7 +1924,7 @@ namespace libtorrent
|
|||
"start: " << r.start << " | "
|
||||
"length: " << r.length << " ]\n";
|
||||
#endif
|
||||
disconnect(error_code(errors::invalid_piece, libtorrent_category), 2);
|
||||
disconnect(errors::invalid_piece, 2);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2010,7 +2008,7 @@ namespace libtorrent
|
|||
char* buffer = m_ses.allocate_disk_buffer("receive buffer");
|
||||
if (buffer == 0)
|
||||
{
|
||||
disconnect(error_code(errors::no_memory, libtorrent_category));
|
||||
disconnect(errors::no_memory);
|
||||
return;
|
||||
}
|
||||
disk_buffer_holder holder(m_ses, buffer);
|
||||
|
@ -2084,7 +2082,7 @@ namespace libtorrent
|
|||
if (t->alerts().should_post<peer_error_alert>())
|
||||
{
|
||||
t->alerts().post_alert(peer_error_alert(t->get_handle(), m_remote
|
||||
, m_peer_id, error_code(errors::peer_sent_empty_piece, libtorrent_category)));
|
||||
, m_peer_id, errors::peer_sent_empty_piece));
|
||||
}
|
||||
// This is used as a reject-request by bitcomet
|
||||
incoming_reject_request(p);
|
||||
|
@ -3003,7 +3001,7 @@ namespace libtorrent
|
|||
(*m_ses.m_logger) << time_now_string() << " CONNECTION TIMED OUT: " << m_remote.address().to_string(ec)
|
||||
<< "\n";
|
||||
#endif
|
||||
disconnect(error_code(errors::timed_out, libtorrent_category), 1);
|
||||
disconnect(errors::timed_out, 1);
|
||||
}
|
||||
|
||||
// the error argument defaults to 0, which means deliberate disconnect
|
||||
|
@ -3307,7 +3305,7 @@ namespace libtorrent
|
|||
|
||||
if (disk_buffer_size > 16 * 1024)
|
||||
{
|
||||
disconnect(error_code(errors::invalid_piece_size, libtorrent_category), 2);
|
||||
disconnect(errors::invalid_piece_size, 2);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -3318,7 +3316,7 @@ namespace libtorrent
|
|||
m_disk_recv_buffer.reset(m_ses.allocate_disk_buffer("receive buffer"));
|
||||
if (!m_disk_recv_buffer)
|
||||
{
|
||||
disconnect(error_code(errors::no_memory, libtorrent_category));
|
||||
disconnect(errors::no_memory);
|
||||
return false;
|
||||
}
|
||||
m_disk_recv_buffer_size = disk_buffer_size;
|
||||
|
@ -3457,7 +3455,7 @@ namespace libtorrent
|
|||
{
|
||||
m_ses.m_half_open.done(m_connection_ticket);
|
||||
m_connecting = false;
|
||||
disconnect(error_code(errors::torrent_aborted, libtorrent_category));
|
||||
disconnect(errors::torrent_aborted);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -3482,7 +3480,7 @@ namespace libtorrent
|
|||
(*m_logger) << time_now_string() << " *** LAST ACTIVITY [ "
|
||||
<< total_seconds(d) << " seconds ago ] ***\n";
|
||||
#endif
|
||||
disconnect(error_code(errors::timed_out_inactivity, libtorrent_category));
|
||||
disconnect(errors::timed_out_inactivity);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -3495,7 +3493,7 @@ namespace libtorrent
|
|||
(*m_logger) << time_now_string() << " *** NO HANDSHAKE [ waited "
|
||||
<< total_seconds(d) << " seconds ] ***\n";
|
||||
#endif
|
||||
disconnect(error_code(errors::timed_out_no_handshake, libtorrent_category));
|
||||
disconnect(errors::timed_out_no_handshake);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -3514,7 +3512,7 @@ namespace libtorrent
|
|||
(*m_logger) << time_now_string() << " *** NO REQUEST [ t: "
|
||||
<< total_seconds(d) << " ] ***\n";
|
||||
#endif
|
||||
disconnect(error_code(errors::timed_out_no_request, libtorrent_category));
|
||||
disconnect(errors::timed_out_no_request);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -3543,7 +3541,7 @@ namespace libtorrent
|
|||
"t1: " << total_seconds(d1) << " | "
|
||||
"t2: " << total_seconds(d2) << " ] ***\n";
|
||||
#endif
|
||||
disconnect(error_code(errors::timed_out_no_interest, libtorrent_category));
|
||||
disconnect(errors::timed_out_no_interest);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -4241,7 +4239,7 @@ namespace libtorrent
|
|||
std::pair<char*, int> buffer = m_ses.allocate_buffer(size);
|
||||
if (buffer.first == 0)
|
||||
{
|
||||
disconnect(error_code(errors::no_memory, libtorrent_category));
|
||||
disconnect(errors::no_memory);
|
||||
return;
|
||||
}
|
||||
TORRENT_ASSERT(buffer.second >= size);
|
||||
|
@ -4266,7 +4264,7 @@ namespace libtorrent
|
|||
std::pair<char*, int> buffer = m_ses.allocate_buffer(size);
|
||||
if (buffer.first == 0)
|
||||
{
|
||||
disconnect(error_code(errors::no_memory, libtorrent_category));
|
||||
disconnect(errors::no_memory);
|
||||
return buffer::interval(0, 0);
|
||||
}
|
||||
TORRENT_ASSERT(buffer.second >= size);
|
||||
|
@ -4500,7 +4498,7 @@ namespace libtorrent
|
|||
|
||||
if (!t)
|
||||
{
|
||||
disconnect(error_code(errors::torrent_aborted, libtorrent_category));
|
||||
disconnect(errors::torrent_aborted);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -4610,7 +4608,7 @@ namespace libtorrent
|
|||
// to ourselves
|
||||
boost::shared_ptr<torrent> t = m_torrent.lock();
|
||||
if (m_peer_info && t) t->get_policy().ban_peer(m_peer_info);
|
||||
disconnect(error_code(errors::self_connection, libtorrent_category), 1);
|
||||
disconnect(errors::self_connection, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -307,7 +307,7 @@ namespace libtorrent
|
|||
|
||||
if ((*i)->connection)
|
||||
{
|
||||
(*i)->connection->disconnect(error_code(errors::banned_by_ip_filter, libtorrent_category));
|
||||
(*i)->connection->disconnect(errors::banned_by_ip_filter);
|
||||
if (ses.m_alerts.should_post<peer_blocked_alert>())
|
||||
ses.m_alerts.post_alert(peer_blocked_alert(m_torrent->get_handle(), (*i)->address()));
|
||||
TORRENT_ASSERT((*i)->connection == 0
|
||||
|
@ -633,7 +633,7 @@ namespace libtorrent
|
|||
&& ses.num_connections() >= ses.max_connections()
|
||||
&& c.remote().address() != m_torrent->current_tracker().address())
|
||||
{
|
||||
c.disconnect(error_code(errors::too_many_connections, libtorrent_category));
|
||||
c.disconnect(errors::too_many_connections);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -672,7 +672,7 @@ namespace libtorrent
|
|||
|
||||
if (i->banned)
|
||||
{
|
||||
c.disconnect(error_code(errors::peer_banned, libtorrent_category));
|
||||
c.disconnect(errors::peer_banned);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -697,8 +697,8 @@ namespace libtorrent
|
|||
|
||||
if (self_connection)
|
||||
{
|
||||
c.disconnect(error_code(errors::self_connection, libtorrent_category), 1);
|
||||
i->connection->disconnect(error_code(errors::self_connection, libtorrent_category), 1);
|
||||
c.disconnect(errors::self_connection, 1);
|
||||
i->connection->disconnect(errors::self_connection, 1);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -711,7 +711,7 @@ namespace libtorrent
|
|||
}
|
||||
else if (!i->connection->is_connecting() || c.is_local())
|
||||
{
|
||||
c.disconnect(error_code(errors::duplicate_peer_id, libtorrent_category));
|
||||
c.disconnect(errors::duplicate_peer_id);
|
||||
return false;
|
||||
}
|
||||
else
|
||||
|
@ -721,7 +721,7 @@ namespace libtorrent
|
|||
" is connecting and this connection is incoming. closing existing "
|
||||
"connection in favour of this one");
|
||||
#endif
|
||||
i->connection->disconnect(error_code(errors::duplicate_peer_id, libtorrent_category));
|
||||
i->connection->disconnect(errors::duplicate_peer_id);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -741,7 +741,7 @@ namespace libtorrent
|
|||
|
||||
if (int(m_peers.size()) >= m_torrent->settings().max_peerlist_size)
|
||||
{
|
||||
c.disconnect(error_code(errors::too_many_connections, libtorrent_category));
|
||||
c.disconnect(errors::too_many_connections);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -825,7 +825,7 @@ namespace libtorrent
|
|||
pp.source |= src;
|
||||
if (!was_conn_cand && is_connect_candidate(pp, m_finished))
|
||||
++m_num_connect_candidates;
|
||||
p->connection->disconnect(error_code(errors::duplicate_peer_id, libtorrent_category));
|
||||
p->connection->disconnect(errors::duplicate_peer_id);
|
||||
erase_peer(p);
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -634,7 +634,7 @@ namespace aux {
|
|||
#ifdef TORRENT_DEBUG
|
||||
int conn = m_connections.size();
|
||||
#endif
|
||||
(*m_connections.begin())->disconnect(error_code(errors::stopping_torrent, libtorrent_category));
|
||||
(*m_connections.begin())->disconnect(errors::stopping_torrent);
|
||||
TORRENT_ASSERT(conn == int(m_connections.size()) + 1);
|
||||
}
|
||||
|
||||
|
@ -1408,7 +1408,7 @@ namespace aux {
|
|||
// are ticked through the torrents' second_tick
|
||||
if (!p->associated_torrent().expired()) continue;
|
||||
if (m_last_tick - p->connected_time() > seconds(m_settings.handshake_timeout))
|
||||
p->disconnect(error_code(errors::timed_out, libtorrent_category));
|
||||
p->disconnect(errors::timed_out);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------
|
||||
|
@ -2203,7 +2203,7 @@ namespace aux {
|
|||
|
||||
if (params.ti && params.ti->num_files() == 0)
|
||||
{
|
||||
ec = error_code(errors::no_files_in_torrent, libtorrent_category);
|
||||
ec = errors::no_files_in_torrent;
|
||||
return torrent_handle();
|
||||
}
|
||||
|
||||
|
@ -2211,7 +2211,7 @@ namespace aux {
|
|||
|
||||
if (is_aborted())
|
||||
{
|
||||
ec = error_code(errors::session_is_closing, libtorrent_category);
|
||||
ec = errors::session_is_closing;
|
||||
return torrent_handle();
|
||||
}
|
||||
|
||||
|
@ -2227,7 +2227,7 @@ namespace aux {
|
|||
if (!params.duplicate_is_error)
|
||||
return torrent_handle(torrent_ptr);
|
||||
|
||||
ec = error_code(errors::duplicate_torrent, libtorrent_category);
|
||||
ec = errors::duplicate_torrent;
|
||||
return torrent_handle();
|
||||
}
|
||||
|
||||
|
|
|
@ -221,7 +221,7 @@ namespace
|
|||
#endif
|
||||
m_torrent.get_policy().ban_peer(p);
|
||||
if (p->connection) p->connection->disconnect(
|
||||
error_code(errors::peer_banned, libtorrent_category));
|
||||
errors::peer_banned);
|
||||
}
|
||||
// we already have this exact entry in the map
|
||||
// we don't have to insert it
|
||||
|
@ -284,7 +284,7 @@ namespace
|
|||
#endif
|
||||
m_torrent.get_policy().ban_peer(p);
|
||||
if (p->connection) p->connection->disconnect(
|
||||
error_code(errors::peer_banned, libtorrent_category));
|
||||
errors::peer_banned);
|
||||
}
|
||||
|
||||
torrent& m_torrent;
|
||||
|
|
|
@ -195,7 +195,7 @@ namespace libtorrent
|
|||
{
|
||||
if ((int)sizes.size() != fs.num_files())
|
||||
{
|
||||
error = error_code(errors::mismatching_number_of_files, libtorrent_category);
|
||||
error = errors::mismatching_number_of_files;
|
||||
return false;
|
||||
}
|
||||
p = complete(p);
|
||||
|
@ -222,7 +222,7 @@ namespace libtorrent
|
|||
if ((compact_mode && size != size_iter->first)
|
||||
|| (!compact_mode && size < size_iter->first))
|
||||
{
|
||||
error = error_code(errors::mismatching_file_size, libtorrent_category);
|
||||
error = errors::mismatching_file_size;
|
||||
return false;
|
||||
}
|
||||
// allow one second 'slack', because of FAT volumes
|
||||
|
@ -231,7 +231,7 @@ namespace libtorrent
|
|||
if ((compact_mode && (time > size_iter->second + 1 || time < size_iter->second - 1)) ||
|
||||
(!compact_mode && (time > size_iter->second + 5 * 60 || time < size_iter->second - 1)))
|
||||
{
|
||||
error = error_code(errors::mismatching_file_timestamp, libtorrent_category);
|
||||
error = errors::mismatching_file_timestamp;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -748,7 +748,7 @@ namespace libtorrent
|
|||
lazy_entry const* file_sizes_ent = rd.dict_find_list("file sizes");
|
||||
if (file_sizes_ent == 0)
|
||||
{
|
||||
error = error_code(errors::missing_file_sizes, libtorrent_category);
|
||||
error = errors::missing_file_sizes;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -766,7 +766,7 @@ namespace libtorrent
|
|||
|
||||
if (file_sizes.empty())
|
||||
{
|
||||
error = error_code(errors::no_files_in_resume_data, libtorrent_category);
|
||||
error = errors::no_files_in_resume_data;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -802,7 +802,7 @@ namespace libtorrent
|
|||
}
|
||||
else
|
||||
{
|
||||
error = error_code(errors::missing_pieces, libtorrent_category);
|
||||
error = errors::missing_pieces;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -814,7 +814,7 @@ namespace libtorrent
|
|||
{
|
||||
if (files().num_files() != (int)file_sizes.size())
|
||||
{
|
||||
error = error_code(errors::mismatching_number_of_files, libtorrent_category);
|
||||
error = errors::mismatching_number_of_files;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -827,7 +827,7 @@ namespace libtorrent
|
|||
{
|
||||
if (!i->pad_file && i->size != fs->first)
|
||||
{
|
||||
error = error_code(errors::mismatching_file_size, libtorrent_category);
|
||||
error = errors::mismatching_file_size;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -2002,7 +2002,7 @@ ret:
|
|||
|
||||
if (rd.type() != lazy_entry::dict_t)
|
||||
{
|
||||
error = error_code(errors::not_a_dictionary, libtorrent_category);
|
||||
error = errors::not_a_dictionary;
|
||||
return check_no_fastresume(error);
|
||||
}
|
||||
|
||||
|
@ -2011,7 +2011,7 @@ ret:
|
|||
if (blocks_per_piece != -1
|
||||
&& blocks_per_piece != m_files.piece_length() / block_size)
|
||||
{
|
||||
error = error_code(errors::invalid_blocks_per_piece, libtorrent_category);
|
||||
error = errors::invalid_blocks_per_piece;
|
||||
return check_no_fastresume(error);
|
||||
}
|
||||
|
||||
|
@ -2034,13 +2034,13 @@ ret:
|
|||
lazy_entry const* slots = rd.dict_find_list("slots");
|
||||
if (slots == 0)
|
||||
{
|
||||
error = error_code(errors::missing_slots, libtorrent_category);
|
||||
error = errors::missing_slots;
|
||||
return check_no_fastresume(error);
|
||||
}
|
||||
|
||||
if ((int)slots->list_size() > m_files.num_pieces())
|
||||
{
|
||||
error = error_code(errors::too_many_slots, libtorrent_category);
|
||||
error = errors::too_many_slots;
|
||||
return check_no_fastresume(error);
|
||||
}
|
||||
|
||||
|
@ -2054,14 +2054,14 @@ ret:
|
|||
lazy_entry const* e = slots->list_at(i);
|
||||
if (e->type() != lazy_entry::int_t)
|
||||
{
|
||||
error = error_code(errors::invalid_slot_list, libtorrent_category);
|
||||
error = errors::invalid_slot_list;
|
||||
return check_no_fastresume(error);
|
||||
}
|
||||
|
||||
int index = int(e->int_value());
|
||||
if (index >= num_pieces || index < -2)
|
||||
{
|
||||
error = error_code(errors::invalid_piece_index, libtorrent_category);
|
||||
error = errors::invalid_piece_index;
|
||||
return check_no_fastresume(error);
|
||||
}
|
||||
if (index >= 0)
|
||||
|
@ -2090,14 +2090,14 @@ ret:
|
|||
lazy_entry const* e = slots->list_at(i);
|
||||
if (e->type() != lazy_entry::int_t)
|
||||
{
|
||||
error = error_code(errors::invalid_slot_list, libtorrent_category);
|
||||
error = errors::invalid_slot_list;
|
||||
return check_no_fastresume(error);
|
||||
}
|
||||
|
||||
int index = int(e->int_value());
|
||||
if (index != i && index >= 0)
|
||||
{
|
||||
error = error_code(errors::invalid_piece_index, libtorrent_category);
|
||||
error = errors::invalid_piece_index;
|
||||
return check_no_fastresume(error);
|
||||
}
|
||||
}
|
||||
|
@ -2124,7 +2124,7 @@ ret:
|
|||
// we're resuming a compact allocated storage
|
||||
m_state = state_expand_pieces;
|
||||
m_current_slot = 0;
|
||||
error = error_code(errors::pieces_need_reorder, libtorrent_category);
|
||||
error = errors::pieces_need_reorder;
|
||||
TORRENT_ASSERT(int(m_piece_to_slot.size()) == m_files.num_pieces());
|
||||
return need_full_check;
|
||||
}
|
||||
|
@ -2137,13 +2137,13 @@ ret:
|
|||
lazy_entry const* pieces = rd.dict_find("pieces");
|
||||
if (pieces == 0 || pieces->type() != lazy_entry::string_t)
|
||||
{
|
||||
error = error_code(errors::missing_pieces, libtorrent_category);
|
||||
error = errors::missing_pieces;
|
||||
return check_no_fastresume(error);
|
||||
}
|
||||
|
||||
if ((int)pieces->string_length() != m_files.num_pieces())
|
||||
{
|
||||
error = error_code(errors::too_many_slots, libtorrent_category);
|
||||
error = errors::too_many_slots;
|
||||
return check_no_fastresume(error);
|
||||
}
|
||||
|
||||
|
|
|
@ -315,7 +315,7 @@ namespace libtorrent
|
|||
std::vector<char>().swap(m_resume_data);
|
||||
if (m_ses.m_alerts.should_post<fastresume_rejected_alert>())
|
||||
{
|
||||
error_code ec(errors::parse_failed, libtorrent_category);
|
||||
error_code ec(errors::parse_failed);
|
||||
m_ses.m_alerts.post_alert(fastresume_rejected_alert(get_handle(), ec));
|
||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
||||
(*m_ses.m_logger) << "fastresume data for "
|
||||
|
@ -398,7 +398,7 @@ namespace libtorrent
|
|||
|
||||
TORRENT_ASSERT(m_abort);
|
||||
if (!m_connections.empty())
|
||||
disconnect_all(error_code(errors::torrent_aborted, libtorrent_category));
|
||||
disconnect_all(errors::torrent_aborted);
|
||||
}
|
||||
|
||||
void torrent::read_piece(int piece)
|
||||
|
@ -502,7 +502,7 @@ namespace libtorrent
|
|||
{
|
||||
if (alerts().should_post<file_error_alert>())
|
||||
alerts().post_alert(file_error_alert(j.error_file, get_handle(), j.error));
|
||||
if (c) c->disconnect(error_code(errors::no_memory, libtorrent_category));
|
||||
if (c) c->disconnect(errors::no_memory);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -701,7 +701,7 @@ namespace libtorrent
|
|||
|
||||
if (m_torrent_file->num_pieces() > piece_picker::max_pieces)
|
||||
{
|
||||
set_error(error_code(errors::too_many_pieces_in_torrent, libtorrent_category), "");
|
||||
set_error(errors::too_many_pieces_in_torrent, "");
|
||||
pause();
|
||||
}
|
||||
|
||||
|
@ -754,7 +754,7 @@ namespace libtorrent
|
|||
if (ev && m_ses.m_alerts.should_post<fastresume_rejected_alert>())
|
||||
{
|
||||
m_ses.m_alerts.post_alert(fastresume_rejected_alert(get_handle()
|
||||
, error_code(ev, libtorrent_category)));
|
||||
, error_code(ev, get_libtorrent_category())));
|
||||
}
|
||||
|
||||
if (ev)
|
||||
|
@ -762,7 +762,7 @@ namespace libtorrent
|
|||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
||||
(*m_ses.m_logger) << "fastresume data for "
|
||||
<< torrent_file().name() << " rejected: "
|
||||
<< error_code(ev, libtorrent_category).message() << "\n";
|
||||
<< ev.message() << "\n";
|
||||
#endif
|
||||
std::vector<char>().swap(m_resume_data);
|
||||
lazy_entry().swap(m_resume_entry);
|
||||
|
@ -1024,7 +1024,7 @@ namespace libtorrent
|
|||
|
||||
clear_error();
|
||||
|
||||
disconnect_all(error_code(errors::stopping_torrent, libtorrent_category));
|
||||
disconnect_all(errors::stopping_torrent);
|
||||
|
||||
m_owning_storage->async_release_files();
|
||||
if (!m_picker) m_picker.reset(new piece_picker());
|
||||
|
@ -2160,8 +2160,7 @@ namespace libtorrent
|
|||
(*p->connection->m_logger) << "*** BANNING PEER [ " << p->ip()
|
||||
<< " ] 'too many corrupt pieces'\n";
|
||||
#endif
|
||||
p->connection->disconnect(error_code(errors::too_many_corrupt_pieces
|
||||
, libtorrent_category));
|
||||
p->connection->disconnect(errors::too_many_corrupt_pieces);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2238,7 +2237,7 @@ namespace libtorrent
|
|||
|
||||
// disconnect all peers and close all
|
||||
// files belonging to the torrents
|
||||
disconnect_all(error_code(errors::torrent_aborted, libtorrent_category));
|
||||
disconnect_all(errors::torrent_aborted);
|
||||
if (m_owning_storage.get())
|
||||
{
|
||||
m_storage->async_release_files(
|
||||
|
@ -3023,8 +3022,7 @@ namespace libtorrent
|
|||
if (m_ses.m_alerts.should_post<url_seed_alert>())
|
||||
{
|
||||
m_ses.m_alerts.post_alert(
|
||||
url_seed_alert(get_handle(), web.url, error_code(
|
||||
errors::unsupported_url_protocol, libtorrent_category)));
|
||||
url_seed_alert(get_handle(), web.url, errors::unsupported_url_protocol));
|
||||
}
|
||||
// never try it again
|
||||
m_web_seeds.erase(web);
|
||||
|
@ -3036,8 +3034,7 @@ namespace libtorrent
|
|||
if (m_ses.m_alerts.should_post<url_seed_alert>())
|
||||
{
|
||||
m_ses.m_alerts.post_alert(
|
||||
url_seed_alert(get_handle(), web.url, error_code(
|
||||
errors::invalid_hostname, libtorrent_category)));
|
||||
url_seed_alert(get_handle(), web.url, errors::invalid_hostname));
|
||||
}
|
||||
// never try it again
|
||||
m_web_seeds.erase(web);
|
||||
|
@ -3049,8 +3046,7 @@ namespace libtorrent
|
|||
if (m_ses.m_alerts.should_post<url_seed_alert>())
|
||||
{
|
||||
m_ses.m_alerts.post_alert(
|
||||
url_seed_alert(get_handle(), web.url, error_code(
|
||||
errors::invalid_port, libtorrent_category)));
|
||||
url_seed_alert(get_handle(), web.url, errors::invalid_port));
|
||||
}
|
||||
// never try it again
|
||||
m_web_seeds.erase(web);
|
||||
|
@ -3074,8 +3070,7 @@ namespace libtorrent
|
|||
if (m_ses.m_alerts.should_post<url_seed_alert>())
|
||||
{
|
||||
m_ses.m_alerts.post_alert(
|
||||
url_seed_alert(get_handle(), web.url, error_code(
|
||||
errors::port_blocked, libtorrent_category)));
|
||||
url_seed_alert(get_handle(), web.url, errors::port_blocked));
|
||||
}
|
||||
// never try it again
|
||||
m_web_seeds.erase(web);
|
||||
|
@ -3262,7 +3257,7 @@ namespace libtorrent
|
|||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
||||
(*m_ses.m_logger) << " ** HOSTNAME LOOKUP FAILED!**: " << e.what() << "\n";
|
||||
#endif
|
||||
c->disconnect(error_code(errors::no_error, libtorrent_category), 1);
|
||||
c->disconnect(errors::no_error, 1);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -4011,7 +4006,7 @@ namespace libtorrent
|
|||
std::set<peer_connection*>::iterator i
|
||||
= m_connections.find(boost::get_pointer(c));
|
||||
if (i != m_connections.end()) m_connections.erase(i);
|
||||
c->disconnect(error_code(errors::no_error, libtorrent_category), 1);
|
||||
c->disconnect(errors::no_error, 1);
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
@ -4050,7 +4045,7 @@ namespace libtorrent
|
|||
{
|
||||
alerts().post_alert(metadata_failed_alert(get_handle()));
|
||||
}
|
||||
set_error(error_code(errors::invalid_swarm_metadata, libtorrent_category), "");
|
||||
set_error(errors::invalid_swarm_metadata, "");
|
||||
pause();
|
||||
return false;
|
||||
}
|
||||
|
@ -4080,25 +4075,25 @@ namespace libtorrent
|
|||
|| m_state == torrent_status::checking_resume_data)
|
||||
&& valid_metadata())
|
||||
{
|
||||
p->disconnect(error_code(errors::torrent_not_ready, libtorrent_category));
|
||||
p->disconnect(errors::torrent_not_ready);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_ses.m_connections.find(p) == m_ses.m_connections.end())
|
||||
{
|
||||
p->disconnect(error_code(errors::peer_not_constructed, libtorrent_category));
|
||||
p->disconnect(errors::peer_not_constructed);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_ses.is_aborted())
|
||||
{
|
||||
p->disconnect(error_code(errors::session_closing, libtorrent_category));
|
||||
p->disconnect(errors::session_closing);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (int(m_connections.size()) >= m_max_connections)
|
||||
{
|
||||
p->disconnect(error_code(errors::too_many_connections, libtorrent_category));
|
||||
p->disconnect(errors::too_many_connections);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -4124,7 +4119,7 @@ namespace libtorrent
|
|||
(*m_ses.m_logger) << time_now_string() << " CLOSING CONNECTION "
|
||||
<< p->remote() << " policy::new_connection threw: " << e.what() << "\n";
|
||||
#endif
|
||||
p->disconnect(error_code(errors::no_error, libtorrent_category));
|
||||
p->disconnect(errors::no_error);
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
@ -4242,7 +4237,7 @@ namespace libtorrent
|
|||
|
||||
peer_connection* p = *i;
|
||||
++ret;
|
||||
p->disconnect(error_code(errors::optimistic_disconnect, libtorrent_category));
|
||||
p->disconnect(errors::optimistic_disconnect);
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -4296,8 +4291,7 @@ namespace libtorrent
|
|||
}
|
||||
}
|
||||
std::for_each(seeds.begin(), seeds.end()
|
||||
, bind(&peer_connection::disconnect, _1, error_code(errors::torrent_finished
|
||||
, libtorrent_category), 0));
|
||||
, bind(&peer_connection::disconnect, _1, errors::torrent_finished, 0));
|
||||
|
||||
if (m_abort) return;
|
||||
|
||||
|
@ -4843,7 +4837,7 @@ namespace libtorrent
|
|||
}
|
||||
#endif
|
||||
|
||||
disconnect_all(error_code(errors::torrent_removed, libtorrent_category));
|
||||
disconnect_all(errors::torrent_removed);
|
||||
stop_announcing();
|
||||
|
||||
if (m_owning_storage.get())
|
||||
|
@ -4974,7 +4968,7 @@ namespace libtorrent
|
|||
if (!m_owning_storage.get())
|
||||
{
|
||||
alerts().post_alert(save_resume_data_failed_alert(get_handle()
|
||||
, error_code(errors::destructing_torrent, libtorrent_category)));
|
||||
, errors::destructing_torrent));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -5066,7 +5060,7 @@ namespace libtorrent
|
|||
alerts().post_alert(torrent_paused_alert(get_handle()));
|
||||
}
|
||||
|
||||
disconnect_all(error_code(errors::torrent_paused, libtorrent_category));
|
||||
disconnect_all(errors::torrent_paused);
|
||||
stop_announcing();
|
||||
}
|
||||
|
||||
|
@ -5396,7 +5390,7 @@ namespace libtorrent
|
|||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
|
||||
(*p->m_logger) << "**ERROR**: " << e.what() << "\n";
|
||||
#endif
|
||||
p->disconnect(error_code(errors::no_error, libtorrent_category), 1);
|
||||
p->disconnect(errors::no_error, 1);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -5997,7 +5991,7 @@ namespace libtorrent
|
|||
{
|
||||
m_ses.m_alerts.post_alert(tracker_error_alert(get_handle()
|
||||
, ae?ae->fails:0, 0, r.url
|
||||
, error_code(errors::timed_out, libtorrent_category)));
|
||||
, errors::timed_out));
|
||||
}
|
||||
}
|
||||
else if (r.kind == tracker_request::scrape_request)
|
||||
|
@ -6005,7 +5999,7 @@ namespace libtorrent
|
|||
if (m_ses.m_alerts.should_post<scrape_failed_alert>())
|
||||
{
|
||||
m_ses.m_alerts.post_alert(scrape_failed_alert(get_handle()
|
||||
, r.url, error_code(errors::timed_out, libtorrent_category)));
|
||||
, r.url, errors::timed_out));
|
||||
}
|
||||
}
|
||||
update_tracker_timer();
|
||||
|
|
|
@ -120,8 +120,7 @@ namespace libtorrent
|
|||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
void throw_invalid_handle()
|
||||
{
|
||||
throw libtorrent_exception(error_code(
|
||||
errors::invalid_torrent_handle, libtorrent_category));
|
||||
throw libtorrent_exception(errors::invalid_torrent_handle);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -481,8 +481,7 @@ namespace libtorrent
|
|||
if (lazy_bdecode(&tmp[0], &tmp[0] + tmp.size(), e) != 0)
|
||||
{
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
throw invalid_torrent_file(error_code(
|
||||
errors::invalid_bencoding, libtorrent_category));
|
||||
throw invalid_torrent_file(errors::invalid_bencoding);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
@ -523,8 +522,7 @@ namespace libtorrent
|
|||
error_code ec;
|
||||
lazy_entry e;
|
||||
if (lazy_bdecode(buffer, buffer + size, e) != 0)
|
||||
throw invalid_torrent_file(error_code(
|
||||
errors::invalid_bencoding, libtorrent_category));
|
||||
throw invalid_torrent_file(errors::invalid_bencoding);
|
||||
|
||||
if (!parse_torrent_file(e, ec))
|
||||
throw invalid_torrent_file(ec);
|
||||
|
@ -544,8 +542,7 @@ namespace libtorrent
|
|||
|
||||
lazy_entry e;
|
||||
if (lazy_bdecode(&buf[0], &buf[0] + buf.size(), e) != 0)
|
||||
throw invalid_torrent_file(error_code(
|
||||
errors::invalid_bencoding, libtorrent_category));
|
||||
throw invalid_torrent_file(errors::invalid_bencoding);
|
||||
error_code ec;
|
||||
if (!parse_torrent_file(e, ec))
|
||||
throw invalid_torrent_file(ec);
|
||||
|
@ -569,8 +566,7 @@ namespace libtorrent
|
|||
|
||||
lazy_entry e;
|
||||
if (lazy_bdecode(&buf[0], &buf[0] + buf.size(), e) != 0)
|
||||
throw invalid_torrent_file(error_code(
|
||||
errors::invalid_bencoding, libtorrent_category));
|
||||
throw invalid_torrent_file(errors::invalid_bencoding);
|
||||
|
||||
error_code ec;
|
||||
if (!parse_torrent_file(e, ec))
|
||||
|
@ -602,7 +598,7 @@ namespace libtorrent
|
|||
lazy_entry e;
|
||||
if (lazy_bdecode(buffer, buffer + size, e) != 0)
|
||||
{
|
||||
ec = error_code(errors::invalid_bencoding, libtorrent_category);
|
||||
ec = errors::invalid_bencoding;
|
||||
return;
|
||||
}
|
||||
parse_torrent_file(e, ec);
|
||||
|
@ -623,7 +619,7 @@ namespace libtorrent
|
|||
lazy_entry e;
|
||||
if (lazy_bdecode(&buf[0], &buf[0] + buf.size(), e) != 0)
|
||||
{
|
||||
ec = error_code(errors::invalid_bencoding, libtorrent_category);
|
||||
ec = errors::invalid_bencoding;
|
||||
return;
|
||||
}
|
||||
parse_torrent_file(e, ec);
|
||||
|
@ -647,7 +643,7 @@ namespace libtorrent
|
|||
lazy_entry e;
|
||||
if (lazy_bdecode(&buf[0], &buf[0] + buf.size(), e) != 0)
|
||||
{
|
||||
ec = error_code(errors::invalid_bencoding, libtorrent_category);
|
||||
ec = errors::invalid_bencoding;
|
||||
return;
|
||||
}
|
||||
parse_torrent_file(e, ec);
|
||||
|
@ -706,7 +702,7 @@ namespace libtorrent
|
|||
{
|
||||
if (info.type() != lazy_entry::dict_t)
|
||||
{
|
||||
ec = error_code(errors::torrent_info_no_dict, libtorrent_category);
|
||||
ec = errors::torrent_info_no_dict;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -727,7 +723,7 @@ namespace libtorrent
|
|||
int piece_length = info.dict_find_int_value("piece length", -1);
|
||||
if (piece_length <= 0)
|
||||
{
|
||||
ec = error_code(errors::torrent_missing_piece_length, libtorrent_category);
|
||||
ec = errors::torrent_missing_piece_length;
|
||||
return false;
|
||||
}
|
||||
m_files.set_piece_length(piece_length);
|
||||
|
@ -737,7 +733,7 @@ namespace libtorrent
|
|||
if (name.empty()) name = info.dict_find_string_value("name");
|
||||
if (name.empty())
|
||||
{
|
||||
ec = error_code(errors::torrent_missing_name, libtorrent_category);
|
||||
ec = errors::torrent_missing_name;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -745,7 +741,7 @@ namespace libtorrent
|
|||
|
||||
if (!valid_path_element(name))
|
||||
{
|
||||
ec = error_code(errors::torrent_invalid_name, libtorrent_category);
|
||||
ec = errors::torrent_invalid_name;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -795,7 +791,7 @@ namespace libtorrent
|
|||
e.pad_file = true;
|
||||
if (e.size < 0)
|
||||
{
|
||||
ec = error_code(errors::torrent_invalid_length, libtorrent_category);
|
||||
ec = errors::torrent_invalid_length;
|
||||
return false;
|
||||
}
|
||||
m_files.add_file(e);
|
||||
|
@ -805,7 +801,7 @@ namespace libtorrent
|
|||
{
|
||||
if (!extract_files(*i, m_files, name))
|
||||
{
|
||||
ec = error_code(errors::torrent_file_parse_failed, libtorrent_category);
|
||||
ec = errors::torrent_file_parse_failed;
|
||||
return false;
|
||||
}
|
||||
m_multifile = true;
|
||||
|
@ -824,7 +820,7 @@ namespace libtorrent
|
|||
if ((pieces == 0 || pieces->type() != lazy_entry::string_t)
|
||||
&& (root_hash == 0 || root_hash->type() != lazy_entry::string_t))
|
||||
{
|
||||
ec = error_code(errors::torrent_missing_pieces, libtorrent_category);
|
||||
ec = errors::torrent_missing_pieces;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -832,7 +828,7 @@ namespace libtorrent
|
|||
{
|
||||
if (pieces->string_length() != m_files.num_pieces() * 20)
|
||||
{
|
||||
ec = error_code(errors::torrent_invalid_hashes, libtorrent_category);
|
||||
ec = errors::torrent_invalid_hashes;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -845,7 +841,7 @@ namespace libtorrent
|
|||
TORRENT_ASSERT(root_hash);
|
||||
if (root_hash->string_length() != 20)
|
||||
{
|
||||
ec = error_code(errors::torrent_invalid_hashes, libtorrent_category);
|
||||
ec = errors::torrent_invalid_hashes;
|
||||
return false;
|
||||
}
|
||||
int num_leafs = merkle_num_leafs(m_files.num_pieces());
|
||||
|
@ -947,7 +943,7 @@ namespace libtorrent
|
|||
{
|
||||
if (torrent_file.type() != lazy_entry::dict_t)
|
||||
{
|
||||
ec = error_code(errors::torrent_is_no_dict, libtorrent_category);
|
||||
ec = errors::torrent_is_no_dict;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1075,7 +1071,7 @@ namespace libtorrent
|
|||
lazy_entry const* info = torrent_file.dict_find_dict("info");
|
||||
if (info == 0)
|
||||
{
|
||||
ec = error_code(errors::torrent_missing_info, libtorrent_category);
|
||||
ec = errors::torrent_missing_info;
|
||||
return false;
|
||||
}
|
||||
return parse_info_section(*info, ec);
|
||||
|
|
|
@ -262,7 +262,7 @@ void upnp::resend_request(error_code const& e)
|
|||
|
||||
if (m_devices.empty())
|
||||
{
|
||||
disable(error_code(errors::no_router, libtorrent_category), l);
|
||||
disable(errors::no_router, l);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -295,7 +295,7 @@ namespace libtorrent { namespace
|
|||
|
||||
if (length > 17 * 1024)
|
||||
{
|
||||
m_pc.disconnect(error_code(errors::invalid_metadata_message, libtorrent_category), 2);
|
||||
m_pc.disconnect(errors::invalid_metadata_message, 2);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -305,7 +305,7 @@ namespace libtorrent { namespace
|
|||
entry msg = bdecode(body.begin, body.end, len);
|
||||
if (msg.type() == entry::undefined_t)
|
||||
{
|
||||
m_pc.disconnect(error_code(errors::invalid_metadata_message, libtorrent_category), 2);
|
||||
m_pc.disconnect(errors::invalid_metadata_message, 2);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -236,7 +236,7 @@ namespace libtorrent { namespace
|
|||
|
||||
if (length > 500 * 1024)
|
||||
{
|
||||
m_pc.disconnect(error_code(errors::pex_message_too_large, libtorrent_category), 2);
|
||||
m_pc.disconnect(errors::pex_message_too_large, 2);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -246,7 +246,7 @@ namespace libtorrent { namespace
|
|||
int ret = lazy_bdecode(body.begin, body.end, pex_msg);
|
||||
if (ret != 0 || pex_msg.type() != lazy_entry::dict_t)
|
||||
{
|
||||
m_pc.disconnect(error_code(errors::invalid_pex_message, libtorrent_category), 2);
|
||||
m_pc.disconnect(errors::invalid_pex_message, 2);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -371,7 +371,7 @@ namespace libtorrent
|
|||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
(*m_logger) << "*** " << std::string(recv_buffer.begin, recv_buffer.end) << "\n";
|
||||
#endif
|
||||
disconnect(error_code(errors::http_parse_error, libtorrent_category), 2);
|
||||
disconnect(errors::http_parse_error, 2);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -430,7 +430,7 @@ namespace libtorrent
|
|||
, error_msg));
|
||||
}
|
||||
m_statistics.received_bytes(0, bytes_transferred);
|
||||
disconnect(error_code(errors::http_error, libtorrent_category), 1);
|
||||
disconnect(errors::http_error, 1);
|
||||
return;
|
||||
}
|
||||
if (m_parser.status_code() >= 300 && m_parser.status_code() < 400)
|
||||
|
@ -444,7 +444,7 @@ namespace libtorrent
|
|||
{
|
||||
// we should not try this server again.
|
||||
t->remove_web_seed(m_url, web_seed_entry::url_seed);
|
||||
disconnect(error_code(errors::missing_location, libtorrent_category), 2);
|
||||
disconnect(errors::missing_location, 2);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -469,14 +469,14 @@ namespace libtorrent
|
|||
if (i == std::string::npos)
|
||||
{
|
||||
t->remove_web_seed(m_url, web_seed_entry::url_seed);
|
||||
disconnect(error_code(errors::invalid_redirection, libtorrent_category), 2);
|
||||
disconnect(errors::invalid_redirection, 2);
|
||||
return;
|
||||
}
|
||||
location.resize(i);
|
||||
}
|
||||
t->add_web_seed(location, web_seed_entry::url_seed);
|
||||
t->remove_web_seed(m_url, web_seed_entry::url_seed);
|
||||
disconnect(error_code(errors::redirecting, libtorrent_category), 2);
|
||||
disconnect(errors::redirecting, 2);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -510,7 +510,7 @@ namespace libtorrent
|
|||
m_statistics.received_bytes(0, bytes_transferred);
|
||||
// we should not try this server again.
|
||||
t->remove_web_seed(m_url, web_seed_entry::url_seed);
|
||||
disconnect(error_code(errors::invalid_range, libtorrent_category));
|
||||
disconnect(errors::invalid_range);
|
||||
return;
|
||||
}
|
||||
// the http range is inclusive
|
||||
|
@ -525,7 +525,7 @@ namespace libtorrent
|
|||
m_statistics.received_bytes(0, bytes_transferred);
|
||||
// we should not try this server again.
|
||||
t->remove_web_seed(m_url, web_seed_entry::url_seed);
|
||||
disconnect(error_code(errors::no_content_length, libtorrent_category), 2);
|
||||
disconnect(errors::no_content_length, 2);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -533,7 +533,7 @@ namespace libtorrent
|
|||
if (m_requests.empty() || m_file_requests.empty())
|
||||
{
|
||||
m_statistics.received_bytes(0, bytes_transferred);
|
||||
disconnect(error_code(errors::http_error, libtorrent_category), 2);
|
||||
disconnect(errors::http_error, 2);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -586,7 +586,7 @@ namespace libtorrent
|
|||
m_statistics.received_bytes(0, bytes_transferred);
|
||||
// this means the end of the incoming request ends _before_ the
|
||||
// first expected byte (fs + m_piece.size())
|
||||
disconnect(error_code(errors::invalid_range, libtorrent_category), 2);
|
||||
disconnect(errors::invalid_range, 2);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ lib test_common
|
|||
;
|
||||
|
||||
exe test_natpmp : test_natpmp.cpp /torrent//torrent
|
||||
: <link>shared <threading>multi <debug-iterators>on <invariant-checks>full ;
|
||||
: <threading>multi <debug-iterators>on <invariant-checks>full ;
|
||||
|
||||
explicit test_natpmp ;
|
||||
|
||||
|
|
Loading…
Reference in New Issue