X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcore%2Fcorenetwork.cpp;h=b7d496af8830d74dd19f7f8ddb60d4e35bf4da8b;hp=e0d4fa6eb90a771854e7cf4612230323d4ae21db;hb=40601ae070413b727a68e35e5b8c619176c661b1;hpb=9d54503555534a2c554f09a33df6afa33d6308ec diff --git a/src/core/corenetwork.cpp b/src/core/corenetwork.cpp index e0d4fa6e..b7d496af 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" @@ -44,7 +46,6 @@ CoreNetwork::CoreNetwork(const NetworkId &networkid, CoreSession *session) _requestedUserModes('-') { _autoReconnectTimer.setSingleShot(true); - _socketCloseTimer.setSingleShot(true); connect(&_socketCloseTimer, SIGNAL(timeout()), this, SLOT(socketCloseTimeout())); setPingInterval(networkConfig()->pingInterval()); @@ -183,8 +184,13 @@ void CoreNetwork::connectToIrc(bool reconnecting) socket.setProxy(QNetworkProxy::NoProxy); } + 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 - socket.setProtocol((QSsl::SslProtocol)server.sslVersion); if (server.useSsl) { CoreIdentity *identity = identityPtr(); if (identity) { @@ -262,13 +268,16 @@ void CoreNetwork::putCmd(const QString &cmd, const QList ¶ms, co if (!prefix.isEmpty()) msg += ":" + prefix + " "; - msg += cmd.toUpper().toAscii(); + msg += cmd.toUpper().toLatin1(); + + for (int i = 0; i < params.size(); i++) { + msg += " "; - for (int i = 0; i < params.size() - 1; i++) { - msg += " " + params[i]; + if (i == params.size() - 1 && (params[i].contains(' ') || (!params[i].isEmpty() && params[i][0] == ':'))) + msg += ":"; + + msg += params[i]; } - if (!params.isEmpty()) - msg += " :" + params.last(); putRawLine(msg); } @@ -437,7 +446,9 @@ void CoreNetwork::socketInitialized() if (server.useSsl && !socket.isEncrypted()) return; #endif - +#if QT_VERSION >= 0x040600 + socket.setSocketOption(QAbstractSocket::KeepAliveOption, true); +#endif CoreIdentity *identity = identityPtr(); if (!identity) { qCritical() << "Identity invalid!"; @@ -447,8 +458,6 @@ void CoreNetwork::socketInitialized() emit socketInitialized(identity, localAddress(), localPort(), peerAddress(), peerPort()); - enablePingTimeout(); - // TokenBucket to avoid sending too much at once _messageDelay = 2200; // this seems to be a safe value (2.2 seconds delay) _burstSize = 5;