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:
Nicholas Dudfield
2026-02-10 07:52:02 +07:00
parent a8388e48a4
commit 3e0d6b9cd2
2 changed files with 14 additions and 5 deletions

View File

@@ -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;
}

View File

@@ -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();
}