diff options
author | Thiago Macieira <thiago.macieira@nokia.com> | 2009-04-16 08:00:10 (GMT) |
---|---|---|
committer | Thiago Macieira <thiago.macieira@nokia.com> | 2009-04-16 11:37:16 (GMT) |
commit | 5c359a9b599e2024d070534c10c5a0e224eca5d8 (patch) | |
tree | af6e80a0919d3f8c929cb129632e1f618ca17ef9 | |
parent | 78659fbe2d4ad8a01b41cb485f57b4a66c031fd5 (diff) | |
download | Qt-5c359a9b599e2024d070534c10c5a0e224eca5d8.zip Qt-5c359a9b599e2024d070534c10c5a0e224eca5d8.tar.gz Qt-5c359a9b599e2024d070534c10c5a0e224eca5d8.tar.bz2 |
Add a warning for trying to connectToHost() when disconnecting.
Right now, we print this warning if connectToHost() is called when
we're in ConnectingState (waiting for remote to SYN,ACK) or in
ConnectedState. This also means connectToHost() allows interruption of
the HostLookupState cleanly (I think).
But if you called connectToHost() right after disconnectFromHost() and
there were data to write, the connectToHost() could discard the
pending outgoing data and reconnect. Or not, depending on whether the
DNS resolution ended first. In other words, race condition.
Reviewed-by: Peter Hartmann
-rw-r--r-- | src/network/socket/qabstractsocket.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/network/socket/qabstractsocket.cpp b/src/network/socket/qabstractsocket.cpp index f8cf4ca..f9750f2 100644 --- a/src/network/socket/qabstractsocket.cpp +++ b/src/network/socket/qabstractsocket.cpp @@ -1263,7 +1263,7 @@ void QAbstractSocket::connectToHostImplementation(const QString &hostName, quint (int) openMode); #endif - if (d->state == ConnectedState || d->state == ConnectingState) { + if (d->state == ConnectedState || d->state == ConnectingState || d->state == ClosingState) { qWarning("QAbstractSocket::connectToHost() called when already connecting/connected to \"%s\"", qPrintable(hostName)); return; } |