@@ -805,7 +805,9 @@ bool CServerListManager::Load()
805805 continue ;
806806 }
807807
808- NetworkUtil::ParseNetworkAddress ( slLine[0 ], haServerHostAddr, bEnableIPv6 );
808+ // This uses ParseNetworkAddressBare because it is just parsing ip:host that was saved to the file.
809+ // Therefore no SRV lookup is appropriate.
810+ NetworkUtil::ParseNetworkAddressBare ( slLine[0 ], haServerHostAddr, bEnableIPv6 );
809811 int iIdx = IndexOf ( haServerHostAddr );
810812 if ( iIdx != INVALID_INDEX )
811813 {
@@ -969,13 +971,23 @@ void CServerListManager::SetRegistered ( const bool bIsRegister )
969971 return ;
970972 }
971973
974+ // It is very important to unlock the Mutex before doing address resolution,
975+ // so that the event loop can run and any other timers that need the mutex
976+ // can obtain it. Otherwise there is the possibility of deadlock when doing
977+ // the SRV lookup, if another timer fires that needs the same mutex.
978+ locker.unlock ();
979+
972980 // get the correct directory address
973981 // Note that we always have to parse the server address again since if
974982 // it is an URL of a dynamic IP address, the IP address might have
975983 // changed in the meanwhile.
976984 // Allow IPv4 only for communicating with Directories
985+ // Use SRV DNS discovery for directory connections, fallback to A/AAAA if none.
977986 const QString strNetworkAddress = NetworkUtil::GetDirectoryAddress ( DirectoryType, strDirectoryAddress );
978- const bool bDirectoryAddressValid = NetworkUtil ().ParseNetworkAddress ( strNetworkAddress, DirectoryAddress, false );
987+ const bool bDirectoryAddressValid = NetworkUtil::ParseNetworkAddress ( strNetworkAddress, DirectoryAddress, false );
988+
989+ // lock the mutex again now that the address has been resolved.
990+ locker.relock ();
979991
980992 if ( bIsRegister )
981993 {
0 commit comments