diff --git a/src/alert.cpp b/src/alert.cpp index 79a965681..076beb0e2 100644 --- a/src/alert.cpp +++ b/src/alert.cpp @@ -861,8 +861,9 @@ namespace libtorrent { "accept" }; char ret[300]; - snprintf(ret, sizeof(ret), "listening on %s failed: [%s] [%s] %s" + snprintf(ret, sizeof(ret), "listening on %s : %s failed: [%s] [%s] %s" , listen_interface() + , print_endpoint(endpoint).c_str() , op_str[operation] , sock_type_str[sock_type] , convert_from_native(error.message()).c_str()); diff --git a/src/session_impl.cpp b/src/session_impl.cpp index 7031386fd..e3ca42823 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -2048,18 +2048,21 @@ retry: session_log("cannot bind TCP listen socket to interface \"%s\": %s" , print_endpoint(m_listen_interface).c_str(), ec.message().c_str()); #endif - if (listen_port_retries > 0) - { - m_listen_interface.port(m_listen_interface.port() + 1); - --listen_port_retries; - goto retry; - } if (m_alerts.should_post()) m_alerts.emplace_alert( m_listen_interface.address().to_string() , m_listen_interface.port() , listen_failed_alert::bind , ec, listen_failed_alert::tcp); + if (listen_port_retries > 0) + { + m_listen_interface.port(m_listen_interface.port() + 1); + // update the actual port m_listen_interface was derived from also + if (!m_listen_interfaces.empty()) + m_listen_interfaces[0].second += 1; + --listen_port_retries; + goto retry; + } return; } @@ -2119,12 +2122,6 @@ retry: session_log("cannot bind to UDP interface \"%s\": %s" , print_endpoint(m_listen_interface).c_str(), ec.message().c_str()); #endif - if (listen_port_retries > 0) - { - m_listen_interface.port(m_listen_interface.port() + 1); - --listen_port_retries; - goto retry; - } if (m_alerts.should_post()) { error_code err; @@ -2133,6 +2130,15 @@ retry: , listen_failed_alert::bind , ec, listen_failed_alert::udp); } + if (listen_port_retries > 0) + { + m_listen_interface.port(m_listen_interface.port() + 1); + // update the actual port m_listen_interface was derived from also + if (!m_listen_interfaces.empty()) + m_listen_interfaces[0].second += 1; + --listen_port_retries; + goto retry; + } return; } else diff --git a/test/setup_transfer.cpp b/test/setup_transfer.cpp index e026b9def..eff42419a 100644 --- a/test/setup_transfer.cpp +++ b/test/setup_transfer.cpp @@ -363,9 +363,9 @@ void wait_for_downloading(lt::session& ses, char const* name) } while (a); if (!downloading_done) { - fprintf(stderr, "did not receive a state_changed_alert indicating " + fprintf(stderr, "%s: did not receive a state_changed_alert indicating " "the torrent is downloading. waited: %d ms\n" - , int(total_milliseconds(clock_type::now() - start))); + , name, int(total_milliseconds(clock_type::now() - start))); } }