| Index: webrtc/p2p/base/p2ptransportchannel.cc
|
| diff --git a/webrtc/p2p/base/p2ptransportchannel.cc b/webrtc/p2p/base/p2ptransportchannel.cc
|
| index 5238da83ca9302954e00b4a5204fc5121eda6851..32a996c5d5758690390d90d8e495efaf4789deef 100644
|
| --- a/webrtc/p2p/base/p2ptransportchannel.cc
|
| +++ b/webrtc/p2p/base/p2ptransportchannel.cc
|
| @@ -136,23 +136,22 @@ void P2PTransportChannel::AddAllocatorSession(
|
|
|
| session->set_generation(static_cast<uint32_t>(allocator_sessions_.size()));
|
| session->SignalPortReady.connect(this, &P2PTransportChannel::OnPortReady);
|
| - session->SignalPortsRemoved.connect(this,
|
| - &P2PTransportChannel::OnPortsRemoved);
|
| - session->SignalPortPruned.connect(this, &P2PTransportChannel::OnPortPruned);
|
| + session->SignalPortsPruned.connect(this, &P2PTransportChannel::OnPortsPruned);
|
| session->SignalCandidatesReady.connect(
|
| this, &P2PTransportChannel::OnCandidatesReady);
|
| session->SignalCandidatesRemoved.connect(
|
| this, &P2PTransportChannel::OnCandidatesRemoved);
|
| session->SignalCandidatesAllocationDone.connect(
|
| this, &P2PTransportChannel::OnCandidatesAllocationDone);
|
| + if (!allocator_sessions_.empty()) {
|
| + allocator_session()->PruneAllPorts();
|
| + }
|
| + allocator_sessions_.push_back(std::move(session));
|
|
|
| // We now only want to apply new candidates that we receive to the ports
|
| // created by this new session because these are replacing those of the
|
| // previous sessions.
|
| - removed_ports_.insert(removed_ports_.end(), ports_.begin(), ports_.end());
|
| - ports_.clear();
|
| -
|
| - allocator_sessions_.push_back(std::move(session));
|
| + PruneAllPorts();
|
| }
|
|
|
| void P2PTransportChannel::AddConnection(Connection* connection) {
|
| @@ -240,9 +239,9 @@ void P2PTransportChannel::SetIceRole(IceRole ice_role) {
|
| for (PortInterface* port : ports_) {
|
| port->SetIceRole(ice_role);
|
| }
|
| - // Update role on removed ports as well, because they may still have
|
| + // Update role on pruned ports as well, because they may still have
|
| // connections alive that should be using the correct role.
|
| - for (PortInterface* port : removed_ports_) {
|
| + for (PortInterface* port : pruned_ports_) {
|
| port->SetIceRole(ice_role);
|
| }
|
| }
|
| @@ -250,7 +249,7 @@ void P2PTransportChannel::SetIceRole(IceRole ice_role) {
|
|
|
| void P2PTransportChannel::SetIceTiebreaker(uint64_t tiebreaker) {
|
| ASSERT(worker_thread_ == rtc::Thread::Current());
|
| - if (!ports_.empty() || !removed_ports_.empty()) {
|
| + if (!ports_.empty() || !pruned_ports_.empty()) {
|
| LOG(LS_ERROR)
|
| << "Attempt to change tiebreaker after Port has been allocated.";
|
| return;
|
| @@ -1678,20 +1677,19 @@ void P2PTransportChannel::OnPortDestroyed(PortInterface* port) {
|
| ASSERT(worker_thread_ == rtc::Thread::Current());
|
|
|
| ports_.erase(std::remove(ports_.begin(), ports_.end(), port), ports_.end());
|
| - removed_ports_.erase(
|
| - std::remove(removed_ports_.begin(), removed_ports_.end(), port),
|
| - removed_ports_.end());
|
| + pruned_ports_.erase(
|
| + std::remove(pruned_ports_.begin(), pruned_ports_.end(), port),
|
| + pruned_ports_.end());
|
| LOG(INFO) << "Removed port because it is destroyed: " << ports_.size()
|
| << " remaining";
|
| }
|
|
|
| -void P2PTransportChannel::OnPortsRemoved(
|
| +void P2PTransportChannel::OnPortsPruned(
|
| PortAllocatorSession* session,
|
| const std::vector<PortInterface*>& ports) {
|
| ASSERT(worker_thread_ == rtc::Thread::Current());
|
| - LOG(LS_INFO) << "Remove " << ports.size() << " ports";
|
| for (PortInterface* port : ports) {
|
| - if (RemovePort(port)) {
|
| + if (PrunePort(port)) {
|
| LOG(INFO) << "Removed port: " << port->ToString() << " " << ports_.size()
|
| << " remaining";
|
| }
|
| @@ -1730,22 +1728,19 @@ void P2PTransportChannel::OnRegatherOnFailedNetworks() {
|
| MSG_REGATHER_ON_FAILED_NETWORKS);
|
| }
|
|
|
| -void P2PTransportChannel::OnPortPruned(PortAllocatorSession* session,
|
| - PortInterface* port) {
|
| - if (RemovePort(port)) {
|
| - LOG(INFO) << "Removed port because it is pruned: " << port->ToString()
|
| - << " " << ports_.size() << " remaining";
|
| - }
|
| +void P2PTransportChannel::PruneAllPorts() {
|
| + pruned_ports_.insert(pruned_ports_.end(), ports_.begin(), ports_.end());
|
| + ports_.clear();
|
| }
|
|
|
| -bool P2PTransportChannel::RemovePort(PortInterface* port) {
|
| +bool P2PTransportChannel::PrunePort(PortInterface* port) {
|
| auto it = std::find(ports_.begin(), ports_.end(), port);
|
| // Don't need to do anything if the port has been deleted from the port list.
|
| if (it == ports_.end()) {
|
| return false;
|
| }
|
| ports_.erase(it);
|
| - removed_ports_.push_back(port);
|
| + pruned_ports_.push_back(port);
|
| return true;
|
| }
|
|
|
|
|