From 2c8773b2bd70652ba3230294aced7b5df4509123 Mon Sep 17 00:00:00 2001 From: Taylor Brandstetter Date: Fri, 16 Mar 2018 10:20:29 -0700 Subject: [PATCH] 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 Commit-Queue: Taylor Brandstetter Cr-Commit-Position: refs/heads/master@{#22543} --- p2p/base/p2ptransportchannel.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/p2p/base/p2ptransportchannel.cc b/p2p/base/p2ptransportchannel.cc index 1398cb1813..ab519f5b07 100644 --- a/p2p/base/p2ptransportchannel.cc +++ b/p2p/base/p2ptransportchannel.cc @@ -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()) {