From 8d5c27143bcb65d3ed652c0d73b00e3bb7e98ae2 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Sun, 5 Nov 2017 17:11:28 -0600 Subject: [PATCH] pvasr list client channels --- src/remote/codec.cpp | 9 +++++++++ src/remote/pv/codec.h | 5 ++++- src/server/pv/serverChannelImpl.h | 2 +- src/server/serverChannelImpl.cpp | 5 ----- src/server/serverContext.cpp | 19 +++++++++++++++++++ 5 files changed, 33 insertions(+), 7 deletions(-) diff --git a/src/remote/codec.cpp b/src/remote/codec.cpp index 90c2d83..413201c 100644 --- a/src/remote/codec.cpp +++ b/src/remote/codec.cpp @@ -1470,6 +1470,15 @@ size_t BlockingServerTCPTransportCodec::getChannelCount() const { return _channels.size(); } +void BlockingServerTCPTransportCodec::getChannels(std::vector& channels) const +{ + Lock lock(_channelsMutex); + for(_channels_t::const_iterator it(_channels.begin()), end(_channels.end()); + it!=end; ++it) + { + channels.push_back(it->second); + } +} void BlockingServerTCPTransportCodec::send(ByteBuffer* buffer, TransportSendControl* control) { diff --git a/src/remote/pv/codec.h b/src/remote/pv/codec.h index 37fab15..78dcff4 100644 --- a/src/remote/pv/codec.h +++ b/src/remote/pv/codec.h @@ -548,6 +548,8 @@ public: virtual ServerChannel::shared_pointer getChannel(pvAccessID sid) OVERRIDE FINAL; + void getChannels(std::vector& channels) const; + virtual size_t getChannelCount() const OVERRIDE FINAL; virtual bool verify(epics::pvData::int32 timeoutMs) OVERRIDE FINAL { @@ -596,10 +598,11 @@ private: */ pvAccessID _lastChannelSID; + typedef std::map _channels_t; /** * Channel table (SID -> channel mapping). */ - std::map _channels; + _channels_t _channels; mutable epics::pvData::Mutex _channelsMutex; diff --git a/src/server/pv/serverChannelImpl.h b/src/server/pv/serverChannelImpl.h index e219699..836b63c 100644 --- a/src/server/pv/serverChannelImpl.h +++ b/src/server/pv/serverChannelImpl.h @@ -42,7 +42,7 @@ public: * Get local channel. * @return local channel. */ - Channel::shared_pointer getChannel(); + const Channel::shared_pointer& getChannel() const { return _channel; } /** * Get channel CID. diff --git a/src/server/serverChannelImpl.cpp b/src/server/serverChannelImpl.cpp index 932b3a7..fe7ded1 100644 --- a/src/server/serverChannelImpl.cpp +++ b/src/server/serverChannelImpl.cpp @@ -34,11 +34,6 @@ ServerChannelImpl::ServerChannelImpl(Channel::shared_pointer const & channel, } } -Channel::shared_pointer ServerChannelImpl::getChannel() -{ - return _channel; -} - pvAccessID ServerChannelImpl::getCID() const { return _cid; diff --git a/src/server/serverContext.cpp b/src/server/serverContext.cpp index 4606f4d..e45935d 100644 --- a/src/server/serverContext.cpp +++ b/src/server/serverContext.cpp @@ -454,6 +454,25 @@ void ServerContextImpl::printInfo(ostream& str, int lvl) } str<<"\n"; + + if(!casTransport || lvl<2) + return; + + typedef std::vector channels_t; + channels_t channels; + casTransport->getChannels(channels); + + for(channels_t::const_iterator it(channels.begin()), end(channels.end()); it!=end; ++it) + { + const ServerChannelImpl *channel(static_cast(it->get())); + const Channel::shared_pointer& providerChan(channel->getChannel()); + if(!providerChan) + continue; + + str<<" "<getChannelName() + <<(providerChan->isConnected()?"":" closed") + <<"\n"; + } } } }