include error code in metadata failure alert

This commit is contained in:
Arvid Norberg 2013-09-14 10:09:30 +00:00
parent f1f89123e8
commit 908e29957e
4 changed files with 9 additions and 6 deletions

View File

@ -1179,8 +1179,9 @@ namespace libtorrent
struct TORRENT_EXPORT metadata_failed_alert: torrent_alert
{
// internal
metadata_failed_alert(const torrent_handle& h)
metadata_failed_alert(const torrent_handle& h, error_code e)
: torrent_alert(h)
, error(e)
{}
TORRENT_DEFINE_ALERT(metadata_failed_alert);
@ -1188,6 +1189,9 @@ namespace libtorrent
const static int static_category = alert::error_notification;
virtual std::string message() const
{ return torrent_alert::message() + " invalid metadata received"; }
// the error that occurred
error_code error;
};
// This alert is generated when the metadata has been completely received and the torrent

View File

@ -127,7 +127,7 @@ namespace libtorrent
invalid_file_tag,
// The fast resume file was missing or had an invalid info-hash
missing_info_hash,
// The info-hash in the resume file did not match the torrent
// The info-hash did not match the torrent
mismatching_info_hash,
// The URL contained an invalid hostname
invalid_hostname,

View File

@ -5910,7 +5910,8 @@ namespace libtorrent
{
if (alerts().should_post<metadata_failed_alert>())
{
alerts().post_alert(metadata_failed_alert(get_handle()));
alerts().post_alert(metadata_failed_alert(get_handle()
, error_code(errors::mismatching_info_hash, get_libtorrent_category())));
}
return false;
}
@ -5925,8 +5926,7 @@ namespace libtorrent
// failed to parse it. Pause the torrent
if (alerts().should_post<metadata_failed_alert>())
{
// TODO: 2 pass in ec along with the alert
alerts().post_alert(metadata_failed_alert(get_handle()));
alerts().post_alert(metadata_failed_alert(get_handle(), ec));
}
set_error(errors::invalid_swarm_metadata, "");
pause();

View File

@ -603,7 +603,6 @@ struct utp_socket_impl
bool m_attached:1;
// this is true if nagle is enabled (which it is by default)
// TODO: 2 support the option to turn it off
bool m_nagle:1;
// this is true while the socket is in slow start mode. It's