[webrtc-pc] avoid risk of reentrancy

ShijunS has just created a new issue for 
https://github.com/w3c/webrtc-pc:

== avoid risk of reentrancy ==
Open an issue based on discussions with Bernard.  We should avoid any 
risk of reentrancy, and meanwhile clarify a few places for firing 
events in the related algorithm steps.

Section 4.3.1
----------
 ...
 If the process to apply description fails for any reason, then user 
agent must queue a task runs the following steps:
1. If connection's signaling state is closed, then abort these steps.
2. If the content of description is invalid or if description's type 
is wrong for the current signaling state of connection, then reject p 
with an InvalidSessionDescriptionError and abort these steps.
3. If description cannot be applied at the media layer, but the User 
Agent recovered, possibly by rolling back to the previous 
configuration, then reject p with IncompatibleSessionDescriptionError 
and abort these steps.
This occurs, for example, when the version of description is older 
than the one currently being used.
4. Otherwise, set connection's signaling state to closed.
5. Fire a simple event named signalingstatechange at connection. 
**[BA] Allows the signalingstatechange to execute code that could 
invalidate objects.** 
6. Reject p with InternalError.
...
...
5. If connection's signaling state changed above, fire a simple event 
named signalingstatechange at connection.
**[BA] Allows code to execute in the signalingstatechange event 
handler (e.g. PC.close) that could invalidate objects.**
6. If description is set as a local description, connection's ICE 
gathering state is new, and description contains media, then update 
connection's ICE gathering state to gathering.
**[BA] ICE gathering state is updated but the state change event isn't
 fired. Is a task queued for this?** 
7. If the process to apply description resulted in an ICE restart 
JSEP, then run the following steps:
  If connection is not already gathering, update connection's ICE 
gathering state to gathering.
  **[BA] ICE gathering state is updated but the state change event 
isn't fired. Is a task queued for this?** 
  If connection's ICE connection state is completed, update 
connection's ICE connection state to connected.
  **[BA] ICE connection state is updated but the state change event 
isn't fired. Is a task queued for this?**
8. If description is set as a remote description with new media 
descriptions [JSEP], the User Agent must dispatch a receiver for all 
new media descriptions.
9. If connection's signaling state is now stable, and the 
negotiation-needed flag is set, the User Agent must queue a task to 
fire a simple event named negotiationneeded at connection and clear 
the negotiation-needed flag.
10. Resolve p with undefined.
...

Section 6.2
------
...
2. Set channel's readyState attribute to closed.
3. If the transport was closed with an error, fire an NetworkError 
event at channel.
**[BA] The NetworkError event should be queued to avoid having an 
error handler execute prior to the next step.**
3. Fire a simple event named close at channel

Please view or discuss this issue at 
https://github.com/w3c/webrtc-pc/issues/492 using your GitHub account

Received on Friday, 5 February 2016 19:57:36 UTC