ServerChannel::_requests holds BaseChannelRequester

Make it a bit more obvious that things are backwards here.
This commit is contained in:
Michael Davidsaver
2018-06-29 12:52:43 -07:00
parent 3341d9a2ba
commit 3ffbf9c597
4 changed files with 29 additions and 31 deletions
+1
View File
@@ -20,6 +20,7 @@ class ServerChannel;
class BaseChannelRequester : virtual public epics::pvData::Requester, public Destroyable
{
public:
POINTER_DEFINITIONS(BaseChannelRequester);
BaseChannelRequester(ServerContextImpl::shared_pointer const & context, std::tr1::shared_ptr<ServerChannel> const & channel,
const pvAccessID ioid, Transport::shared_pointer const & transport);
virtual ~BaseChannelRequester() {};
+6 -3
View File
@@ -10,10 +10,13 @@
#include <pv/destroyable.h>
#include <pv/remote.h>
#include <pv/security.h>
#include <pv/baseChannelRequester.h>
namespace epics {
namespace pvAccess {
class BaseChannelRequester;
class ServerChannel
{
public:
@@ -43,7 +46,7 @@ public:
ChannelSecuritySession::shared_pointer getChannelSecuritySession() const
{ return _channelSecuritySession; }
void registerRequest(pvAccessID id, Destroyable::shared_pointer const & request);
void registerRequest(pvAccessID id, const std::tr1::shared_ptr<BaseChannelRequester>& request);
void unregisterRequest(pvAccessID id);
@@ -51,7 +54,7 @@ public:
void completeGetField(GetFieldRequester *req);
//! may return NULL
Destroyable::shared_pointer getRequest(pvAccessID id);
std::tr1::shared_ptr<BaseChannelRequester> getRequest(pvAccessID id);
void destroy();
@@ -68,7 +71,7 @@ private:
//! keep alive in-progress GetField()
GetFieldRequester::shared_pointer _active_requester;
typedef std::map<pvAccessID, Destroyable::shared_pointer> _requests_t;
typedef std::map<pvAccessID, std::tr1::shared_ptr<BaseChannelRequester> > _requests_t;
_requests_t _requests;
bool _destroyed;
+19 -25
View File
@@ -1125,9 +1125,8 @@ ChannelGetRequester::shared_pointer ServerChannelGetRequesterImpl::create(Server
void ServerChannelGetRequesterImpl::activate(PVStructure::shared_pointer const & pvRequest)
{
startRequest(QOS_INIT);
ChannelGetRequester::shared_pointer thisPointer = shared_from_this();
Destroyable::shared_pointer thisDestroyable = shared_from_this();
_channel->registerRequest(_ioid, thisDestroyable);
shared_pointer thisPointer(shared_from_this());
_channel->registerRequest(_ioid, thisPointer);
INIT_EXCEPTION_GUARD(CMD_GET, _channelGet, _channel->getChannel()->createChannelGet(thisPointer, pvRequest));
}
@@ -1385,9 +1384,8 @@ ChannelPutRequester::shared_pointer ServerChannelPutRequesterImpl::create(Server
void ServerChannelPutRequesterImpl::activate(PVStructure::shared_pointer const & pvRequest)
{
startRequest(QOS_INIT);
ChannelPutRequester::shared_pointer thisPointer = shared_from_this();
Destroyable::shared_pointer thisDestroyable = shared_from_this();
_channel->registerRequest(_ioid, thisDestroyable);
shared_pointer thisPointer(shared_from_this());
_channel->registerRequest(_ioid, thisPointer);
INIT_EXCEPTION_GUARD(CMD_PUT, _channelPut, _channel->getChannel()->createChannelPut(thisPointer, pvRequest));
}
@@ -1668,9 +1666,8 @@ ChannelPutGetRequester::shared_pointer ServerChannelPutGetRequesterImpl::create(
void ServerChannelPutGetRequesterImpl::activate(PVStructure::shared_pointer const & pvRequest)
{
startRequest(QOS_INIT);
ChannelPutGetRequester::shared_pointer thisPointer = shared_from_this();
Destroyable::shared_pointer thisDestroyable = shared_from_this();
_channel->registerRequest(_ioid, thisDestroyable);
shared_pointer thisPointer(shared_from_this());
_channel->registerRequest(_ioid, thisPointer);
INIT_EXCEPTION_GUARD(CMD_PUT_GET, _channelPutGet, _channel->getChannel()->createChannelPutGet(thisPointer, pvRequest));
}
@@ -1994,9 +1991,8 @@ void ServerMonitorRequesterImpl::activate(PVStructure::shared_pointer const & pv
}
}
startRequest(QOS_INIT);
MonitorRequester::shared_pointer thisPointer = shared_from_this();
Destroyable::shared_pointer thisDestroyable = shared_from_this();
_channel->registerRequest(_ioid, thisDestroyable);
shared_pointer thisPointer(shared_from_this());
_channel->registerRequest(_ioid, thisPointer);
INIT_EXCEPTION_GUARD(CMD_MONITOR, _channelMonitor, _channel->getChannel()->createMonitor(thisPointer, pvRequest));
}
@@ -2385,9 +2381,8 @@ ChannelArrayRequester::shared_pointer ServerChannelArrayRequesterImpl::create(
void ServerChannelArrayRequesterImpl::activate(PVStructure::shared_pointer const & pvRequest)
{
startRequest(QOS_INIT);
ChannelArrayRequester::shared_pointer thisPointer = shared_from_this();
Destroyable::shared_pointer thisDestroyable = shared_from_this();
_channel->registerRequest(_ioid, thisDestroyable);
shared_pointer thisPointer(shared_from_this());
_channel->registerRequest(_ioid, thisPointer);
INIT_EXCEPTION_GUARD(CMD_ARRAY, _channelArray, _channel->getChannel()->createChannelArray(thisPointer, pvRequest));
}
@@ -2607,25 +2602,26 @@ void ServerCancelRequestHandler::handleResponse(osiSockAddr* responseFrom,
const pvAccessID ioid = payloadBuffer->getInt();
ServerChannel::shared_pointer channel = casTransport->getChannel(sid);
if (!channel.get())
if (!channel)
{
failureResponse(transport, ioid, BaseChannelRequester::badCIDStatus);
return;
}
Destroyable::shared_pointer request = channel->getRequest(ioid);
if (!request.get())
BaseChannelRequester::shared_pointer request(channel->getRequest(ioid));
if (!request)
{
failureResponse(transport, ioid, BaseChannelRequester::badIOIDStatus);
return;
}
ChannelRequest::shared_pointer cr = dynamic_pointer_cast<ChannelRequest>(request);
if (!cr.get())
if (!cr)
{
failureResponse(transport, ioid, BaseChannelRequester::notAChannelRequestStatus);
return;
}
// never gets here
// cancel
cr->cancel();
@@ -2733,9 +2729,8 @@ ChannelProcessRequester::shared_pointer ServerChannelProcessRequesterImpl::creat
void ServerChannelProcessRequesterImpl::activate(PVStructure::shared_pointer const & pvRequest)
{
startRequest(QOS_INIT);
ChannelProcessRequester::shared_pointer thisPointer = shared_from_this();
Destroyable::shared_pointer thisDestroyable = shared_from_this();
_channel->registerRequest(_ioid, thisDestroyable);
shared_pointer thisPointer(shared_from_this());
_channel->registerRequest(_ioid, thisPointer);
INIT_EXCEPTION_GUARD(CMD_PROCESS, _channelProcess, _channel->getChannel()->createChannelProcess(thisPointer, pvRequest));
}
@@ -3013,9 +3008,8 @@ ChannelRPCRequester::shared_pointer ServerChannelRPCRequesterImpl::create(
void ServerChannelRPCRequesterImpl::activate(PVStructure::shared_pointer const & pvRequest)
{
startRequest(QOS_INIT);
ChannelRPCRequester::shared_pointer thisPointer = shared_from_this();
Destroyable::shared_pointer thisDestroyable = shared_from_this();
_channel->registerRequest(_ioid, thisDestroyable);
shared_pointer thisPointer(shared_from_this());
_channel->registerRequest(_ioid, thisPointer);
INIT_EXCEPTION_GUARD(CMD_RPC, _channelRPC, _channel->getChannel()->createChannelRPC(thisPointer, pvRequest));
}
+3 -3
View File
@@ -34,7 +34,7 @@ ServerChannel::ServerChannel(Channel::shared_pointer const & channel,
}
}
void ServerChannel::registerRequest(const pvAccessID id, Destroyable::shared_pointer const & request)
void ServerChannel::registerRequest(const pvAccessID id, const std::tr1::shared_ptr<BaseChannelRequester> & request)
{
Lock guard(_mutex);
if(_destroyed) throw std::logic_error("Can't registerRequest() for destory'd server channel");
@@ -51,7 +51,7 @@ void ServerChannel::unregisterRequest(const pvAccessID id)
}
}
Destroyable::shared_pointer ServerChannel::getRequest(const pvAccessID id)
std::tr1::shared_ptr<BaseChannelRequester> ServerChannel::getRequest(const pvAccessID id)
{
Lock guard(_mutex);
_requests_t::iterator iter = _requests.find(id);
@@ -59,7 +59,7 @@ Destroyable::shared_pointer ServerChannel::getRequest(const pvAccessID id)
{
return iter->second;
}
return Destroyable::shared_pointer();
return BaseChannelRequester::shared_pointer();
}
void ServerChannel::destroy()