Do not assume nice behavior in error handling

SPDY is currently assuming it will only receive RST_STREAM messages on
active steams. This is however not always a safe assumption.

Task-number: QTBUG-37100
Change-Id: Ied89a68a209891992ad72daa513066efc1d7c421
Reviewed-by: Peter Hartmann <phartmann@blackberry.com>
bb10
Allan Sandfeld Jensen 2014-02-26 16:48:33 +01:00 committed by The Qt Project
parent f8c5dd9857
commit 1e29bf5b07
1 changed files with 3 additions and 2 deletions

View File

@ -959,7 +959,6 @@ void QSpdyProtocolHandler::handleRST_STREAM(char /*flags*/, quint32 length,
Q_UNUSED(length); // silence -Wunused-parameter
qint32 streamID = getStreamID(frameData.constData());
QHttpNetworkReply *httpReply = m_inFlightStreams.value(streamID).second;
Q_ASSERT(httpReply);
qint32 statusCodeInt = fourBytesToInt(frameData.constData() + 4);
RST_STREAM_STATUS_CODE statusCode = static_cast<RST_STREAM_STATUS_CODE>(statusCodeInt);
@ -1016,7 +1015,8 @@ void QSpdyProtocolHandler::handleRST_STREAM(char /*flags*/, quint32 length,
errorCode = QNetworkReply::ProtocolFailure;
errorMessage = "got SPDY RST_STREAM message with unknown error code";
}
replyFinishedWithError(httpReply, streamID, errorCode, errorMessage.constData());
if (httpReply)
replyFinishedWithError(httpReply, streamID, errorCode, errorMessage.constData());
}
void QSpdyProtocolHandler::handleSETTINGS(char flags, quint32 /*length*/, const QByteArray &frameData)
@ -1266,6 +1266,7 @@ void QSpdyProtocolHandler::replyFinished(QHttpNetworkReply *httpReply, qint32 st
void QSpdyProtocolHandler::replyFinishedWithError(QHttpNetworkReply *httpReply, qint32 streamID,
QNetworkReply::NetworkError errorCode, const char *errorMessage)
{
Q_ASSERT(httpReply);
httpReply->d_func()->state = QHttpNetworkReplyPrivate::SPDYClosed;
int streamsRemoved = m_inFlightStreams.remove(streamID);
Q_ASSERT(streamsRemoved == 1);