summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAlex Trotsenko <alex1973tr@gmail.com>2016-06-09 18:37:59 +0300
committerAlex Trotsenko <alex1973tr@gmail.com>2016-07-20 11:36:38 +0000
commitaeb36d5292abd979b9c064877f3ed1b4da961c4e (patch)
tree0f291293d4ecf859ac9ba16034ef8bc56f84b66e /tests
parent902a5e7aaa0ec156d19b5a7988eff1809a6a2046 (diff)
QAbstractSocket: ensure bind()+connect() works on delayed close
While connecting, the socket goes through the HostLookupState. In this state, the socket engine is not yet created, unless the socket had previously been bound. When it has been bound, we should keep the socket engine even if the user initiates a delayed close by using the write()+close() sequence. Change-Id: Iefebcb33cd72cb49617acbac8e02af9d8209c869 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp
index 6bb502edcb..fb6b0c6e32 100644
--- a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp
+++ b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp
@@ -673,6 +673,12 @@ void tst_QTcpSocket::bindThenResolveHost()
const quint16 port = 80;
socket->connectToHost(hostName, port);
+ // Additionally, initiate a delayed close before the socket connects
+ // to ensure that we don't lose the socket engine in HostLookupState.
+ // After a connection has been established, socket should send all
+ // the pending data and close the socket engine automatically.
+ QVERIFY(socket->putChar(0));
+ socket->close();
QVERIFY2(socket->waitForConnected(), (hostName.toLocal8Bit() + ": " + QByteArray::number(port) + ' '
+ QtNetworkSettings::msgSocketError(*socket)).constData());