Skip to content

Commit d112cab

Browse files
committed
quic: fix no onstream handler crash quic
Signed-off-by: Efe Karasakal <hi@efe.dev>
1 parent b0fa732 commit d112cab

3 files changed

Lines changed: 12 additions & 0 deletions

File tree

src/quic/application.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -760,6 +760,11 @@ class DefaultApplication final : public Session::Application {
760760
// during the onstream callback (via MakeCallback re-entrancy).
761761
return false;
762762
}
763+
764+
// The stream was created, but was immediately destroyed because there's no onstream handler.
765+
if (stream->is_destroyed()) [[unlikely]] {
766+
return true;
767+
}
763768
} else {
764769
stream = BaseObjectPtr<Stream>(Stream::From(stream_user_data));
765770
if (!stream) {

src/quic/streams.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1325,6 +1325,10 @@ bool Stream::is_pending() const {
13251325
return state()->pending;
13261326
}
13271327

1328+
bool Stream::is_destroyed() const {
1329+
return stats()->destroyed_at != 0;
1330+
}
1331+
13281332
stream_id Stream::id() const {
13291333
return state()->id;
13301334
}

src/quic/streams.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,9 @@ class Stream final : public AsyncWrap,
267267
// to be created.
268268
bool is_pending() const;
269269

270+
// True if the stream is already destroyed.
271+
bool is_destroyed() const;
272+
270273
// True if we've completely sent all outbound data for this stream.
271274
// Importantly, this does not necessarily mean that we are completely
272275
// done with the outbound data. We may still be waiting on outbound

0 commit comments

Comments
 (0)