From a63627fcfd4f66ac5d1705b0fd5d96850b9846da Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Tue, 15 Sep 2026 16:20:02 -0700 Subject: [PATCH] client: clean chanByCID --- src/client.cpp | 7 +++++++ test/testput.cpp | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/client.cpp b/src/client.cpp index d525538..9480977 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -1367,6 +1367,8 @@ void ContextImpl::cacheClean(const std::string& name, Context::cacheAction actio // explicitly break ref. loop of channel cache chanByName.erase(cur); + if(chanByCID.erase(trash->cid)!=1) + log_crit_printf(io, "Inconsistent chanByName vs. chanByCID for %s\n", trash->name.c_str()); if(action==Context::Disconnect) { trash->disconnect(trash); @@ -1374,6 +1376,11 @@ void ContextImpl::cacheClean(const std::string& name, Context::cacheAction actio } } } + + if(chanByName.size() != chanByCID.size()) { + log_crit_printf(io, "Inconsistent sizes chanByName %zu vs. chanByCID %zu", + chanByName.size(), chanByCID.size()); + } } void ContextImpl::cacheCleanS(evutil_socket_t fd, short evt, void *raw) diff --git a/test/testput.cpp b/test/testput.cpp index c13c4e9..1c9d8d2 100644 --- a/test/testput.cpp +++ b/test/testput.cpp @@ -90,7 +90,7 @@ struct Tester : public TesterBase } op.reset(); - cli.cacheClear(); + cli.cacheClear("", client::Context::Disconnect); } void loopback(bool get)