| Index: webrtc/pc/peerconnection.cc
 | 
| diff --git a/webrtc/pc/peerconnection.cc b/webrtc/pc/peerconnection.cc
 | 
| index 96e2b339a49d25faa32e449b2944c362b27c946a..750d821ff3da84be091c3ee9fc99fffe6873ef79 100644
 | 
| --- a/webrtc/pc/peerconnection.cc
 | 
| +++ b/webrtc/pc/peerconnection.cc
 | 
| @@ -1280,10 +1280,24 @@ void PeerConnection::SetLocalDescription(
 | 
|    signaling_thread()->Post(RTC_FROM_HERE, this,
 | 
|                             MSG_SET_SESSIONDESCRIPTION_SUCCESS, msg);
 | 
|  
 | 
| +  // According to JSEP, after setLocalDescription, changing the candidate pool
 | 
| +  // size is not allowed, and changing the set of ICE servers will not result
 | 
| +  // in new candidates being gathered.
 | 
| +  port_allocator_->FreezeCandidatePool();
 | 
| +
 | 
|    // MaybeStartGathering needs to be called after posting
 | 
|    // MSG_SET_SESSIONDESCRIPTION_SUCCESS, so that we don't signal any candidates
 | 
|    // before signaling that SetLocalDescription completed.
 | 
|    session_->MaybeStartGathering();
 | 
| +
 | 
| +  if (desc->type() == SessionDescriptionInterface::kAnswer) {
 | 
| +    // TODO(deadbeef): We already had to hop to the network thread for
 | 
| +    // MaybeStartGathering...
 | 
| +    network_thread()->Invoke<void>(
 | 
| +        RTC_FROM_HERE,
 | 
| +        rtc::Bind(&cricket::PortAllocator::DiscardPooledSessions,
 | 
| +                  port_allocator_.get()));
 | 
| +  }
 | 
|  }
 | 
|  
 | 
|  void PeerConnection::SetRemoteDescription(
 | 
| @@ -1394,6 +1408,15 @@ void PeerConnection::SetRemoteDescription(
 | 
|    SetSessionDescriptionMsg* msg = new SetSessionDescriptionMsg(observer);
 | 
|    signaling_thread()->Post(RTC_FROM_HERE, this,
 | 
|                             MSG_SET_SESSIONDESCRIPTION_SUCCESS, msg);
 | 
| +
 | 
| +  if (desc->type() == SessionDescriptionInterface::kAnswer) {
 | 
| +    // TODO(deadbeef): We already had to hop to the network thread for
 | 
| +    // MaybeStartGathering...
 | 
| +    network_thread()->Invoke<void>(
 | 
| +        RTC_FROM_HERE,
 | 
| +        rtc::Bind(&cricket::PortAllocator::DiscardPooledSessions,
 | 
| +                  port_allocator_.get()));
 | 
| +  }
 | 
|  }
 | 
|  
 | 
|  PeerConnectionInterface::RTCConfiguration PeerConnection::GetConfiguration() {
 | 
| @@ -1559,6 +1582,10 @@ void PeerConnection::Close() {
 | 
|  
 | 
|    session_->Close();
 | 
|    event_log_.reset();
 | 
| +  network_thread()->Invoke<void>(
 | 
| +      RTC_FROM_HERE,
 | 
| +      rtc::Bind(&cricket::PortAllocator::DiscardPooledSessions,
 | 
| +                port_allocator_.get()));
 | 
|  }
 | 
|  
 | 
|  void PeerConnection::OnSessionStateChange(WebRtcSession* /*session*/,
 | 
| 
 |