diff --git a/documentation/gw.rst b/documentation/gw.rst index 0030c8ec..8f6a75c0 100644 --- a/documentation/gw.rst +++ b/documentation/gw.rst @@ -666,8 +666,6 @@ possibly with port number (eg. "1.2.3.4:5076)", and never host names. .. automethod:: testChannel - .. automethod:: disconnect - .. automethod:: sweep .. automethod:: forceBan diff --git a/src/p4p/_gw.pyx b/src/p4p/_gw.pyx index 90d1ce33..cbaa3040 100644 --- a/src/p4p/_gw.pyx +++ b/src/p4p/_gw.pyx @@ -53,7 +53,6 @@ cdef extern from "pvxs_gw.h" namespace "p4p" nogil: shared_ptr[GWChan] connect(const string &dsname, const string &usname, unique_ptr[ChannelControl]* op) except+ void sweep() except+ - void disconnect(const string& usname) except+ void forceBan(const string& host, const string& usname) except+ void clearBan() except+ void cachePeek(setxx[string]& names) except+ @@ -208,15 +207,6 @@ cdef class Provider(_p4p.Source): with nogil: self.provider.get().sweep() - def disconnect(self, bytes usname): - """Force disconnection of all channels connected to the named PV - - :param bytes usname: Upstream (Server side) PV name - """ - cdef string n = usname - with nogil: - self.provider.get().disconnect(n) - def forceBan(self, bytes host = None, bytes usname = None): """Preemptively Add an entry to the negative result cache. Either host or usname must be not None diff --git a/src/pvxs_gw.cpp b/src/pvxs_gw.cpp index ff739ef1..2c3a943a 100644 --- a/src/pvxs_gw.cpp +++ b/src/pvxs_gw.cpp @@ -912,11 +912,39 @@ void GWSource::sweep() upstream.cacheClear(tr->usname); } -void GWSource::disconnect(const std::string& usname) {} -void GWSource::forceBan(const std::string& host, const std::string& usname) {} -void GWSource::clearBan() {} +void GWSource::forceBan(const std::string& host, const std::string& usname) { + bool nohost = host.empty(); + bool noname = usname.empty(); + if(nohost && noname) { + throw std::logic_error("forceBan requires a host name/or usname"); + } + + Guard G(mutex); + + if(nohost) { + banPV.insert(usname); + } else if(noname) { + banHost.insert(host); + } else { + banHostPV.emplace(host, usname); + } +} -void GWSource::cachePeek(std::set &names) const {} +void GWSource::clearBan() { + Guard G(mutex); + + banHost.clear(); + banPV.clear(); + banHostPV.clear(); +} + +void GWSource::cachePeek(std::set &names) const { + Guard G(mutex); + + for(const auto& pair : channels) { + names.insert(pair.first); + } +} void GWSource::auditPush(AuditEvent&& revt) { diff --git a/src/pvxs_gw.h b/src/pvxs_gw.h index b6df2ad8..5e009d57 100644 --- a/src/pvxs_gw.h +++ b/src/pvxs_gw.h @@ -182,7 +182,6 @@ struct GWSource : public server::Source, std::unique_ptr *op); void sweep(); - void disconnect(const std::string& usname); void forceBan(const std::string& host, const std::string& usname); void clearBan();