libutil: remove Pool::flushBad

this was never actually used, and bad design in the first place—why
should a bad resource be put back into the idle pool? just drop it.

Change-Id: Idab8774bee19dadae0209d404c4fb86dd4aeba1e
This commit is contained in:
eldritch horrors 2024-03-21 21:33:14 +01:00
parent 620de98d0c
commit 862f20a4ba
4 changed files with 0 additions and 32 deletions

View file

@ -940,11 +940,6 @@ std::optional<TrustedFlag> RemoteStore::isTrustedClient()
return conn->remoteTrustsUs; return conn->remoteTrustsUs;
} }
void RemoteStore::flushBadConnections()
{
connections->flushBad();
}
RemoteStore::Connection::~Connection() RemoteStore::Connection::~Connection()
{ {

View file

@ -161,8 +161,6 @@ public:
std::optional<TrustedFlag> isTrustedClient() override; std::optional<TrustedFlag> isTrustedClient() override;
void flushBadConnections();
struct Connection; struct Connection;
ref<Connection> openConnectionWrapper(); ref<Connection> openConnectionWrapper();

View file

@ -184,16 +184,6 @@ public:
{ {
return state.lock()->max; return state.lock()->max;
} }
void flushBad()
{
auto state_(state.lock());
std::vector<ref<R>> left;
for (auto & p : state_->idle)
if (validator(p))
left.push_back(p);
std::swap(state_->idle, left);
}
}; };
} }

View file

@ -65,21 +65,6 @@ namespace nix {
ASSERT_EQ(pool.capacity(), 0); ASSERT_EQ(pool.capacity(), 0);
} }
TEST(Pool, flushBadDropsOutOfScopeResources) {
auto isGood = [](const ref<TestResource> & r) { return false; };
auto createResource = []() { return make_ref<TestResource>(); };
Pool<TestResource> pool = Pool<TestResource>((size_t)1, createResource, isGood);
{
auto _r = pool.get();
ASSERT_EQ(pool.count(), 1);
}
pool.flushBad();
ASSERT_EQ(pool.count(), 0);
}
// Test that the resources we allocate are being reused when they are still good. // Test that the resources we allocate are being reused when they are still good.
TEST(Pool, reuseResource) { TEST(Pool, reuseResource) {
auto isGood = [](const ref<TestResource> & r) { return true; }; auto isGood = [](const ref<TestResource> & r) { return true; };