forked from premiere/premiere-libtorrent
improve dht error reporting
This commit is contained in:
parent
fec7407461
commit
9ab349f1d0
|
@ -1906,6 +1906,33 @@ namespace libtorrent
|
|||
feed_item item;
|
||||
};
|
||||
|
||||
// posted when something fails in the DHT. This is not necessarily a fatal
|
||||
// error, but it could prevent proper operation
|
||||
struct TORRENT_EXPORT dht_error_alert: alert
|
||||
{
|
||||
// internal
|
||||
dht_error_alert(int op, error_code const& ec)
|
||||
: error(ec), operation(op_t(op)) {}
|
||||
|
||||
TORRENT_DEFINE_ALERT(dht_error_alert);
|
||||
|
||||
const static int static_category = alert::error_notification
|
||||
| alert::dht_notification;
|
||||
virtual std::string message() const;
|
||||
|
||||
// the error code
|
||||
error_code error;
|
||||
|
||||
enum op_t
|
||||
{
|
||||
unknown,
|
||||
hostname_lookup
|
||||
};
|
||||
|
||||
// the operation that failed
|
||||
op_t operation;
|
||||
};
|
||||
|
||||
|
||||
#undef TORRENT_DEFINE_ALERT
|
||||
|
||||
|
|
|
@ -538,5 +538,26 @@ namespace libtorrent {
|
|||
, error.category().name(), convert_from_native(error.message()).c_str());
|
||||
return msg;
|
||||
}
|
||||
|
||||
std::string dht_error_alert::message() const
|
||||
{
|
||||
const static char* const operation_names[] =
|
||||
{
|
||||
"unknown"
|
||||
"hostname lookup"
|
||||
};
|
||||
|
||||
int op = operation;
|
||||
if (op < 0 || op > sizeof(operation_names)/sizeof(operation_names[0]))
|
||||
op = 0;
|
||||
|
||||
char msg[600];
|
||||
snprintf(msg, sizeof(msg), "DHT error [%s] (%d) %s"
|
||||
, operation_names[op]
|
||||
, error.value()
|
||||
, convert_from_native(error.message()).c_str());
|
||||
return msg;
|
||||
}
|
||||
|
||||
} // namespace libtorrent
|
||||
|
||||
|
|
|
@ -5750,8 +5750,14 @@ retry:
|
|||
#if defined TORRENT_ASIO_DEBUGGING
|
||||
complete_async("session_impl::on_dht_router_name_lookup");
|
||||
#endif
|
||||
// TODO: 1 report errors as alerts
|
||||
if (e) return;
|
||||
if (e)
|
||||
{
|
||||
if (m_alerts.should_post<dht_error_alert>())
|
||||
m_alerts.post_alert(dht_error_alert(
|
||||
dht_error_alert::hostname_lookup, e));
|
||||
return;
|
||||
}
|
||||
|
||||
while (host != tcp::resolver::iterator())
|
||||
{
|
||||
// router nodes should be added before the DHT is started (and bootstrapped)
|
||||
|
|
|
@ -1900,8 +1900,7 @@ bool utp_socket_impl::send_pkt(int flags)
|
|||
m_mtu_ceiling = p->size - 1;
|
||||
if (m_mtu_floor > m_mtu_ceiling) m_mtu_floor = m_mtu_ceiling;
|
||||
update_mtu_limits();
|
||||
// TODO: 2 we might want to do something else here
|
||||
// as well, to resend the packet immediately without
|
||||
// resend the packet immediately without
|
||||
// it being an MTU probe
|
||||
p->mtu_probe = false;
|
||||
if (m_mtu_seq == m_ack_nr)
|
||||
|
|
Loading…
Reference in New Issue