Avoid touching port_ in Connection::ToString() after starting delete.
Bug: webrtc:13865 Change-Id: Ia469c46642d7e305a50e57d9ea6ad873e633db4e Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256808 Reviewed-by: Niels Moller <nisse@webrtc.org> Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org> Cr-Commit-Position: refs/heads/main@{#36338}
This commit is contained in:
@ -1198,49 +1198,65 @@ uint32_t Connection::ComputeNetworkCost() const {
|
||||
|
||||
std::string Connection::ToString() const {
|
||||
RTC_DCHECK_RUN_ON(network_thread_);
|
||||
const absl::string_view CONNECT_STATE_ABBREV[2] = {
|
||||
constexpr absl::string_view CONNECT_STATE_ABBREV[2] = {
|
||||
"-", // not connected (false)
|
||||
"C", // connected (true)
|
||||
};
|
||||
const absl::string_view RECEIVE_STATE_ABBREV[2] = {
|
||||
constexpr absl::string_view RECEIVE_STATE_ABBREV[2] = {
|
||||
"-", // not receiving (false)
|
||||
"R", // receiving (true)
|
||||
};
|
||||
const absl::string_view WRITE_STATE_ABBREV[4] = {
|
||||
constexpr absl::string_view WRITE_STATE_ABBREV[4] = {
|
||||
"W", // STATE_WRITABLE
|
||||
"w", // STATE_WRITE_UNRELIABLE
|
||||
"-", // STATE_WRITE_INIT
|
||||
"x", // STATE_WRITE_TIMEOUT
|
||||
};
|
||||
const absl::string_view ICESTATE[4] = {
|
||||
constexpr absl::string_view ICESTATE[4] = {
|
||||
"W", // STATE_WAITING
|
||||
"I", // STATE_INPROGRESS
|
||||
"S", // STATE_SUCCEEDED
|
||||
"F" // STATE_FAILED
|
||||
};
|
||||
const absl::string_view SELECTED_STATE_ABBREV[2] = {
|
||||
constexpr absl::string_view SELECTED_STATE_ABBREV[2] = {
|
||||
"-", // candidate pair not selected (false)
|
||||
"S", // selected (true)
|
||||
};
|
||||
rtc::StringBuilder ss;
|
||||
ss << "Conn[" << ToDebugId();
|
||||
|
||||
if (pending_delete_) {
|
||||
// No content name for pending delete, so temporarily substitute the name
|
||||
// with a hash (rhyming with trash) and don't include any information about
|
||||
// the network or candidates, state that belongs to a potentially deleted
|
||||
// `port_`.
|
||||
ss << ":#:";
|
||||
} else {
|
||||
const Candidate& local = local_candidate();
|
||||
const Candidate& remote = remote_candidate();
|
||||
rtc::StringBuilder ss;
|
||||
ss << "Conn[" << ToDebugId() << ":" << port_->content_name() << ":"
|
||||
<< port_->Network()->ToString() << ":" << local.id() << ":"
|
||||
<< local.component() << ":" << local.generation() << ":" << local.type()
|
||||
<< ":" << local.protocol() << ":" << local.address().ToSensitiveString()
|
||||
<< "->" << remote.id() << ":" << remote.component() << ":"
|
||||
<< remote.priority() << ":" << remote.type() << ":" << remote.protocol()
|
||||
<< ":" << remote.address().ToSensitiveString() << "|"
|
||||
<< CONNECT_STATE_ABBREV[connected()] << RECEIVE_STATE_ABBREV[receiving()]
|
||||
<< WRITE_STATE_ABBREV[write_state()] << ICESTATE[static_cast<int>(state())]
|
||||
<< "|" << SELECTED_STATE_ABBREV[selected_] << "|" << remote_nomination()
|
||||
<< "|" << nomination_ << "|" << priority() << "|";
|
||||
ss << ":" << port_->content_name() << ":" << port_->Network()->ToString()
|
||||
<< ":" << local.id() << ":" << local.component() << ":"
|
||||
<< local.generation() << ":" << local.type() << ":" << local.protocol()
|
||||
<< ":" << local.address().ToSensitiveString() << "->" << remote.id()
|
||||
<< ":" << remote.component() << ":" << remote.priority() << ":"
|
||||
<< remote.type() << ":" << remote.protocol() << ":"
|
||||
<< remote.address().ToSensitiveString() << "|";
|
||||
}
|
||||
|
||||
ss << CONNECT_STATE_ABBREV[connected_] << RECEIVE_STATE_ABBREV[receiving_]
|
||||
<< WRITE_STATE_ABBREV[write_state_] << ICESTATE[static_cast<int>(state_)]
|
||||
<< "|" << SELECTED_STATE_ABBREV[selected_] << "|" << remote_nomination_
|
||||
<< "|" << nomination_ << "|";
|
||||
|
||||
if (!pending_delete_)
|
||||
ss << priority() << "|";
|
||||
|
||||
if (rtt_ < DEFAULT_RTT) {
|
||||
ss << rtt_ << "]";
|
||||
} else {
|
||||
ss << "-]";
|
||||
}
|
||||
|
||||
return ss.Release();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user