From f52609a5873c94cfef2c98478d7ce46d8533023e Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Sat, 30 Jan 2021 10:15:54 -0800 Subject: [PATCH] client: ignoreGUIDs() --- src/client.cpp | 17 +++++++++++++++++ src/clientimpl.h | 2 ++ src/pvxs/client.h | 5 +++++ 3 files changed, 24 insertions(+) diff --git a/src/client.cpp b/src/client.cpp index 4b6f672..a42c788 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -392,6 +392,16 @@ void Context::cacheClear(const std::string& name, cacheAction action) }); } +void Context::ignoreServerGUIDs(const std::vector& guids) +{ + if(!pvt) + throw std::logic_error("NULL Context"); + + pvt->impl->manager.loop().call([this, &guids](){ + pvt->impl->ignoreServerGUIDs = guids; + }); +} + Report Context::report() const { Report ret; @@ -671,6 +681,13 @@ void procSearchReply(ContextImpl& self, const SockAddr& src, Buffer& M, bool ist uint16_t nSearch = 0u; from_wire(M, nSearch); + if(M.good()) { + for(const ServerGUID& ignore : self.ignoreServerGUIDs) { + if(guid==ignore) + return; + } + } + for(auto n : range(nSearch)) { (void)n; diff --git a/src/clientimpl.h b/src/clientimpl.h index ede2bda..a9f3491 100644 --- a/src/clientimpl.h +++ b/src/clientimpl.h @@ -218,6 +218,8 @@ struct ContextImpl : public std::enable_shared_from_this evsocket searchTx; uint16_t searchRxPort; + std::vector ignoreServerGUIDs; + // poked and beaconSenders from both TCP and UDP workers epicsMutex pokeLock; epicsTimeStamp lastPoke{}; diff --git a/src/pvxs/client.h b/src/pvxs/client.h index 6d44a01..f29a254 100644 --- a/src/pvxs/client.h +++ b/src/pvxs/client.h @@ -20,6 +20,7 @@ #include #include #include +#include namespace pvxs { namespace client { @@ -496,6 +497,10 @@ public: */ void cacheClear(const std::string& name = std::string(), cacheAction action = Clean); + //! Ignore any search replies with these GUIDs + //! @since UNRELEASED + void ignoreServerGUIDs(const std::vector& guids); + //! Compile report about peers and channels //! @since UNRELEASED Report report() const;