HTTP internals: keep consistent state in channel and protocol handler

It could be that the channel has its reply already reset to 0, while
the protocol handler thinks the reply is still active, which might
lead to weird behavior including hard to reproduce crashes.

Task-number: QTBUG-37424

Change-Id: I89b65d34caaa546a343edc2ee205aa76425de88f
Reviewed-by: Richard J. Moore <rich@kde.org>
This commit is contained in:
Peter Hartmann 2014-03-13 16:55:28 +01:00 committed by The Qt Project
parent 61fda89cd1
commit 2bbdc6358f

View File

@ -377,6 +377,8 @@ void QHttpNetworkConnectionPrivate::emitReplyError(QAbstractSocket *socket,
// Clean the channel // Clean the channel
channels[i].close(); channels[i].close();
channels[i].reply = 0; channels[i].reply = 0;
if (channels[i].protocolHandler)
channels[i].protocolHandler->setReply(0);
channels[i].request = QHttpNetworkRequest(); channels[i].request = QHttpNetworkRequest();
if (socket) if (socket)
channels[i].requeueCurrentlyPipelinedRequests(); channels[i].requeueCurrentlyPipelinedRequests();
@ -826,6 +828,8 @@ void QHttpNetworkConnectionPrivate::removeReply(QHttpNetworkReply *reply)
// is the reply associated the currently processing of this channel? // is the reply associated the currently processing of this channel?
if (channels[i].reply == reply) { if (channels[i].reply == reply) {
channels[i].reply = 0; channels[i].reply = 0;
if (channels[i].protocolHandler)
channels[i].protocolHandler->setReply(0);
channels[i].request = QHttpNetworkRequest(); channels[i].request = QHttpNetworkRequest();
channels[i].resendCurrent = false; channels[i].resendCurrent = false;