diff options
author | Victor Boivie <boivie@webrtc.org> | 2021-05-07 10:55:32 +0200 |
---|---|---|
committer | WebRTC LUCI CQ <webrtc-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2021-05-07 11:36:57 +0000 |
commit | 3dadf8b06f141645afe4df98ab8b50e7ccc4f4f4 (patch) | |
tree | d426ef8cf3eae7e82dd515e736f973950c0bc862 /net | |
parent | dfc11d55af84851c58a1c03423a634e3bc9ba08f (diff) | |
download | webrtc-3dadf8b06f141645afe4df98ab8b50e7ccc4f4f4.tar.gz |
dcsctp: Log socket name also in callbacks
This makes it easier to understand which socket that experience an error
or abort. Aborts are now also logged, which was missed previously.
Bug: webrtc:12614
Change-Id: Ie5e4357b3e5450106cc6cc28c1e9578ad53d073a
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/217764
Commit-Queue: Victor Boivie <boivie@webrtc.org>
Reviewed-by: Florent Castelli <orphis@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33947}
Diffstat (limited to 'net')
-rw-r--r-- | net/dcsctp/socket/dcsctp_socket_test.cc | 6 | ||||
-rw-r--r-- | net/dcsctp/socket/mock_dcsctp_socket_callbacks.h | 18 |
2 files changed, 18 insertions, 6 deletions
diff --git a/net/dcsctp/socket/dcsctp_socket_test.cc b/net/dcsctp/socket/dcsctp_socket_test.cc index e08bdbaf70..2b2e9880f1 100644 --- a/net/dcsctp/socket/dcsctp_socket_test.cc +++ b/net/dcsctp/socket/dcsctp_socket_test.cc @@ -180,6 +180,8 @@ class DcSctpSocketTest : public testing::Test { protected: explicit DcSctpSocketTest(bool enable_message_interleaving = false) : options_(MakeOptionsForTest(enable_message_interleaving)), + cb_a_("A"), + cb_z_("Z"), sock_a_("A", cb_a_, nullptr, options_), sock_z_("Z", cb_z_, nullptr, options_) {} @@ -765,7 +767,7 @@ TEST_F(DcSctpSocketTest, OnePeerReconnects) { sock_z_.ReceivePacket(cb_a_.ConsumeSentPacket()); // Create a new association, z2 - and don't use z anymore. - testing::NiceMock<MockDcSctpSocketCallbacks> cb_z2; + testing::NiceMock<MockDcSctpSocketCallbacks> cb_z2("Z2"); DcSctpSocket sock_z2("Z2", cb_z2, nullptr, options_); sock_z2.Connect(); @@ -888,7 +890,7 @@ TEST_F(DcSctpSocketTest, ReceivingErrorChunkReportsAsCallback) { TEST_F(DcSctpSocketTest, PassingHighWatermarkWillOnlyAcceptCumAckTsn) { // Create a new association, z2 - and don't use z anymore. - testing::NiceMock<MockDcSctpSocketCallbacks> cb_z2; + testing::NiceMock<MockDcSctpSocketCallbacks> cb_z2("Z2"); DcSctpOptions options = options_; options.max_receiver_window_buffer_size = 100; DcSctpSocket sock_z2("Z2", cb_z2, nullptr, options); diff --git a/net/dcsctp/socket/mock_dcsctp_socket_callbacks.h b/net/dcsctp/socket/mock_dcsctp_socket_callbacks.h index 289da7a4d1..9d0bd53372 100644 --- a/net/dcsctp/socket/mock_dcsctp_socket_callbacks.h +++ b/net/dcsctp/socket/mock_dcsctp_socket_callbacks.h @@ -13,6 +13,7 @@ #include <cstdint> #include <deque> #include <memory> +#include <string> #include <utility> #include <vector> @@ -51,8 +52,9 @@ inline int GetUniqueSeed() { class MockDcSctpSocketCallbacks : public DcSctpSocketCallbacks { public: - MockDcSctpSocketCallbacks() - : random_(internal::GetUniqueSeed()), + explicit MockDcSctpSocketCallbacks(absl::string_view name = "") + : log_prefix_(name.empty() ? "" : std::string(name) + ": "), + random_(internal::GetUniqueSeed()), timeout_manager_([this]() { return now_; }) { ON_CALL(*this, SendPacket) .WillByDefault([this](rtc::ArrayView<const uint8_t> data) { @@ -65,9 +67,16 @@ class MockDcSctpSocketCallbacks : public DcSctpSocketCallbacks { }); ON_CALL(*this, OnError) - .WillByDefault([](ErrorKind error, absl::string_view message) { + .WillByDefault([this](ErrorKind error, absl::string_view message) { RTC_LOG(LS_WARNING) - << "Socket error: " << ToString(error) << "; " << message; + << log_prefix_ << "Socket error: " << ToString(error) << "; " + << message; + }); + ON_CALL(*this, OnAborted) + .WillByDefault([this](ErrorKind error, absl::string_view message) { + RTC_LOG(LS_WARNING) + << log_prefix_ << "Socket abort: " << ToString(error) << "; " + << message; }); } MOCK_METHOD(void, @@ -139,6 +148,7 @@ class MockDcSctpSocketCallbacks : public DcSctpSocketCallbacks { } private: + const std::string log_prefix_; TimeMs now_ = TimeMs(0); webrtc::Random random_; FakeTimeoutManager timeout_manager_; |