From ca94696ae257395b452048535b3b86e95dbf47c4 Mon Sep 17 00:00:00 2001 From: Tommi Date: Mon, 2 May 2022 10:16:53 +0200 Subject: [PATCH] Clear port_ before firing destroyed event. This reverts a change introduced last week in [1] whereby the port_ pointer would be valid while firing the `Destroyed` event. [1] https://webrtc-review.googlesource.com/c/src/+/259826 Bug: webrtc:13892, webrtc:13865 Change-Id: I9c7be8fa9a5603fbdbf0debd91e2d4e21b303270 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/260860 Commit-Queue: Tomas Gunnarsson Reviewed-by: Harald Alvestrand Cr-Commit-Position: refs/heads/main@{#36728} --- p2p/base/connection.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/p2p/base/connection.cc b/p2p/base/connection.cc index 04da6bdc4b..ca5f78b23c 100644 --- a/p2p/base/connection.cc +++ b/p2p/base/connection.cc @@ -843,6 +843,12 @@ bool Connection::Shutdown() { RTC_DLOG(LS_VERBOSE) << ToString() << ": Connection destroyed"; + LogCandidatePairConfig(webrtc::IceCandidatePairConfigType::kDestroyed); + + // Reset the `port_` after logging since information required for logging + // needs access to `port_`. + port_.reset(); + // Fire the 'destroyed' event before deleting the object. This is done // intentionally to avoid a situation whereby the signal might have dangling // pointers to objects that have been deleted by the time the async task @@ -850,12 +856,6 @@ bool Connection::Shutdown() { SignalDestroyed(this); SignalDestroyed.disconnect_all(); - LogCandidatePairConfig(webrtc::IceCandidatePairConfigType::kDestroyed); - - // Reset the `port_` after logging and firing the destroyed signal since - // information required for logging needs access to `port_`. - port_.reset(); - return true; }