diff --git a/netwerk/sctp/datachannel/DataChannel.cpp b/netwerk/sctp/datachannel/DataChannel.cpp index 5385c9e83219..48d1fc4db1a6 100644 --- a/netwerk/sctp/datachannel/DataChannel.cpp +++ b/netwerk/sctp/datachannel/DataChannel.cpp @@ -1778,7 +1778,7 @@ DataChannelConnection::HandleStreamResetEvent(const struct sctp_stream_reset_eve LOG(("Disconnected DataChannel %p from connection %p", (void *) channel.get(), (void *) channel->mConnection.get())); - channel->Destroy(); + channel->DestroyLocked(); // At this point when we leave here, the object is a zombie held alive only by the DOM object } else { LOG(("Can't find incoming channel %d",i)); @@ -2502,7 +2502,7 @@ DataChannelConnection::CloseInt(DataChannel *aChannel) aChannel->mState = CLOSING; if (mState == CLOSED) { // we're not going to hang around waiting - channel->Destroy(); + channel->DestroyLocked(); } // At this point when we leave here, the object is a zombie held alive only by the DOM object } @@ -2556,13 +2556,15 @@ void DataChannel::Close() { ENSURE_DATACONNECTION; + RefPtr connection(mConnection); mConnection->Close(this); } // Used when disconnecting from the DataChannelConnection void -DataChannel::Destroy() +DataChannel::DestroyLocked() { + mConnection->mLock.AssertCurrentThreadOwns(); ENSURE_DATACONNECTION; LOG(("Destroying Data channel %u", mStream)); diff --git a/netwerk/sctp/datachannel/DataChannel.h b/netwerk/sctp/datachannel/DataChannel.h index 2ccdc48a835d..6386dbb498df 100644 --- a/netwerk/sctp/datachannel/DataChannel.h +++ b/netwerk/sctp/datachannel/DataChannel.h @@ -337,10 +337,11 @@ private: ~DataChannel(); public: - void Destroy(); // when we disconnect from the connection after stream RESET - NS_INLINE_DECL_THREADSAFE_REFCOUNTING(DataChannel) + // when we disconnect from the connection after stream RESET + void DestroyLocked(); + // Close this DataChannel. Can be called multiple times. MUST be called // before destroying the DataChannel (state must be CLOSED or CLOSING). void Close();