Skip to content

Commit

Permalink
gw: fill in unlabeled TODO
Browse files Browse the repository at this point in the history
... and remove unused disconnect()
  • Loading branch information
mdavidsaver committed Aug 24, 2023
1 parent d6b8d3b commit 2930d9f
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 17 deletions.
2 changes: 0 additions & 2 deletions documentation/gw.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 0 additions & 10 deletions src/p4p/_gw.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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+
Expand Down Expand Up @@ -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
Expand Down
36 changes: 32 additions & 4 deletions src/pvxs_gw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string> &names) const {}
void GWSource::clearBan() {
Guard G(mutex);

banHost.clear();
banPV.clear();
banHostPV.clear();
}

void GWSource::cachePeek(std::set<std::string> &names) const {
Guard G(mutex);

for(const auto& pair : channels) {
names.insert(pair.first);
}
}

void GWSource::auditPush(AuditEvent&& revt)
{
Expand Down
1 change: 0 additions & 1 deletion src/pvxs_gw.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@ struct GWSource : public server::Source,
std::unique_ptr<server::ChannelControl> *op);

void sweep();
void disconnect(const std::string& usname);
void forceBan(const std::string& host, const std::string& usname);
void clearBan();

Expand Down

0 comments on commit 2930d9f

Please sign in to comment.