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}
This commit is contained in:
parent
dfc11d55af
commit
3dadf8b06f
@ -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);
|
||||
|
||||
@ -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_;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user