diff options
author | Markus Goetz <markus@woboq.com> | 2015-07-24 09:53:20 +0200 |
---|---|---|
committer | Markus Goetz (Woboq GmbH) <markus@woboq.com> | 2015-08-20 12:02:32 +0000 |
commit | bc32c0ebc0bc00db84ca2f28eb16ab2e5b53a1b6 (patch) | |
tree | ebd9b4f1419a4f7e60012356088b71c271837fb1 /src/network/access/qhttpprotocolhandler.cpp | |
parent | d99c9bcf2c4e14d3db02ad375aa624a0695e838d (diff) |
QNAM: Fix reply deadlocks on server closing connection
The _q_readyRead can also be called from readMoreLater() because we implemented
it so that bandwidth limited reading can be implemented.
This can lead to a race condition if the socket is closing at the specific moment
and then deadlock the channel: It will stay unusable with a zombie request.
The fix in QHttpProtocolaHandler checks if there is actually bytes available to read
from the socket and only then continue.
The fix in the HTTP channel needs to be done to properly finish the reply in
cases of a server replying with HTTP/1.0 or "Connection: close".
The delayed incovation of _q_receiveReply will properly finish up the reply.
Change-Id: I19ce2ae595f91d56386cc7406ccacc9935672b6b
Reviewed-by: Richard J. Moore <rich@kde.org>
Diffstat (limited to 'src/network/access/qhttpprotocolhandler.cpp')
-rw-r--r-- | src/network/access/qhttpprotocolhandler.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/network/access/qhttpprotocolhandler.cpp b/src/network/access/qhttpprotocolhandler.cpp index ab2e3dac57..a2083158f1 100644 --- a/src/network/access/qhttpprotocolhandler.cpp +++ b/src/network/access/qhttpprotocolhandler.cpp @@ -237,7 +237,12 @@ void QHttpProtocolHandler::_q_readyRead() } if (m_channel->isSocketWaiting() || m_channel->isSocketReading()) { - m_channel->state = QHttpNetworkConnectionChannel::ReadingState; + if (m_socket->bytesAvailable()) { + // We might get a spurious call from readMoreLater() + // call of the QHttpNetworkConnection even while the socket is disconnecting. + // Therefore check if there is actually bytes available before changing the channel state. + m_channel->state = QHttpNetworkConnectionChannel::ReadingState; + } if (m_reply) _q_receiveReply(); } |