From 5c359a9b599e2024d070534c10c5a0e224eca5d8 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 16 Apr 2009 10:00:10 +0200 Subject: 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 --- src/network/socket/qabstractsocket.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/network/socket') diff --git a/src/network/socket/qabstractsocket.cpp b/src/network/socket/qabstractsocket.cpp index f8cf4caf07..f9750f2700 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; } -- cgit v1.2.3