Http2: Clean out streams as they get deleted
Instead of keeping the empty QPointer in the hash forever let's try to keep the hash lean as to not punish iteration over it as the streams are being created and deleted. Pick-to: 6.8 Task-number: QTBUG-126772 Change-Id: Id7afa684a19e6a16726e5bda5debdd2f2bbe86ab Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
This commit is contained in:
parent
ca735d8d41
commit
94e8bb9630
@ -41,7 +41,23 @@ QHttp2Stream::QHttp2Stream(QHttp2Connection *connection, quint32 streamID) noexc
|
||||
qCDebug(qHttp2ConnectionLog, "[%p] new stream %u", connection, streamID);
|
||||
}
|
||||
|
||||
QHttp2Stream::~QHttp2Stream() noexcept = default;
|
||||
QHttp2Stream::~QHttp2Stream() noexcept {
|
||||
if (auto *connection = getConnection()) {
|
||||
if (m_state == State::Open || m_state == State::HalfClosedRemote) {
|
||||
qCDebug(qHttp2ConnectionLog, "[%p] stream %u, destroyed while still open", connection,
|
||||
m_streamID);
|
||||
// Check if we can still send data, then send RST_STREAM:
|
||||
if (connection->getSocket()) {
|
||||
if (isUploadingDATA())
|
||||
sendRST_STREAM(CANCEL);
|
||||
else
|
||||
sendRST_STREAM(HTTP2_NO_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
connection->m_streams.remove(streamID());
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn quint32 QHttp2Stream::streamID() const noexcept
|
||||
@ -866,6 +882,8 @@ QHttp2Connection::createStreamInternal()
|
||||
|
||||
QHttp2Stream *QHttp2Connection::createStreamInternal_impl(quint32 streamID)
|
||||
{
|
||||
Q_ASSERT(streamID > m_lastIncomingStreamID || streamID >= m_nextStreamID);
|
||||
|
||||
qsizetype numStreams = m_streams.size();
|
||||
QPointer<QHttp2Stream> &stream = m_streams[streamID];
|
||||
if (numStreams == m_streams.size()) // stream already existed
|
||||
|
Loading…
x
Reference in New Issue
Block a user