diff --git a/src/serverlist.cpp b/src/serverlist.cpp index c1015256b5..70bccf3956 100644 --- a/src/serverlist.cpp +++ b/src/serverlist.cpp @@ -969,13 +969,27 @@ void CServerListManager::SetRegistered ( const bool bIsRegister ) return; } + // It is very important to unlock the Mutex before doing address resolution, + // so that the event loop can run and any other timers that need the mutex + // can obtain it. Otherwise there is the possibility of deadlock when doing + // the SRV lookup, if another timer fires that needs the same mutex. + locker.unlock(); + // get the correct directory address // Note that we always have to parse the server address again since if // it is an URL of a dynamic IP address, the IP address might have // changed in the meanwhile. // Allow IPv4 only for communicating with Directories - const QString strNetworkAddress = NetworkUtil::GetDirectoryAddress ( DirectoryType, strDirectoryAddress ); - const bool bDirectoryAddressValid = NetworkUtil().ParseNetworkAddress ( strNetworkAddress, DirectoryAddress, false ); + // Use SRV DNS discovery for directory connections, fallback to A/AAAA if none. + const QString strNetworkAddress = NetworkUtil::GetDirectoryAddress ( DirectoryType, strDirectoryAddress ); +#ifndef CLIENT_NO_SRV_CONNECT + const bool bDirectoryAddressValid = NetworkUtil().ParseNetworkAddressWithSrvDiscovery ( strNetworkAddress, DirectoryAddress, false ); +#else + const bool bDirectoryAddressValid = NetworkUtil().ParseNetworkAddress ( strNetworkAddress, DirectoryAddress, false ); +#endif + + // lock the mutex again now that the address has been resolved. + locker.relock(); if ( bIsRegister ) {