pvasr list client channels

This commit is contained in:
Michael Davidsaver
2017-11-05 17:11:28 -06:00
parent 49173ec884
commit 8d5c27143b
5 changed files with 33 additions and 7 deletions

View File

@@ -1470,6 +1470,15 @@ size_t BlockingServerTCPTransportCodec::getChannelCount() const {
return _channels.size();
}
void BlockingServerTCPTransportCodec::getChannels(std::vector<ServerChannel::shared_pointer>& 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) {

View File

@@ -548,6 +548,8 @@ public:
virtual ServerChannel::shared_pointer getChannel(pvAccessID sid) OVERRIDE FINAL;
void getChannels(std::vector<ServerChannel::shared_pointer>& 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<pvAccessID, ServerChannel::shared_pointer> _channels_t;
/**
* Channel table (SID -> channel mapping).
*/
std::map<pvAccessID, ServerChannel::shared_pointer> _channels;
_channels_t _channels;
mutable epics::pvData::Mutex _channelsMutex;

View File

@@ -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.

View File

@@ -34,11 +34,6 @@ ServerChannelImpl::ServerChannelImpl(Channel::shared_pointer const & channel,
}
}
Channel::shared_pointer ServerChannelImpl::getChannel()
{
return _channel;
}
pvAccessID ServerChannelImpl::getCID() const
{
return _cid;

View File

@@ -454,6 +454,25 @@ void ServerContextImpl::printInfo(ostream& str, int lvl)
}
str<<"\n";
if(!casTransport || lvl<2)
return;
typedef std::vector<ServerChannel::shared_pointer> 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<const ServerChannelImpl*>(it->get()));
const Channel::shared_pointer& providerChan(channel->getChannel());
if(!providerChan)
continue;
str<<" "<<providerChan->getChannelName()
<<(providerChan->isConnected()?"":" closed")
<<"\n";
}
}
}
}