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 {
|
std::string Connection::ToString() const {
|
||||||
RTC_DCHECK_RUN_ON(network_thread_);
|
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)
|
"-", // not connected (false)
|
||||||
"C", // connected (true)
|
"C", // connected (true)
|
||||||
};
|
};
|
||||||
const absl::string_view RECEIVE_STATE_ABBREV[2] = {
|
constexpr absl::string_view RECEIVE_STATE_ABBREV[2] = {
|
||||||
"-", // not receiving (false)
|
"-", // not receiving (false)
|
||||||
"R", // receiving (true)
|
"R", // receiving (true)
|
||||||
};
|
};
|
||||||
const absl::string_view WRITE_STATE_ABBREV[4] = {
|
constexpr absl::string_view WRITE_STATE_ABBREV[4] = {
|
||||||
"W", // STATE_WRITABLE
|
"W", // STATE_WRITABLE
|
||||||
"w", // STATE_WRITE_UNRELIABLE
|
"w", // STATE_WRITE_UNRELIABLE
|
||||||
"-", // STATE_WRITE_INIT
|
"-", // STATE_WRITE_INIT
|
||||||
"x", // STATE_WRITE_TIMEOUT
|
"x", // STATE_WRITE_TIMEOUT
|
||||||
};
|
};
|
||||||
const absl::string_view ICESTATE[4] = {
|
constexpr absl::string_view ICESTATE[4] = {
|
||||||
"W", // STATE_WAITING
|
"W", // STATE_WAITING
|
||||||
"I", // STATE_INPROGRESS
|
"I", // STATE_INPROGRESS
|
||||||
"S", // STATE_SUCCEEDED
|
"S", // STATE_SUCCEEDED
|
||||||
"F" // STATE_FAILED
|
"F" // STATE_FAILED
|
||||||
};
|
};
|
||||||
const absl::string_view SELECTED_STATE_ABBREV[2] = {
|
constexpr absl::string_view SELECTED_STATE_ABBREV[2] = {
|
||||||
"-", // candidate pair not selected (false)
|
"-", // candidate pair not selected (false)
|
||||||
"S", // selected (true)
|
"S", // selected (true)
|
||||||
};
|
};
|
||||||
const Candidate& local = local_candidate();
|
|
||||||
const Candidate& remote = remote_candidate();
|
|
||||||
rtc::StringBuilder ss;
|
rtc::StringBuilder ss;
|
||||||
ss << "Conn[" << ToDebugId() << ":" << port_->content_name() << ":"
|
ss << "Conn[" << ToDebugId();
|
||||||
<< port_->Network()->ToString() << ":" << local.id() << ":"
|
|
||||||
<< local.component() << ":" << local.generation() << ":" << local.type()
|
if (pending_delete_) {
|
||||||
<< ":" << local.protocol() << ":" << local.address().ToSensitiveString()
|
// No content name for pending delete, so temporarily substitute the name
|
||||||
<< "->" << remote.id() << ":" << remote.component() << ":"
|
// with a hash (rhyming with trash) and don't include any information about
|
||||||
<< remote.priority() << ":" << remote.type() << ":" << remote.protocol()
|
// the network or candidates, state that belongs to a potentially deleted
|
||||||
<< ":" << remote.address().ToSensitiveString() << "|"
|
// `port_`.
|
||||||
<< CONNECT_STATE_ABBREV[connected()] << RECEIVE_STATE_ABBREV[receiving()]
|
ss << ":#:";
|
||||||
<< WRITE_STATE_ABBREV[write_state()] << ICESTATE[static_cast<int>(state())]
|
} else {
|
||||||
<< "|" << SELECTED_STATE_ABBREV[selected_] << "|" << remote_nomination()
|
const Candidate& local = local_candidate();
|
||||||
<< "|" << nomination_ << "|" << priority() << "|";
|
const Candidate& remote = remote_candidate();
|
||||||
|
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) {
|
if (rtt_ < DEFAULT_RTT) {
|
||||||
ss << rtt_ << "]";
|
ss << rtt_ << "]";
|
||||||
} else {
|
} else {
|
||||||
ss << "-]";
|
ss << "-]";
|
||||||
}
|
}
|
||||||
|
|
||||||
return ss.Release();
|
return ss.Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user