From cbc4750f52964e6e7e13e296e526de98ef538cd4 Mon Sep 17 00:00:00 2001 From: Robin Burchell Date: Thu, 24 Dec 2015 00:15:44 +0100 Subject: QSocks5SocketEngine: Always try to connect in connectToHost unless already connecting. Otherwise, connectInternal becomes a no-op after an initial connection attempt has been made (making the socket effectively useless if that connection attempt fails). A workaround is to close() the socket, which worked by virtue of QAbstractSocket's close() disconnecting (which ultimately calls resetSocketLayer, and destroys the socket engine instance) - meaning that the next connection attempt would have a fresh socks instance to try out the connection with. Reported-by: Gabe Edwards Change-Id: Iab1e84af6d4248fd75a6dfe5e79a3c73129aae0b Reviewed-by: Richard J. Moore --- src/network/socket/qsocks5socketengine.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/network/socket/qsocks5socketengine.cpp') diff --git a/src/network/socket/qsocks5socketengine.cpp b/src/network/socket/qsocks5socketengine.cpp index 26543883cc1..6868e8c73a3 100644 --- a/src/network/socket/qsocks5socketengine.cpp +++ b/src/network/socket/qsocks5socketengine.cpp @@ -1111,14 +1111,16 @@ bool QSocks5SocketEngine::connectInternal() } } - if (d->socks5State == QSocks5SocketEnginePrivate::Uninitialized - && d->socketState != QAbstractSocket::ConnectingState) { - setState(QAbstractSocket::ConnectingState); - //limit buffer in internal socket, data is buffered in the external socket under application control - d->data->controlSocket->setReadBufferSize(65536); + if (d->socketState != QAbstractSocket::ConnectingState) { + if (d->socks5State == QSocks5SocketEnginePrivate::Uninitialized) { + setState(QAbstractSocket::ConnectingState); + //limit buffer in internal socket, data is buffered in the external socket under application control + d->data->controlSocket->setReadBufferSize(65536); + } + d->data->controlSocket->connectToHost(d->proxyInfo.hostName(), d->proxyInfo.port()); - return false; } + return false; } -- cgit v1.2.3