Bug 1240760: Update DataChannel::Close() r=mcmanus

MozReview-Commit-ID: 7nN9h3M3O8w
This commit is contained in:
Randell Jesup 2016-02-19 01:08:07 -05:00
parent 18371f22fb
commit 0e9ad4317d
2 changed files with 8 additions and 5 deletions

View File

@ -1778,7 +1778,7 @@ DataChannelConnection::HandleStreamResetEvent(const struct sctp_stream_reset_eve
LOG(("Disconnected DataChannel %p from connection %p", LOG(("Disconnected DataChannel %p from connection %p",
(void *) channel.get(), (void *) channel->mConnection.get())); (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 // At this point when we leave here, the object is a zombie held alive only by the DOM object
} else { } else {
LOG(("Can't find incoming channel %d",i)); LOG(("Can't find incoming channel %d",i));
@ -2502,7 +2502,7 @@ DataChannelConnection::CloseInt(DataChannel *aChannel)
aChannel->mState = CLOSING; aChannel->mState = CLOSING;
if (mState == CLOSED) { if (mState == CLOSED) {
// we're not going to hang around waiting // 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 // 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() DataChannel::Close()
{ {
ENSURE_DATACONNECTION; ENSURE_DATACONNECTION;
RefPtr<DataChannelConnection> connection(mConnection);
mConnection->Close(this); mConnection->Close(this);
} }
// Used when disconnecting from the DataChannelConnection // Used when disconnecting from the DataChannelConnection
void void
DataChannel::Destroy() DataChannel::DestroyLocked()
{ {
mConnection->mLock.AssertCurrentThreadOwns();
ENSURE_DATACONNECTION; ENSURE_DATACONNECTION;
LOG(("Destroying Data channel %u", mStream)); LOG(("Destroying Data channel %u", mStream));

View File

@ -337,10 +337,11 @@ private:
~DataChannel(); ~DataChannel();
public: public:
void Destroy(); // when we disconnect from the connection after stream RESET
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(DataChannel) 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 // Close this DataChannel. Can be called multiple times. MUST be called
// before destroying the DataChannel (state must be CLOSED or CLOSING). // before destroying the DataChannel (state must be CLOSED or CLOSING).
void Close(); void Close();