Avoid DCHECK in P2PTransportChannel::MorePingable.

Some implementations of std::max_element (used to find the "most
pingable" connection) seem to compare an element with itself, which
MorePingable doesn't handle.

Fixing by handling the self-comparison outside MorePingable.

Bug: webrtc:8697
Change-Id: Ieb34580f52037639c00041a4e65901cad92d0971
Reviewed-on: https://webrtc-review.googlesource.com/62402
Reviewed-by: Qingsi Wang <qingsi@webrtc.org>
Commit-Queue: Taylor Brandstetter <deadbeef@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22543}
This commit is contained in:
Taylor Brandstetter 2018-03-16 10:20:29 -07:00 committed by Commit Bot
parent 32362a6729
commit 2c8773b2bd

View File

@ -1966,6 +1966,11 @@ Connection* P2PTransportChannel::FindNextPingableConnection() {
auto iter =
std::max_element(pingable_connections.begin(), pingable_connections.end(),
[this](Connection* conn1, Connection* conn2) {
// Some implementations of max_element compare an
// element with itself.
if (conn1 == conn2) {
return false;
}
return MorePingable(conn1, conn2) == conn2;
});
if (iter != pingable_connections.end()) {