diff --git a/src/quic/cid.cc b/src/quic/cid.cc index fdc636145210b2..1b5fdd861b7a9a 100644 --- a/src/quic/cid.cc +++ b/src/quic/cid.cc @@ -20,14 +20,12 @@ CID::CID() : ptr_(&cid_) { CID::CID(const ngtcp2_cid& cid) : CID(cid.data, cid.datalen) {} CID::CID(const uint8_t* data, size_t len) : CID() { - DCHECK_GE(len, kMinLength); DCHECK_LE(len, kMaxLength); ngtcp2_cid_init(&cid_, data, len); } CID::CID(const ngtcp2_cid* cid) : ptr_(cid) { CHECK_NOT_NULL(cid); - DCHECK_GE(cid->datalen, kMinLength); DCHECK_LE(cid->datalen, kMaxLength); } diff --git a/src/quic/session.cc b/src/quic/session.cc index 30f91163418d16..d939edee18e01a 100644 --- a/src/quic/session.cc +++ b/src/quic/session.cc @@ -814,6 +814,14 @@ struct Session::Impl final : public MemoryRetainer { void* user_data, void* stream_user_data) { NGTCP2_CALLBACK_SCOPE(session) + // The callback will be invoked with datalen 0 if a zero-length + // stream frame with fin flag set is received. In that case, let's + // just ignore it. + // Per ngtcp2, the range of bytes that are being acknowledged here + // are `[offset, offset + datalen]` but we only really care about + // the datalen as our accounting does not track the offset and + // acknowledges should never come out of order here. + if (datalen == 0) return NGTCP2_SUCCESS; return session->application().AcknowledgeStreamData(stream_id, datalen) ? NGTCP2_SUCCESS : NGTCP2_ERR_CALLBACK_FAILURE; @@ -1387,6 +1395,7 @@ void Session::Close(Session::CloseMethod method) { } STAT_RECORD_TIMESTAMP(Stats, closing_at); + impl_->state_->closing = 1; // With both the DEFAULT and SILENT options, we will proceed to closing // the session immediately. All open streams will be immediately destroyed @@ -1436,7 +1445,7 @@ void Session::Close(Session::CloseMethod method) { void Session::FinishClose() { // FinishClose() should be called only after, and as a result of, Close() // being called first. - DCHECK(impl_); + DCHECK(!is_destroyed()); DCHECK(impl_->state_->closing); // If impl_->Close() returns true, then the session can be destroyed diff --git a/src/quic/streams.cc b/src/quic/streams.cc index f1ce7d2e562703..f7b2ed275f9e15 100644 --- a/src/quic/streams.cc +++ b/src/quic/streams.cc @@ -1107,7 +1107,7 @@ void Stream::Acknowledge(size_t datalen) { DCHECK_GE(datalen, STAT_GET(Stats, max_offset_ack)); STAT_SET(Stats, max_offset_ack, datalen); - // // Consumes the given number of bytes in the buffer. + // Consumes the given number of bytes in the buffer. outbound_->Acknowledge(datalen); }