commit ce76403552ad9d180fe60b1a2462ff91eb132807
parent 4577d758859d1ed89c1688389ecb50d3b17c242f
Author: Byron Campen <docfaraday@gmail.com>
Date: Wed, 29 Oct 2025 12:35:17 +0000
Bug 1988096: Make sure these are only run once. r=ng
Differential Revision: https://phabricator.services.mozilla.com/D269070
Diffstat:
2 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/netwerk/sctp/datachannel/DataChannel.cpp b/netwerk/sctp/datachannel/DataChannel.cpp
@@ -1202,6 +1202,10 @@ void DataChannelConnection::EndOfStream(const RefPtr<DataChannel>& aChannel) {
[this, self = RefPtr<DataChannelConnection>(this), channel = aChannel,
stream = aChannel->mStream]() {
if (channel->mSendStreamNeedsReset) {
+ if (channel->mEndOfStreamCalled) {
+ return;
+ }
+ channel->mEndOfStreamCalled = true;
DC_INFO((
"%p: Need to send a reset for channel %p, closing gracefully",
this, channel.get()));
@@ -1543,6 +1547,10 @@ void DataChannel::AnnounceClosed() {
NS_NewCancelableRunnableFunction(
"DataChannel::AnnounceClosed",
[this, self = RefPtr<DataChannel>(this), connection = mConnection]() {
+ if (mAnnouncedClosed) {
+ return;
+ }
+ mAnnouncedClosed = true;
// We have to unset this first, and then fire DOM events, so the
// event handler won't hit an error if it tries to reuse this id.
if (mStream != INVALID_STREAM) {
diff --git a/netwerk/sctp/datachannel/DataChannel.h b/netwerk/sctp/datachannel/DataChannel.h
@@ -479,6 +479,7 @@ class DataChannel {
dom::RTCDataChannel* mMainthreadDomDataChannel = nullptr;
bool mHasWorkerDomDataChannel = false;
bool mEverOpened = false;
+ bool mAnnouncedClosed = false;
uint16_t mStream;
RefPtr<DataChannelConnection> mConnection;
@@ -488,6 +489,7 @@ class DataChannel {
bool mWaitingForAck = false;
bool mSendStreamNeedsReset = false;
bool mRecvStreamNeedsReset = false;
+ bool mEndOfStreamCalled = false;
nsTArray<OutgoingMsg> mBufferedData;
std::map<uint16_t, IncomingMsg> mRecvBuffers;