diff options
author | Alex Trotsenko <alex1973tr@gmail.com> | 2016-02-17 17:55:41 +0200 |
---|---|---|
committer | Alex Trotsenko <alex1973tr@gmail.com> | 2016-03-18 13:05:42 +0000 |
commit | bec47545dc7570bad2af3975ad3b92496ce6d9a3 (patch) | |
tree | 88ba2a32ec5d9203ed1230772ba6ae8b3e1904c6 /src/network | |
parent | d930c8b5fc4a7578a26868706354522f7448f089 (diff) |
QAbstractSocket: do not fail writing on read buffer overflow
canReadNotification() could return 'false' if either the socket has
been closed, or the read buffer has reached the maximum size. Because of
this duality, waitForBytesWritten() should not fail as a result of a
canReadNotification() call.
Change-Id: I9a15fa174a3b982a7ce404913caa38fc19f64622
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Reviewed-by: Markus Goetz (Woboq GmbH) <markus@woboq.com>
Diffstat (limited to 'src/network')
-rw-r--r-- | src/network/socket/qabstractsocket.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/network/socket/qabstractsocket.cpp b/src/network/socket/qabstractsocket.cpp index c6f5b8864b..802b623375 100644 --- a/src/network/socket/qabstractsocket.cpp +++ b/src/network/socket/qabstractsocket.cpp @@ -2253,8 +2253,10 @@ bool QAbstractSocket::waitForBytesWritten(int msecs) forever { bool readyToRead = false; bool readyToWrite = false; - if (!d->socketEngine->waitForReadOrWrite(&readyToRead, &readyToWrite, true, !d->writeBuffer.isEmpty(), - qt_subtract_from_timeout(msecs, stopWatch.elapsed()))) { + if (!d->socketEngine->waitForReadOrWrite(&readyToRead, &readyToWrite, + !d->readBufferMaxSize || d->buffer.size() < d->readBufferMaxSize, + !d->writeBuffer.isEmpty(), + qt_subtract_from_timeout(msecs, stopWatch.elapsed()))) { #if defined (QABSTRACTSOCKET_DEBUG) qDebug("QAbstractSocket::waitForBytesWritten(%i) failed (%i, %s)", msecs, d->socketEngine->error(), d->socketEngine->errorString().toLatin1().constData()); @@ -2269,8 +2271,7 @@ bool QAbstractSocket::waitForBytesWritten(int msecs) #if defined (QABSTRACTSOCKET_DEBUG) qDebug("QAbstractSocket::waitForBytesWritten calls canReadNotification"); #endif - if(!d->canReadNotification()) - return false; + d->canReadNotification(); } |