From 1eeab2d27f61485cb53364d40339a8d832a076e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Mon, 24 Jun 2019 18:55:36 +0200 Subject: QSocks5SocketEngine: account for in-transit signal when waiting for read When calling waitFor{ReadyRead,Disconnected} it will wait for data but if the data is already received and the read notification has been queued (and there's no more data coming in) it will return false. By checking if a read notification has been queued and then handling this we can easily take care of this scenario. Fixes some flaky tests which missed the read data in waitForDisconnect and similar. Fixes: QTBUG-38385 Change-Id: Ic05d59883c1175783e56ff1822b6636c35aec874 Reviewed-by: Volker Hilsheimer --- src/network/socket/qsocks5socketengine.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src') diff --git a/src/network/socket/qsocks5socketengine.cpp b/src/network/socket/qsocks5socketengine.cpp index d2328f8536..e7e4d64c32 100644 --- a/src/network/socket/qsocks5socketengine.cpp +++ b/src/network/socket/qsocks5socketengine.cpp @@ -1753,6 +1753,11 @@ bool QSocks5SocketEngine::waitForRead(int msecs, bool *timedOut) return false; if (d->data->controlSocket->state() == QAbstractSocket::UnconnectedState) return true; + if (bytesAvailable() && d->readNotificationPending) { + // We've got some data incoming, but the queued call hasn't been performed yet. + // The data is where we expect it to be already, so just return true. + return true; + } // we're connected if (d->mode == QSocks5SocketEnginePrivate::ConnectMode || -- cgit v1.2.3