TIL that flushing a socket may trigger a readyRead(). In certain cases
this would lead to compression being enabled on the client side too late
(because we would flush the socket before), breaking the sync to core.
As (contrary to starting SSL) enabling the compression does not care if
there's still uncompressed data in the socket's write buffer, we can just
remove this flush.
Also, let's make it explicit that we flush immediately before starting
encryption, rather than hiding that somewhere in the LegacyPeer, to avoid
introducing weird bugs later. And also flush the socket before handing the
peer over to the CoreSession, as we used to do before the refactoring -
we don't want bug #682 back.
RemotePeer::setSignalProxy(proxy);
// FIXME only in compat mode
RemotePeer::setSignalProxy(proxy);
// FIXME only in compat mode
if (proxy) {
// enable compression now if requested - the initial handshake is uncompressed in the legacy protocol!
_useCompression = socket()->property("UseCompression").toBool();
if (proxy) {
// enable compression now if requested - the initial handshake is uncompressed in the legacy protocol!
_useCompression = socket()->property("UseCompression").toBool();
m["LoginEnabled"] = m["Configured"] = msg.coreConfigured;
writeSocketData(m);
m["LoginEnabled"] = m["Configured"] = msg.coreConfigured;
writeSocketData(m);
- socket()->flush(); // ensure that the write cache is flushed before we switch to ssl
qDebug() << qPrintable(tr("Starting encryption for Client:")) << _peer->description();
connect(sslSocket, SIGNAL(sslErrors(const QList<QSslError> &)), SLOT(onSslErrors()));
qDebug() << qPrintable(tr("Starting encryption for Client:")) << _peer->description();
connect(sslSocket, SIGNAL(sslErrors(const QList<QSslError> &)), SLOT(onSslErrors()));
+ sslSocket->flush(); // ensure that the write cache is flushed before we switch to ssl (bug 682)
sslSocket->startServerEncryption();
#endif
}
sslSocket->startServerEncryption();
#endif
}
disconnect(_peer, 0, this, 0);
_peer->setParent(0); // Core needs to take care of this one now!
disconnect(_peer, 0, this, 0);
_peer->setParent(0); // Core needs to take care of this one now!
+ socket()->flush(); // Make sure all data is sent before handing over the peer (and socket) to the session thread (bug 682)
emit handshakeComplete(_peer, uid);
}
emit handshakeComplete(_peer, uid);
}