Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[link prober] print out error code message when sendHeartbeat fails #266

Merged
merged 4 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/link_prober/LinkProber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ void LinkProber::sendHeartbeat(bool forceSend)
mStream.write_some(boost::asio::buffer(mTxBuffer.data(), mTxPacketSize), errorCode);

if (errorCode) {
MUXLOGTRACE(mMuxPortConfig.getPortName() + ": Failed to send heartbeat!");
MUXLOGTRACE(mMuxPortConfig.getPortName() + ": Failed to send heartbeat! Error code: " + errorCode.message());
zjswhhh marked this conversation as resolved.
Show resolved Hide resolved
} else {
MUXLOGTRACE(mMuxPortConfig.getPortName() + ": Done sending data");
}
Expand Down
5 changes: 3 additions & 2 deletions src/link_prober/LinkProber.h
Original file line number Diff line number Diff line change
Expand Up @@ -623,8 +623,6 @@ class LinkProber
std::shared_ptr<SockFilter> mSockFilterPtr;
SockFilterProg mSockFilterProg;

int mSocket = 0;

std::size_t mTxPacketSize;
std::array<uint8_t, MUX_MAX_ICMP_BUFFER_SIZE> mTxBuffer;
std::array<uint8_t, MUX_MAX_ICMP_BUFFER_SIZE> mRxBuffer;
Expand All @@ -635,6 +633,9 @@ class LinkProber

uint64_t mIcmpUnknownEventCount = 0;
uint64_t mIcmpPacketCount = 0;

public:
int mSocket = 0;
};

} /* namespace link_prober */
Expand Down
7 changes: 7 additions & 0 deletions test/LinkProberTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,4 +337,11 @@ TEST_F(LinkProberTest, InitializeException)
EXPECT_THROW(initialize(), common::SocketErrorException);
}

TEST_F(LinkProberTest, sendHeartbeatFails)
{
mLinkProber.mSocket = -1;
initialize();

handleSendHeartbeat();
}
} /* namespace test */
Loading