Bug 1562315 - Respect again=false indicated by http2 session when calling through TLSFilterTransaction, r=dragana

Differential Revision: https://phabricator.services.mozilla.com/D37391

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Honza Bambas 2019-07-09 13:52:27 +00:00
Родитель c052688204
Коммит f38f54b139
2 изменённых файлов: 44 добавлений и 10 удалений

Просмотреть файл

@ -355,23 +355,46 @@ nsresult TLSFilterTransaction::ReadSegments(nsAHttpSegmentReader* aReader,
return NS_SUCCEEDED(rv) ? mReadSegmentReturnValue : rv;
}
nsresult TLSFilterTransaction::WriteSegments(nsAHttpSegmentWriter* aWriter,
uint32_t aCount,
uint32_t* outCountWritten) {
nsresult TLSFilterTransaction::WriteSegmentsAgain(nsAHttpSegmentWriter* aWriter,
uint32_t aCount,
uint32_t* outCountWritten,
bool* again) {
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
LOG(("TLSFilterTransaction::WriteSegments %p max=%d\n", this, aCount));
LOG(("TLSFilterTransaction::WriteSegmentsAgain %p max=%d\n", this, aCount));
if (!mTransaction) {
return mCloseReason;
}
bool againBeforeWriteSegmentsCall = *again;
mSegmentWriter = aWriter;
nsresult rv = mTransaction->WriteSegments(this, aCount, outCountWritten);
if (NS_SUCCEEDED(rv) && NS_FAILED(mFilterReadCode) && !(*outCountWritten)) {
// nsPipe turns failures into silent OK.. undo that!
rv = mFilterReadCode;
if (Connection() && (mFilterReadCode == NS_BASE_STREAM_WOULD_BLOCK)) {
Unused << Connection()->ResumeRecv();
nsresult rv =
mTransaction->WriteSegmentsAgain(this, aCount, outCountWritten, again);
if (NS_SUCCEEDED(rv) && !(*outCountWritten)) {
if (NS_FAILED(mFilterReadCode)) {
// nsPipe turns failures into silent OK.. undo that!
rv = mFilterReadCode;
if (Connection() && (mFilterReadCode == NS_BASE_STREAM_WOULD_BLOCK)) {
Unused << Connection()->ResumeRecv();
}
}
if (againBeforeWriteSegmentsCall && !*again) {
LOG(
("TLSFilterTransaction %p called trans->WriteSegments which dropped "
"the 'again' flag",
this));
// The transaction (=h2 session) wishes to break the loop. There is a
// pending close of the transaction that is being handled by the current
// input stream of the session. After cancellation of that transaction
// the state of the stream will change and move the state machine of the
// session forward on the next call of WriteSegmentsAgain. But if there
// are no data on the socket to read to call this code again, the session
// and the stream will just hang in an intermediate state, blocking. Hence
// forcing receive to finish the stream cleanup.
if (Connection()) {
Unused << Connection()->ForceRecv();
}
}
}
LOG(("TLSFilterTransaction %p called trans->WriteSegments rv=%" PRIx32
@ -380,6 +403,13 @@ nsresult TLSFilterTransaction::WriteSegments(nsAHttpSegmentWriter* aWriter,
return rv;
}
nsresult TLSFilterTransaction::WriteSegments(nsAHttpSegmentWriter* aWriter,
uint32_t aCount,
uint32_t* outCountWritten) {
bool again = false;
return WriteSegmentsAgain(aWriter, aCount, outCountWritten, &again);
}
nsresult TLSFilterTransaction::GetTransactionSecurityInfo(
nsISupports** outSecInfo) {
if (!mSecInfo) {

Просмотреть файл

@ -144,6 +144,10 @@ class TLSFilterTransaction final : public nsAHttpTransaction,
NullHttpTransaction* QueryNullTransaction() override;
nsHttpTransaction* QueryHttpTransaction() override;
SpdyConnectTransaction* QuerySpdyConnectTransaction() override;
MOZ_MUST_USE nsresult WriteSegmentsAgain(nsAHttpSegmentWriter* writer,
uint32_t count,
uint32_t* countWritten,
bool* again) override;
private:
MOZ_MUST_USE nsresult StartTimerCallback();