diff --git a/include/libtorrent/alert_types.hpp b/include/libtorrent/alert_types.hpp index 24595a4e2..1510e6d88 100644 --- a/include/libtorrent/alert_types.hpp +++ b/include/libtorrent/alert_types.hpp @@ -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 diff --git a/include/libtorrent/error_code.hpp b/include/libtorrent/error_code.hpp index b2bfdcf84..5a4459a30 100644 --- a/include/libtorrent/error_code.hpp +++ b/include/libtorrent/error_code.hpp @@ -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, diff --git a/src/torrent.cpp b/src/torrent.cpp index 5f1eccc4c..3918d2174 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -5910,7 +5910,8 @@ namespace libtorrent { if (alerts().should_post()) { - 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()) { - // 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(); diff --git a/src/utp_stream.cpp b/src/utp_stream.cpp index 5a0f38c01..822641ebb 100644 --- a/src/utp_stream.cpp +++ b/src/utp_stream.cpp @@ -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