diff --git a/src/ioc/PVAServerRegister.cpp b/src/ioc/PVAServerRegister.cpp index a7c386f..dba4b96 100644 --- a/src/ioc/PVAServerRegister.cpp +++ b/src/ioc/PVAServerRegister.cpp @@ -88,7 +88,7 @@ void stopPVAServer() } } -void statusPVAServer() +void pvasr(int lvl) { try { pvd::Lock G(the_server_lock); @@ -96,7 +96,7 @@ void statusPVAServer() std::cout<<"PVA server not running\n"; return; } else { - the_server->printInfo(); + the_server->printInfo(lvl); } }catch(std::exception& e){ std::cout<<"Error: "<("startPVAServer", "provider names"); - epics::iocshRegister<&statusPVAServer>("statusPVAServer"); epics::iocshRegister<&stopPVAServer>("stopPVAServer"); + epics::iocshRegister("pvasr", "detail"); initHookRegister(&initStartPVAServer); } diff --git a/src/remote/codec.cpp b/src/remote/codec.cpp index 14208dc..9d3afda 100644 --- a/src/remote/codec.cpp +++ b/src/remote/codec.cpp @@ -1464,10 +1464,10 @@ BlockingServerTCPTransportCodec::getChannel(pvAccessID sid) { } -int BlockingServerTCPTransportCodec::getChannelCount() { +size_t BlockingServerTCPTransportCodec::getChannelCount() const { Lock lock(_channelsMutex); - return static_cast(_channels.size()); + return _channels.size(); } diff --git a/src/remote/pv/codec.h b/src/remote/pv/codec.h index 42162d2..2cb0345 100644 --- a/src/remote/pv/codec.h +++ b/src/remote/pv/codec.h @@ -363,7 +363,7 @@ public: } virtual epics::pvData::int8 getRevision() const OVERRIDE FINAL { - return PVA_PROTOCOL_REVISION; + return std::min(PVA_PROTOCOL_REVISION, _remoteTransportRevision); } @@ -548,7 +548,7 @@ public: virtual ServerChannel::shared_pointer getChannel(pvAccessID sid) OVERRIDE FINAL; - virtual int getChannelCount() OVERRIDE FINAL; + virtual size_t getChannelCount() const OVERRIDE FINAL; virtual bool verify(epics::pvData::int32 timeoutMs) OVERRIDE FINAL { @@ -600,7 +600,7 @@ private: */ std::map _channels; - epics::pvData::Mutex _channelsMutex; + mutable epics::pvData::Mutex _channelsMutex; epics::pvData::Status _verificationStatus; epics::pvData::Mutex _verificationStatusMutex; diff --git a/src/remote/pv/remote.h b/src/remote/pv/remote.h index 8c94213..1e3c253 100644 --- a/src/remote/pv/remote.h +++ b/src/remote/pv/remote.h @@ -524,7 +524,7 @@ public: * Get channel count. * @return channel count. */ - virtual int getChannelCount() = 0; + virtual size_t getChannelCount() const = 0; }; /** diff --git a/src/server/pv/serverContext.h b/src/server/pv/serverContext.h index 6f7ea1d..38af2f4 100644 --- a/src/server/pv/serverContext.h +++ b/src/server/pv/serverContext.h @@ -61,13 +61,14 @@ public: /** * Prints detailed information about the context to the standard output stream. */ - void printInfo(); + void printInfo(int lvl =0); /** * Prints detailed information about the context to the specified output stream. + * @param lvl detail level * @param str stream to which to print the info */ - virtual void printInfo(std::ostream& str) = 0; + virtual void printInfo(std::ostream& str, int lvl=0) = 0; void dispose() EPICS_DEPRECATED; diff --git a/src/server/pv/serverContextImpl.h b/src/server/pv/serverContextImpl.h index c7addf9..168032f 100644 --- a/src/server/pv/serverContextImpl.h +++ b/src/server/pv/serverContextImpl.h @@ -43,7 +43,7 @@ public: void initialize(); void run(epics::pvData::uint32 seconds) OVERRIDE FINAL; void shutdown() OVERRIDE FINAL; - void printInfo(std::ostream& str) OVERRIDE FINAL; + void printInfo(std::ostream& str, int lvl) OVERRIDE FINAL; void setBeaconServerStatusProvider(BeaconServerStatusProvider::shared_pointer const & beaconServerStatusProvider) OVERRIDE FINAL; //**************** derived from Context ****************// epics::pvData::Timer::shared_pointer getTimer() OVERRIDE FINAL; diff --git a/src/server/serverContext.cpp b/src/server/serverContext.cpp index 73fcb0e..4606f4d 100644 --- a/src/server/serverContext.cpp +++ b/src/server/serverContext.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include using namespace std; @@ -404,30 +405,57 @@ void ServerContextImpl::destroyAllTransports() } } -void ServerContext::printInfo() +void ServerContext::printInfo(int lvl) { - printInfo(cout); + printInfo(cout, lvl); } -void ServerContextImpl::printInfo(ostream& str) +void ServerContextImpl::printInfo(ostream& str, int lvl) { - Lock guard(_mutex); - str << "VERSION : " << getVersion().getVersionString() << endl - << "PROVIDER_NAMES : "; - for(std::vector::const_iterator it = _channelProviders.begin(); - it != _channelProviders.end(); ++it) - { - str<<(*it)->getProviderName()<<", "; + if(lvl==0) { + Lock guard(_mutex); + str << "VERSION : " << getVersion().getVersionString() << endl + << "PROVIDER_NAMES : "; + for(std::vector::const_iterator it = _channelProviders.begin(); + it != _channelProviders.end(); ++it) + { + str<<(*it)->getProviderName()<<", "; + } + str << endl + << "BEACON_ADDR_LIST : " << _beaconAddressList << endl + << "AUTO_BEACON_ADDR_LIST : " << _autoBeaconAddressList << endl + << "BEACON_PERIOD : " << _beaconPeriod << endl + << "BROADCAST_PORT : " << _broadcastPort << endl + << "SERVER_PORT : " << _serverPort << endl + << "RCV_BUFFER_SIZE : " << _receiveBufferSize << endl + << "IGNORE_ADDR_LIST: " << _ignoreAddressList << endl + << "INTF_ADDR_LIST : " << inetAddressToString(_ifaceAddr, false) << endl; + + } else { + // lvl > 0 + + TransportRegistry::transportVector_t transports; + _transportRegistry.toArray(transports); + + str<<"Clients:\n"; + for(TransportRegistry::transportVector_t::const_iterator it(transports.begin()), end(transports.end()); + it!=end; ++it) + { + const Transport::shared_pointer& transport(*it); + + str<<"client "<getType()<<"://"<getRemoteName() + <<" ver="<getRevision()) + <<" "<<(transport->isClosed()?"closed!":""); + + const detail::BlockingServerTCPTransportCodec *casTransport = dynamic_cast(transport.get()); + + if(casTransport) { + str<<" "<<(casTransport ? casTransport->getChannelCount() : size_t(-1))<<" channels"; + } + + str<<"\n"; + } } - str << endl - << "BEACON_ADDR_LIST : " << _beaconAddressList << endl - << "AUTO_BEACON_ADDR_LIST : " << _autoBeaconAddressList << endl - << "BEACON_PERIOD : " << _beaconPeriod << endl - << "BROADCAST_PORT : " << _broadcastPort << endl - << "SERVER_PORT : " << _serverPort << endl - << "RCV_BUFFER_SIZE : " << _receiveBufferSize << endl - << "IGNORE_ADDR_LIST: " << _ignoreAddressList << endl - << "INTF_ADDR_LIST : " << inetAddressToString(_ifaceAddr, false) << endl; } void ServerContext::dispose()