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 <tommi@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#36728}
diff --git a/p2p/base/connection.cc b/p2p/base/connection.cc
index 04da6bd..ca5f78b 100644
--- a/p2p/base/connection.cc
+++ b/p2p/base/connection.cc
@@ -843,6 +843,12 @@
 
   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 @@
   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;
 }