consolidate TransportClient and ChannelImpl as ClientChannelImpl

This commit is contained in:
Michael Davidsaver
2017-11-06 15:51:43 -06:00
parent 7118e34222
commit 576b241faa
11 changed files with 71 additions and 99 deletions
+1 -1
View File
@@ -68,7 +68,7 @@ SOCKET BlockingTCPConnector::tryConnect(osiSockAddr& address, int tries) {
return INVALID_SOCKET;
}
Transport::shared_pointer BlockingTCPConnector::connect(TransportClient::shared_pointer const & client,
Transport::shared_pointer BlockingTCPConnector::connect(std::tr1::shared_ptr<ClientChannelImpl> const & client,
ResponseHandler::shared_pointer const & responseHandler, osiSockAddr& address,
int8 transportRevision, int16 priority) {
+1 -1
View File
@@ -35,7 +35,7 @@ struct closer {
namespace epics {
namespace pvAccess {
Transport::shared_pointer BlockingUDPConnector::connect(TransportClient::shared_pointer const & /*client*/,
Transport::shared_pointer BlockingUDPConnector::connect(std::tr1::shared_ptr<ClientChannelImpl> const & /*client*/,
ResponseHandler::shared_pointer const & responseHandler, osiSockAddr& bindAddress,
int8 transportRevision, int16 /*priority*/) {
+1 -1
View File
@@ -558,7 +558,7 @@ void initializeUDPTransports(bool serverFlag,
const std::string& addressList,
const std::string& ignoreAddressList)
{
TransportClient::shared_pointer nullTransportClient;
std::tr1::shared_ptr<ClientChannelImpl> nullTransportClient;
epics::auto_ptr<BlockingUDPConnector> connector(new BlockingUDPConnector(serverFlag, true, true));
//
+11 -10
View File
@@ -40,6 +40,7 @@
#include <pv/codec.h>
#include <pv/serializationHelper.h>
#include <pv/serverChannelImpl.h>
#include <pv/clientContextImpl.h>
using namespace std;
using namespace epics::pvData;
@@ -1671,7 +1672,7 @@ BlockingClientTCPTransportCodec::BlockingClientTCPTransportCodec(
ResponseHandler::shared_pointer const & responseHandler,
int32_t sendBufferSize,
int32_t receiveBufferSize,
TransportClient::shared_pointer const & client,
ClientChannelImpl::shared_pointer const & client,
epics::pvData::int8 /*remoteTransportRevision*/,
float heartbeatInterval,
int16_t priority ) :
@@ -1740,7 +1741,7 @@ void BlockingClientTCPTransportCodec::unresponsiveTransport() {
TransportClientMap_t::iterator it = _owners.begin();
for(; it!=_owners.end(); it++) {
TransportClient::shared_pointer client = it->second.lock();
ClientChannelImpl::shared_pointer client = it->second.lock();
if (client)
{
EXCEPTION_GUARD(client->transportUnresponsive());
@@ -1749,7 +1750,7 @@ void BlockingClientTCPTransportCodec::unresponsiveTransport() {
}
}
bool BlockingClientTCPTransportCodec::acquire(TransportClient::shared_pointer const & client) {
bool BlockingClientTCPTransportCodec::acquire(ClientChannelImpl::shared_pointer const & client) {
Lock lock(_mutex);
if(isClosed()) return false;
@@ -1758,8 +1759,8 @@ bool BlockingClientTCPTransportCodec::acquire(TransportClient::shared_pointer co
LOG(logLevelDebug, "Acquiring transport to %s.", _socketName.c_str());
}
_owners[client->getID()] = TransportClient::weak_pointer(client);
//_owners.insert(TransportClient::weak_pointer(client));
_owners[client->getID()] = ClientChannelImpl::weak_pointer(client);
//_owners.insert(ClientChannelImpl::weak_pointer(client));
return true;
}
@@ -1798,7 +1799,7 @@ void BlockingClientTCPTransportCodec::closedNotifyClients() {
TransportClientMap_t::iterator it = _owners.begin();
for(; it!=_owners.end(); it++) {
TransportClient::shared_pointer client = it->second.lock();
ClientChannelImpl::shared_pointer client = it->second.lock();
if (client)
{
EXCEPTION_GUARD(client->transportClosed());
@@ -1810,7 +1811,7 @@ void BlockingClientTCPTransportCodec::closedNotifyClients() {
_owners.clear();
}
//void BlockingClientTCPTransportCodec::release(TransportClient::shared_pointer const & client) {
//void BlockingClientTCPTransportCodec::release(ClientChannelImpl::shared_pointer const & client) {
void BlockingClientTCPTransportCodec::release(pvAccessID clientID) {
Lock lock(_mutex);
if(isClosed()) return;
@@ -1821,7 +1822,7 @@ void BlockingClientTCPTransportCodec::release(pvAccessID clientID) {
}
_owners.erase(clientID);
//_owners.erase(TransportClient::weak_pointer(client));
//_owners.erase(ClientChannelImpl::weak_pointer(client));
// not used anymore, close it
// TODO consider delayed destruction (can improve performance!!!)
@@ -1845,7 +1846,7 @@ void BlockingClientTCPTransportCodec::responsiveTransport() {
Transport::shared_pointer thisSharedPtr = shared_from_this();
TransportClientMap_t::iterator it = _owners.begin();
for(; it!=_owners.end(); it++) {
TransportClient::shared_pointer client = it->second.lock();
ClientChannelImpl::shared_pointer client = it->second.lock();
if (client)
{
EXCEPTION_GUARD(client->transportResponsive(thisSharedPtr));
@@ -1860,7 +1861,7 @@ void BlockingClientTCPTransportCodec::changedTransport() {
Lock lock(_mutex);
TransportClientMap_t::iterator it = _owners.begin();
for(; it!=_owners.end(); it++) {
TransportClient::shared_pointer client = it->second.lock();
ClientChannelImpl::shared_pointer client = it->second.lock();
if (client)
{
EXCEPTION_GUARD(client->transportChanged());
+3 -1
View File
@@ -42,6 +42,8 @@
namespace epics {
namespace pvAccess {
class ClientChannelImpl;
/**
* Channel Access TCP connector.
* @author <a href="mailto:matej.sekoranjaATcosylab.com">Matej Sekoranja</a>
@@ -56,7 +58,7 @@ public:
virtual ~BlockingTCPConnector();
virtual Transport::shared_pointer connect(TransportClient::shared_pointer const & client,
virtual Transport::shared_pointer connect(std::tr1::shared_ptr<ClientChannelImpl> const & client,
ResponseHandler::shared_pointer const & responseHandler, osiSockAddr& address,
epics::pvData::int8 transportRevision, epics::pvData::int16 priority);
private:
+3 -2
View File
@@ -36,6 +36,7 @@
namespace epics {
namespace pvAccess {
class ClientChannelImpl;
class BlockingUDPConnector;
enum InetAddressType { inetAddressType_all, inetAddressType_unicast, inetAddressType_broadcast_multicast };
@@ -238,7 +239,7 @@ public:
return epics::pvData::getFieldCreate()->deserialize(buffer, this);
}
virtual bool acquire(std::tr1::shared_ptr<TransportClient> const & /*client*/)
virtual bool acquire(std::tr1::shared_ptr<ClientChannelImpl> const & /*client*/)
{
return false;
}
@@ -447,7 +448,7 @@ public:
/**
* NOTE: transport client is ignored for broadcast (UDP).
*/
virtual Transport::shared_pointer connect(TransportClient::shared_pointer const & client,
virtual Transport::shared_pointer connect(std::tr1::shared_ptr<ClientChannelImpl> const & client,
ResponseHandler::shared_pointer const & responseHandler, osiSockAddr& bindAddress,
epics::pvData::int8 transportRevision, epics::pvData::int16 priority);
+5 -5
View File
@@ -528,7 +528,7 @@ public:
public:
virtual bool acquire(std::tr1::shared_ptr<TransportClient> const & /*client*/) OVERRIDE FINAL
virtual bool acquire(std::tr1::shared_ptr<ClientChannelImpl> const & /*client*/) OVERRIDE FINAL
{
return false;
}
@@ -633,7 +633,7 @@ protected:
ResponseHandler::shared_pointer const & responseHandler,
int32_t sendBufferSize,
int32_t receiveBufferSize,
TransportClient::shared_pointer const & client,
std::tr1::shared_ptr<ClientChannelImpl> const & client,
epics::pvData::int8 remoteTransportRevision,
float heartbeatInterval,
int16_t priority);
@@ -645,7 +645,7 @@ public:
ResponseHandler::shared_pointer const & responseHandler,
int32_t sendBufferSize,
int32_t receiveBufferSize,
TransportClient::shared_pointer const & client,
std::tr1::shared_ptr<ClientChannelImpl> const & client,
int8_t remoteTransportRevision,
float heartbeatInterval,
int16_t priority )
@@ -673,7 +673,7 @@ public:
virtual void callback() OVERRIDE FINAL;
virtual bool acquire(TransportClient::shared_pointer const & client) OVERRIDE FINAL;
virtual bool acquire(std::tr1::shared_ptr<ClientChannelImpl> const & client) OVERRIDE FINAL;
virtual void release(pvAccessID clientId) OVERRIDE FINAL;
@@ -699,7 +699,7 @@ private:
* Owners (users) of the transport.
*/
// TODO consider using TR1 hash map
typedef std::map<pvAccessID, TransportClient::weak_pointer> TransportClientMap_t;
typedef std::map<pvAccessID, std::tr1::weak_ptr<ClientChannelImpl> > TransportClientMap_t;
TransportClientMap_t _owners;
/**
+6 -42
View File
@@ -41,6 +41,7 @@ namespace epics {
namespace pvAccess {
class TransportRegistry;
class ClientChannelImpl;
enum QoS {
/**
@@ -150,7 +151,7 @@ public:
virtual void send(epics::pvData::ByteBuffer* buffer, TransportSendControl* control) = 0;
};
class TransportClient;
class ClientChannelImpl;
class SecuritySession;
/**
@@ -167,15 +168,15 @@ public:
* @param client client (channel) acquiring the transport
* @return <code>true</code> if transport was granted, <code>false</code> otherwise.
*/
//virtual bool acquire(TransportClient::shared_pointer const & client) = 0;
virtual bool acquire(std::tr1::shared_ptr<TransportClient> const & client) = 0;
//virtual bool acquire(ClientChannelImpl::shared_pointer const & client) = 0;
virtual bool acquire(std::tr1::shared_ptr<ClientChannelImpl> const & client) = 0;
/**
* Releases transport.
* @param client client (channel) releasing the transport
*/
virtual void release(pvAccessID clientId) = 0;
//virtual void release(TransportClient::shared_pointer const & client) = 0;
//virtual void release(ClientChannelImpl::shared_pointer const & client) = 0;
/**
* Get protocol type (tcp, udp, ssl, etc.).
@@ -376,43 +377,6 @@ protected:
epics::pvData::int32 _debugLevel;
};
/**
* Client (user) of the transport.
*/
class TransportClient {
public:
POINTER_DEFINITIONS(TransportClient);
virtual ~TransportClient() {
}
// ID used to allow fast/efficient lookup
virtual pvAccessID getID() = 0;
/**
* Notification of unresponsive transport (e.g. no heartbeat detected) .
*/
virtual void transportUnresponsive() = 0;
/**
* Notification of responsive transport (e.g. heartbeat detected again),
* called to discard <code>transportUnresponsive</code> notification.
* @param transport responsive transport.
*/
virtual void transportResponsive(Transport::shared_pointer const & transport) = 0;
/**
* Notification of network change (server restarted).
*/
virtual void transportChanged() = 0;
/**
* Notification of forcefully closed transport.
*/
virtual void transportClosed() = 0;
};
/**
* Interface defining socket connector (Connector-Transport pattern).
*/
@@ -429,7 +393,7 @@ public:
* @param[in] priority process priority.
* @return transport instance.
*/
virtual Transport::shared_pointer connect(TransportClient::shared_pointer const & client,
virtual Transport::shared_pointer connect(std::tr1::shared_ptr<ClientChannelImpl> const & client,
ResponseHandler::shared_pointer const & responseHandler, osiSockAddr& address,
epics::pvData::int8 transportRevision, epics::pvData::int16 priority) = 0;