Skip to content

Commit d30dd67

Browse files
committed
quic: FIx several minor errors
1 parent 431b994 commit d30dd67

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

src/quic/session.cc

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -560,9 +560,9 @@ struct Session::Impl final : public MemoryRetainer {
560560
// will remove themselves from the Session as soon as they are closed.
561561
// Note: we create a copy because the streams will remove themselves
562562
// while they are cleaning up which will invalidate the iterator.
563-
StreamsMap streams = streams_;
563+
StreamsMap streams = streams_; // needs to be a ref
564564
for (auto& stream : streams) stream.second->Destroy(last_error_);
565-
DCHECK(streams.empty());
565+
DCHECK(streams_.empty()); // do not check our local copy
566566

567567
// Clear the pending streams.
568568
while (!pending_bidi_stream_queue_.IsEmpty()) {
@@ -1397,8 +1397,10 @@ void Session::Close(CloseMethod method) {
13971397
Debug(this, "Closing with error: %s", impl_->last_error_);
13981398
}
13991399

1400-
STAT_RECORD_TIMESTAMP(Stats, closing_at);
1401-
impl_->state_->closing = 1;
1400+
// This is done already in the implmentation
1401+
// STAT_RECORD_TIMESTAMP(Stats, closing_at);
1402+
// The next line would be prevent, that close of the implementation is executed!
1403+
// impl_->state_->closing = 1;
14021404

14031405
// With both the DEFAULT and SILENT options, we will proceed to closing
14041406
// the session immediately. All open streams will be immediately destroyed
@@ -1449,7 +1451,8 @@ void Session::FinishClose() {
14491451
// FinishClose() should be called only after, and as a result of, Close()
14501452
// being called first.
14511453
DCHECK(!is_destroyed());
1452-
DCHECK(impl_->state_->closing);
1454+
// The next line does not make sense, as in the implementation is also checking if closing is not in progress
1455+
// DCHECK(impl_->state_->closing);
14531456

14541457
// If impl_->Close() returns true, then the session can be destroyed
14551458
// immediately without round-tripping through JavaScript.
@@ -1467,8 +1470,7 @@ void Session::Destroy() {
14671470
// being called first.
14681471
DCHECK(impl_);
14691472
DCHECK(impl_->state_->closing);
1470-
Debug(this, "Session destroyed");
1471-
impl_.reset();
1473+
Debug(this, "Session destroyed");
14721474
if (qlog_stream_ || keylog_stream_) {
14731475
env()->SetImmediate(
14741476
[qlog = qlog_stream_, keylog = keylog_stream_](Environment*) {
@@ -1478,6 +1480,9 @@ void Session::Destroy() {
14781480
}
14791481
qlog_stream_.reset();
14801482
keylog_stream_.reset();
1483+
impl_.reset(); // This can cause the session (so us) object to be garbage
1484+
// collected, so the session object may not be valid after
1485+
// this call.
14811486
}
14821487

14831488
PendingStream::PendingStreamQueue& Session::pending_bidi_stream_queue() const {
@@ -2091,7 +2096,7 @@ void Session::RemoveStream(stream_id id) {
20912096
// returns.
20922097
if (impl_->state_->closing && impl_->state_->graceful_close) {
20932098
FinishClose();
2094-
CHECK(is_destroyed());
2099+
// CHECK(is_destroyed()); // this will not work, our this pointer may not be valid anymore!
20952100
}
20962101
}
20972102

0 commit comments

Comments
 (0)