Bug 1259728 - minimal fix for reentrancy in pc.close(). r=jesup

MozReview-Commit-ID: Dji4d2bYTcj

--HG--
extra : rebase_source : 65d08cc6869444b2219ed7529ebad6c23115153f
This commit is contained in:
Jan-Ivar Bruaroey 2016-03-29 16:27:03 -04:00
parent 528d76cc52
commit 036cbca2a2
2 changed files with 15 additions and 3 deletions

View File

@ -622,8 +622,8 @@ RTCPeerConnection.prototype = {
dispatchEvent: function(event) {
// PC can close while events are firing if there is an async dispatch
// in c++ land
if (!this._closed) {
// in c++ land. But let through "closed" signaling and ice connection events.
if (!this._closed || this._inClose) {
this.__DOM_IMPL__.dispatchEvent(event);
}
},
@ -1139,11 +1139,13 @@ RTCPeerConnection.prototype = {
if (this._closed) {
return;
}
this._closed = true;
this._inClose = true;
this.changeIceConnectionState("closed");
this._localIdp.close();
this._remoteIdp.close();
this._impl.close();
this._closed = true;
this._inClose = false;
},
getLocalStreams: function() {

View File

@ -29,6 +29,16 @@
is(pc.signalingState, "closed", "signalingState is 'closed'");
is(pc.iceConnectionState, "closed", "iceConnectionState is 'closed'");
// test that pc is really closed (and doesn't crash, bug 1259728)
try {
pc.getLocalStreams();
} catch (e) {
exception = e;
}
is(exception && exception.name, "InvalidStateError",
"pc.getLocalStreams should throw when closed");
exception = null;
try {
pc.close();
} catch (e) {