Chromium Code Reviews| Index: webrtc/p2p/client/basicportallocator.cc |
| diff --git a/webrtc/p2p/client/basicportallocator.cc b/webrtc/p2p/client/basicportallocator.cc |
| index 22abf33e93639d90b276ca9d6c5cc025fca3a6e0..413c968df5b3273c46427c3d9ca5b61b87f7e6e1 100644 |
| --- a/webrtc/p2p/client/basicportallocator.cc |
| +++ b/webrtc/p2p/client/basicportallocator.cc |
| @@ -1072,7 +1072,6 @@ void AllocationSequence::OnReadPacket( |
| const rtc::PacketTime& packet_time) { |
| ASSERT(socket == udp_socket_.get()); |
| - bool turn_port_found = false; |
| // Try to find the TurnPort that matches the remote address. Note that the |
| // message could be a STUN binding response if the TURN server is also used as |
| @@ -1080,13 +1079,12 @@ void AllocationSequence::OnReadPacket( |
| // a STUN binding response, so we pass the message to TurnPort regardless of |
| // the message type. The TurnPort will just ignore the message since it will |
| // not find any request by transaction ID. |
| - for (std::vector<TurnPort*>::const_iterator it = turn_ports_.begin(); |
| - it != turn_ports_.end(); ++it) { |
| - TurnPort* port = *it; |
| + for (TurnPort* port : turn_ports_) { |
| if (port->server_address().address == remote_addr) { |
| - port->HandleIncomingPacket(socket, data, size, remote_addr, packet_time); |
| - turn_port_found = true; |
| - break; |
| + if (port->HandleIncomingPacket(socket, data, size, remote_addr, |
| + packet_time)) { |
| + return; |
| + } |
| } |
| } |
| @@ -1095,10 +1093,10 @@ void AllocationSequence::OnReadPacket( |
| // Pass the packet to the UdpPort if there is no matching TurnPort, or if |
| // the TURN server is also a STUN server. |
| - if (!turn_port_found || |
| - stun_servers.find(remote_addr) != stun_servers.end()) { |
| - udp_port_->HandleIncomingPacket( |
| - socket, data, size, remote_addr, packet_time); |
| + if (stun_servers.find(remote_addr) != stun_servers.end()) { |
|
honghaiz3
2016/04/22 01:49:03
I think this is incorrect.
In the current code, a
honghaiz3
2016/04/22 03:52:33
One possible approach is to use the existing logic
Sergey Ulanov
2016/04/22 18:05:52
Implemented this suggestion in Patch Set 4.
I'm no
honghaiz3
2016/04/22 19:17:27
I think patch set 4 is slightly safer.
Although p
|
| + RTC_DCHECK(udp_port_->SharedSocket()); |
| + udp_port_->HandleIncomingPacket(socket, data, size, remote_addr, |
| + packet_time); |
| } |
| } |
| } |