server GetField ensure no duplicate reply

This commit is contained in:
Michael Davidsaver
2017-11-06 16:36:36 -06:00
parent 84a0729bcf
commit 3b565d0c56
4 changed files with 14 additions and 7 deletions
+1
View File
@@ -687,6 +687,7 @@ public:
void destroy();
void send(epics::pvData::ByteBuffer* buffer, TransportSendControl* control);
private:
bool done;
epics::pvData::Status _status;
epics::pvData::FieldConstPtr _field;
};
+1 -1
View File
@@ -48,7 +48,7 @@ public:
void unregisterRequest(pvAccessID id);
void installGetField(const GetFieldRequester::shared_pointer& gf);
void completeGetField();
void completeGetField(GetFieldRequester *req);
//! may return NULL
Destroyable::shared_pointer getRequest(pvAccessID id);
+9 -4
View File
@@ -2783,20 +2783,25 @@ void ServerGetFieldHandler::getFieldFailureResponse(Transport::shared_pointer co
ServerGetFieldRequesterImpl::ServerGetFieldRequesterImpl(
ServerContextImpl::shared_pointer const & context, ServerChannel::shared_pointer const & channel,
const pvAccessID ioid, Transport::shared_pointer const & transport) :
BaseChannelRequester(context, channel, ioid, transport), _field()
BaseChannelRequester(context, channel, ioid, transport), done(false)
{
}
void ServerGetFieldRequesterImpl::getDone(const Status& status, FieldConstPtr const & field)
{
bool twice;
{
Lock guard(_mutex);
_status = status;
_field = field;
twice = done;
done = true;
}
TransportSender::shared_pointer thisSender = shared_from_this();
_transport->enqueueSendRequest(thisSender);
_channel->completeGetField();
if(!twice) {
TransportSender::shared_pointer thisSender = shared_from_this();
_transport->enqueueSendRequest(thisSender);
}
_channel->completeGetField(this);
}
void ServerGetFieldRequesterImpl::destroy()
+3 -2
View File
@@ -121,12 +121,13 @@ void ServerChannel::installGetField(const GetFieldRequester::shared_pointer& gf)
}
}
void ServerChannel::completeGetField()
void ServerChannel::completeGetField(GetFieldRequester *req)
{
GetFieldRequester::shared_pointer prev;
{
epicsGuard<epicsMutex> G(_mutex);
prev.swap(_active_requester);
if(_active_requester.get()==req)
prev.swap(_active_requester);
}
}