diff options
author | Alex Trotsenko <alex1973tr@gmail.com> | 2021-07-12 20:00:50 +0300 |
---|---|---|
committer | Alex Trotsenko <alex1973tr@gmail.com> | 2021-07-25 10:06:27 +0300 |
commit | 921ff400bbb84b0a5c51a9a04675dce17dac0cd8 (patch) | |
tree | 16a64d1e02ba845390ffb7014f578cac7c5f6e08 /src/network | |
parent | f18d8fd1fb405d2cefea298e2383e5a2e76fcd7a (diff) |
QLocalSocket/Win: allow delayed close to work
This mechanism was neither properly designed nor correctly tested
initially on Windows.
[ChangeLog][QtNetwork][Important Behavior Changes] QLocalSocket on
Windows now implements delayed closing, which is consistent with
the behavior on Unix.
Change-Id: Ic3bc427e68eea7f18201f6129df19fbc87d68101
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Diffstat (limited to 'src/network')
-rw-r--r-- | src/network/socket/qlocalsocket.cpp | 9 | ||||
-rw-r--r-- | src/network/socket/qlocalsocket_win.cpp | 16 |
2 files changed, 9 insertions, 16 deletions
diff --git a/src/network/socket/qlocalsocket.cpp b/src/network/socket/qlocalsocket.cpp index fba7f75663..a42b70546c 100644 --- a/src/network/socket/qlocalsocket.cpp +++ b/src/network/socket/qlocalsocket.cpp @@ -208,7 +208,14 @@ QT_BEGIN_NAMESPACE /*! \fn void QLocalSocket::close() - \reimp + + Closes the I/O device for the socket and calls disconnectFromServer() + to close the socket's connection. + + See QIODevice::close() for a description of the actions that occur when an I/O + device is closed. + + \sa abort() */ /*! diff --git a/src/network/socket/qlocalsocket_win.cpp b/src/network/socket/qlocalsocket_win.cpp index 5d0fdfb023..229efe0226 100644 --- a/src/network/socket/qlocalsocket_win.cpp +++ b/src/network/socket/qlocalsocket_win.cpp @@ -377,21 +377,11 @@ bool QLocalSocket::canReadLine() const void QLocalSocket::close() { Q_D(QLocalSocket); - if (openMode() == NotOpen) - return; QIODevice::close(); d->serverName = QString(); d->fullServerName = QString(); - - if (state() != UnconnectedState) { - if (bytesToWrite() > 0) { - disconnectFromServer(); - return; - } - - d->_q_pipeClosed(); - } + disconnectFromServer(); } bool QLocalSocket::flush() @@ -481,10 +471,6 @@ bool QLocalSocket::waitForDisconnected(int msecs) qWarning("QLocalSocket::waitForDisconnected() is not allowed in UnconnectedState"); return false; } - if (!openMode().testFlag(QIODevice::ReadOnly)) { - qWarning("QLocalSocket::waitForDisconnected isn't supported for write only pipes."); - return false; - } QDeadlineTimer deadline(msecs); while (!d->pipeReader->isPipeClosed()) { |