diff options
author | Peter Hartmann <peter.hartmann@nokia.com> | 2009-10-27 15:04:29 (GMT) |
---|---|---|
committer | Peter Hartmann <peter.hartmann@nokia.com> | 2009-10-27 15:38:38 (GMT) |
commit | 2d0b29c312ddf422595ce9debb3678bb5c4d51b6 (patch) | |
tree | cc9a88dcdfbc10db62c9ff9f9cb930d1e805f171 /src/network/socket/qsocks5socketengine.cpp | |
parent | d0b0e0ed8ac857d78e497b74bb1c3596273c53ba (diff) | |
download | Qt-2d0b29c312ddf422595ce9debb3678bb5c4d51b6.zip Qt-2d0b29c312ddf422595ce9debb3678bb5c4d51b6.tar.gz Qt-2d0b29c312ddf422595ce9debb3678bb5c4d51b6.tar.bz2 |
QAbstractSocket: wait with closing until all bytes have been written
only disconnect from host when all bytes have been written; i.e. not
only check whether the write buffer is empty, but also check whether
the socket engine has still bytes to write. This is necessary for
HTTP and SOCKS5 socket engine, because they both contain an inner TCP
socket which also does buffering. For the native socket engine, there
is no difference with this patch.
Reviewed-by: Markus Goetz
Reviewed-by: Thiago Macieira
Diffstat (limited to 'src/network/socket/qsocks5socketengine.cpp')
-rw-r--r-- | src/network/socket/qsocks5socketengine.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/network/socket/qsocks5socketengine.cpp b/src/network/socket/qsocks5socketengine.cpp index 30074cf..bd60ad1 100644 --- a/src/network/socket/qsocks5socketengine.cpp +++ b/src/network/socket/qsocks5socketengine.cpp @@ -1235,6 +1235,9 @@ void QSocks5SocketEnginePrivate::_q_controlSocketError(QAbstractSocket::SocketEr if (!readNotificationPending) connectData->readBuffer.clear(); emitReadNotification(); + data->controlSocket->close(); + // cause a disconnect in the outer socket + emitWriteNotification(); } else if (socks5State == Uninitialized || socks5State == AuthenticationMethodsSent || socks5State == Authenticating @@ -1245,6 +1248,7 @@ void QSocks5SocketEnginePrivate::_q_controlSocketError(QAbstractSocket::SocketEr } else { q_func()->setError(data->controlSocket->error(), data->controlSocket->errorString()); emitReadNotification(); + emitWriteNotification(); } } @@ -1623,6 +1627,16 @@ qint64 QSocks5SocketEngine::pendingDatagramSize() const } #endif // QT_NO_UDPSOCKET +qint64 QSocks5SocketEngine::bytesToWrite() const +{ + Q_D(const QSocks5SocketEngine); + if (d->data && d->data->controlSocket) { + return d->data->controlSocket->bytesToWrite(); + } else { + return 0; + } +} + int QSocks5SocketEngine::option(SocketOption option) const { Q_D(const QSocks5SocketEngine); |