mirror of
https://github.com/Xahau/xahaud.git
synced 2026-08-21 23:40:52 +00:00
fix: increment mSeq on queue drop and fix flaky connection-refused test
- Advance mSeq when dropping events so consumers can detect gaps via sequence numbers, and log the dropped seq - Use ephemeral port (bind + close) instead of hardcoded 19999 for the connection-refused test to avoid false negatives on busy machines
This commit is contained in:
@@ -80,8 +80,10 @@ public:
|
||||
|
||||
if (mDeque.size() >= maxQueueSize)
|
||||
{
|
||||
JLOG(j_.warn()) << "RPCCall::fromNetwork drop: queue full ("
|
||||
<< mDeque.size() << "), endpoint=" << mIp;
|
||||
JLOG(j_.warn())
|
||||
<< "RPCCall::fromNetwork drop: queue full (" << mDeque.size()
|
||||
<< "), seq=" << mSeq << ", endpoint=" << mIp;
|
||||
++mSeq;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -321,14 +321,21 @@ class HTTPClient_test : public beast::unit_test::suite
|
||||
using namespace jtx;
|
||||
Env env{*this};
|
||||
|
||||
// No server listening — connection refused.
|
||||
// Use a port that's very unlikely to be in use.
|
||||
// Bind a port, then close it — guarantees nothing is listening.
|
||||
boost::asio::io_service tmp;
|
||||
boost::asio::ip::tcp::acceptor acc(
|
||||
tmp,
|
||||
boost::asio::ip::tcp::endpoint(
|
||||
boost::asio::ip::address::from_string("127.0.0.1"), 0));
|
||||
auto port = acc.local_endpoint().port();
|
||||
acc.close();
|
||||
|
||||
std::atomic<int> completed{0};
|
||||
auto j = env.app().journal("HTTPClient");
|
||||
|
||||
{
|
||||
boost::asio::io_service ios;
|
||||
fireRequest(ios, "127.0.0.1", 19999, completed, j);
|
||||
fireRequest(ios, "127.0.0.1", port, completed, j);
|
||||
ios.run();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user