merged i2p_alert fix from RC_0_16
This commit is contained in:
parent
826417b471
commit
6f82d3b8ae
|
@ -2041,6 +2041,21 @@ namespace libtorrent
|
|||
std::string salt;
|
||||
boost::uint64_t seq;
|
||||
};
|
||||
|
||||
// this alert is used to report errors in the i2p SAM connection
|
||||
struct TORRENT_EXPORT i2p_alert : alert
|
||||
{
|
||||
i2p_alert(error_code const& ec) : error(ec) {}
|
||||
|
||||
TORRENT_DEFINE_ALERT(i2p_alert);
|
||||
|
||||
const static int static_category = alert::error_notification;
|
||||
virtual std::string message() const;
|
||||
|
||||
// the error that occurred in the i2p SAM connection
|
||||
error_code error;
|
||||
};
|
||||
|
||||
#undef TORRENT_DEFINE_ALERT
|
||||
|
||||
}
|
||||
|
|
|
@ -610,6 +610,13 @@ namespace libtorrent {
|
|||
return msg;
|
||||
}
|
||||
|
||||
std::string i2p_alert::message() const
|
||||
{
|
||||
char msg[600];
|
||||
snprintf(msg, sizeof(msg), "i2p_error: [%s] %s"
|
||||
, error.category().name(), convert_from_native(error.message()).c_str());
|
||||
return msg;
|
||||
}
|
||||
|
||||
} // namespace libtorrent
|
||||
|
||||
|
|
|
@ -148,8 +148,7 @@ namespace libtorrent
|
|||
void i2p_connection::async_name_lookup(char const* name
|
||||
, i2p_connection::name_lookup_handler handler)
|
||||
{
|
||||
// TORRENT_ASSERT(is_open());
|
||||
if (m_state == sam_idle && m_name_lookup.empty())
|
||||
if (m_state == sam_idle && m_name_lookup.empty() && is_open())
|
||||
do_name_lookup(name, handler);
|
||||
else
|
||||
m_name_lookup.push_back(std::make_pair(std::string(name), handler));
|
||||
|
|
|
@ -2455,6 +2455,9 @@ retry:
|
|||
{
|
||||
if (ec)
|
||||
{
|
||||
if (m_alerts.should_post<i2p_alert>())
|
||||
m_alerts.post_alert(i2p_alert(ec));
|
||||
|
||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
||||
char msg[200];
|
||||
snprintf(msg, sizeof(msg), "i2p open failed (%d) %s", ec.value(), ec.message().c_str());
|
||||
|
|
Loading…
Reference in New Issue