From 96fe7e7137010c2df3480a8ea774ccbc7dfc88fc Mon Sep 17 00:00:00 2001 From: Manuel Nickschas Date: Fri, 14 Mar 2014 21:13:09 +0100 Subject: [PATCH] Fix round-robin for networks that support it Some IRC networks perform round-robin by supplying a list of IP addresses in their DNS records. However, Qt a) always uses the first address of that list, and b) caches DNS records for a minute. This results that users who connect at a roughly similar time (like at core startup) will all pick the same IP for a given round-robin network address. We now force Qt (simply by calling QHostInfo::fromName()) to perform a fresh lookup every time it connects to an IRC network, which solves this problem. However, this will not help you if your OS uses a system DNS cache that does not reshuffle the list of IPs for repeated lookups. --- src/core/corenetwork.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/core/corenetwork.cpp b/src/core/corenetwork.cpp index 954565cf..18f27842 100644 --- a/src/core/corenetwork.cpp +++ b/src/core/corenetwork.cpp @@ -18,6 +18,8 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ +#include + #include "corenetwork.h" #include "core.h" @@ -184,6 +186,10 @@ void CoreNetwork::connectToIrc(bool reconnecting) enablePingTimeout(); + // Qt caches DNS entries for a minute, resulting in round-robin (e.g. for chat.freenode.net) not working if several users + // connect at a similar time. QHostInfo::fromName(), however, always performs a fresh lookup, overwriting the cache entry. + QHostInfo::fromName(server.host); + #ifdef HAVE_SSL if (server.useSsl) { CoreIdentity *identity = identityPtr(); -- 2.20.1