From efcaee9c2d982672dd9683cd270bc4b1bd6e0104 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Mon, 27 Oct 2008 03:45:08 +0000 Subject: [PATCH] fix for when DHT is started before a listen port has been configured --- src/session_impl.cpp | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/session_impl.cpp b/src/session_impl.cpp index 575e8f487..261d2cfa0 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -2133,15 +2133,10 @@ namespace aux { || m_dht_same_port) { m_dht_same_port = true; - // if you hit this assert you are trying to start the - // DHT with the same port as the tcp listen port - // (which is default) _before_ you have opened the - // tcp listen port (so there is no configured port to use) - // basically, make sure you call listen_on() before - // start_dht(). See documentation for listen_on() for - // more information. - TORRENT_ASSERT(m_listen_interface.port() > 0); - m_dht_settings.service_port = m_listen_interface.port(); + if (m_listen_interface.port() > 0) + m_dht_settings.service_port = m_listen_interface.port(); + else + m_dht_settings.service_port = 45000 + (rand() % 10000); } m_external_udp_port = m_dht_settings.service_port; if (m_natpmp.get() && m_udp_mapping[0] == -1)