improve logging aroud binding listen sockets

This commit is contained in:
arvidn 2015-06-28 09:13:59 -04:00
parent b4c3c40380
commit a754559ac6
1 changed files with 9 additions and 7 deletions

View File

@ -1679,10 +1679,12 @@ namespace aux {
while (ec && retries > 0) while (ec && retries > 0)
{ {
TORRENT_ASSERT_VAL(ec, ec);
#ifndef TORRENT_DISABLE_LOGGING #ifndef TORRENT_DISABLE_LOGGING
session_log("failed to bind to interface [%s] \"%s\": %s" session_log("failed to bind to interface [%s %d] \"%s : %s\": %s "
, device.c_str(), bind_ip.to_string(ec).c_str() "(retries: %d)"
, ec.message().c_str()); , device.c_str(), port, bind_ip.to_string(ec).c_str()
, ec.category().name(), ec.message().c_str(), retries);
#endif #endif
ec.clear(); ec.clear();
TORRENT_ASSERT_VAL(!ec, ec); TORRENT_ASSERT_VAL(!ec, ec);
@ -1694,8 +1696,7 @@ namespace aux {
} }
if (ec && !(flags & listen_no_system_port)) if (ec && !(flags & listen_no_system_port))
{ {
// instead of giving up, trying // instead of giving up, try let the OS pick a port
// let the OS pick a port
port = 0; port = 0;
ec.clear(); ec.clear();
bind_ip = bind_to_device(m_io_service, *ret.sock, ipv4 bind_ip = bind_to_device(m_io_service, *ret.sock, ipv4
@ -1708,8 +1709,9 @@ namespace aux {
if (m_alerts.should_post<listen_failed_alert>()) if (m_alerts.should_post<listen_failed_alert>())
m_alerts.emplace_alert<listen_failed_alert>(device, last_op, ec, sock_type); m_alerts.emplace_alert<listen_failed_alert>(device, last_op, ec, sock_type);
#ifndef TORRENT_DISABLE_LOGGING #ifndef TORRENT_DISABLE_LOGGING
session_log("cannot bind to interface \"%s\": %s" session_log("cannot to bind to interface [%s %d] \"%s : %s\": %s"
, device.c_str(), ec.message().c_str()); , device.c_str(), port, bind_ip.to_string(ec).c_str()
, ec.category().name(), ec.message().c_str());
#endif #endif
return ret; return ret;
} }