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}
This commit is contained in:
Tommi 2022-05-02 10:16:53 +02:00 committed by WebRTC LUCI CQ
parent a4e9480279
commit ca94696ae2

View File

@ -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;
}