diff options
author | MÃ¥rten Nordheim <marten.nordheim@qt.io> | 2020-11-18 11:44:59 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2020-11-19 13:31:17 +0000 |
commit | 4e14824ff4fc60ac03ce9365aea79bf6f0fe1f94 (patch) | |
tree | 297eecc5cd9fad8570493f9b3c667d5e06cf53c9 /src/network | |
parent | 10ba2b36b95455a44488484c5751bd7e30a2be95 (diff) |
HTTP2: fix crash from assertion
In general the protocolHandler isn't deleted unless
the channel is being destructed. So instead of reset()ing
the pointer we keep it around.
Also update the http2protocolhandler to mimic the http1
handler a little closer: shutting down the channel in
receiveReply if there's no reply/activeStreams, and not
calling receiveReply at all if there's no activeStreams.
Change-Id: I702547f594deb6b0c1384068f7e93e560527e8e2
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
(cherry picked from commit 0b21c15b11e9af64741e26822f33dfba5975d9b0)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src/network')
-rw-r--r-- | src/network/access/qhttp2protocolhandler.cpp | 8 | ||||
-rw-r--r-- | src/network/access/qhttpnetworkconnectionchannel.cpp | 1 |
2 files changed, 7 insertions, 2 deletions
diff --git a/src/network/access/qhttp2protocolhandler.cpp b/src/network/access/qhttp2protocolhandler.cpp index 4c9e722166..91c41d8240 100644 --- a/src/network/access/qhttp2protocolhandler.cpp +++ b/src/network/access/qhttp2protocolhandler.cpp @@ -264,7 +264,8 @@ void QHttp2ProtocolHandler::_q_uploadDataDestroyed(QObject *uploadData) void QHttp2ProtocolHandler::_q_readyRead() { - _q_receiveReply(); + if (!goingAway || activeStreams.size()) + _q_receiveReply(); } void QHttp2ProtocolHandler::_q_receiveReply() @@ -272,6 +273,11 @@ void QHttp2ProtocolHandler::_q_receiveReply() Q_ASSERT(m_socket); Q_ASSERT(m_channel); + if (goingAway && activeStreams.isEmpty()) { + m_channel->close(); + return; + } + while (!goingAway || activeStreams.size()) { const auto result = frameReader.read(*m_socket); switch (result) { diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp index 9325787d5f..ba3cb8f071 100644 --- a/src/network/access/qhttpnetworkconnectionchannel.cpp +++ b/src/network/access/qhttpnetworkconnectionchannel.cpp @@ -1005,7 +1005,6 @@ void QHttpNetworkConnectionChannel::_q_error(QAbstractSocket::SocketError socket && switchedToHttp2)) { auto h2Handler = static_cast<QHttp2ProtocolHandler *>(protocolHandler.data()); h2Handler->handleConnectionClosure(); - protocolHandler.reset(); } } return; |