From aeb36d5292abd979b9c064877f3ed1b4da961c4e Mon Sep 17 00:00:00 2001 From: Alex Trotsenko Date: Thu, 9 Jun 2016 18:37:59 +0300 Subject: 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 --- src/network/socket/qabstractsocket.cpp | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) (limited to 'src/network') diff --git a/src/network/socket/qabstractsocket.cpp b/src/network/socket/qabstractsocket.cpp index 098739adc3..88237dc416 100644 --- a/src/network/socket/qabstractsocket.cpp +++ b/src/network/socket/qabstractsocket.cpp @@ -2651,9 +2651,8 @@ void QAbstractSocket::setPeerName(const QString &name) } /*! - Closes the I/O device for the socket, disconnects the socket's connection with the - host, closes the socket, and resets the name, address, port number and underlying - socket descriptor. + Closes the I/O device for the socket and calls disconnectFromHost() + to close the socket's connection. See QIODevice::close() for a description of the actions that occur when an I/O device is closed. @@ -2669,13 +2668,6 @@ void QAbstractSocket::close() QIODevice::close(); if (d->state != UnconnectedState) disconnectFromHost(); - - d->localPort = 0; - d->peerPort = 0; - d->localAddress.clear(); - d->peerAddress.clear(); - d->peerName.clear(); - d->cachedSocketDescriptor = -1; } /*! @@ -2778,6 +2770,7 @@ void QAbstractSocket::disconnectFromHost() d->peerPort = 0; d->localAddress.clear(); d->peerAddress.clear(); + d->peerName.clear(); d->setWriteChannelCount(0); #if defined(QABSTRACTSOCKET_DEBUG) -- cgit v1.2.3