CACMonitor: if already started defend against start being called after reconnect
This commit is contained in:
@@ -1166,9 +1166,9 @@ CAChannelPut::CAChannelPut(CAChannel::shared_pointer const & channel,
|
||||
:
|
||||
channel(channel),
|
||||
channelPutRequester(channelPutRequester),
|
||||
pvRequest(pvRequest),
|
||||
lastRequestFlag(false),
|
||||
block(false)
|
||||
pvRequest(pvRequest),
|
||||
block(false),
|
||||
lastRequestFlag(false)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -1647,6 +1647,9 @@ CAChannelMonitorPtr CAChannelMonitor::create(
|
||||
|
||||
CAChannelMonitor::~CAChannelMonitor()
|
||||
{
|
||||
if(!isStarted) return;
|
||||
channel->threadAttach();
|
||||
ca_clear_subscription(eventID);
|
||||
}
|
||||
|
||||
CAChannelMonitor::CAChannelMonitor(
|
||||
@@ -1656,8 +1659,8 @@ CAChannelMonitor::CAChannelMonitor(
|
||||
:
|
||||
channel(channel),
|
||||
monitorRequester(monitorRequester),
|
||||
pvRequest(pvRequest)
|
||||
|
||||
pvRequest(pvRequest),
|
||||
isStarted(false)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -1747,6 +1750,11 @@ void CAChannelMonitor::subscriptionEvent(struct event_handler_args &args)
|
||||
|
||||
epics::pvData::Status CAChannelMonitor::start()
|
||||
{
|
||||
Status status = Status::Ok;
|
||||
if(isStarted) {
|
||||
status = Status(Status::STATUSTYPE_WARNING,"already started");
|
||||
return status;
|
||||
}
|
||||
channel->threadAttach();
|
||||
|
||||
/*
|
||||
@@ -1768,24 +1776,26 @@ epics::pvData::Status CAChannelMonitor::start()
|
||||
&eventID);
|
||||
if (result == ECA_NORMAL)
|
||||
{
|
||||
isStarted = true;
|
||||
monitorQueue->start();
|
||||
ca_flush_io();
|
||||
return Status::Ok;
|
||||
}
|
||||
else
|
||||
{
|
||||
return status;
|
||||
} else {
|
||||
isStarted = false;
|
||||
return Status(Status::STATUSTYPE_ERROR, string(ca_message(result)));
|
||||
}
|
||||
}
|
||||
|
||||
epics::pvData::Status CAChannelMonitor::stop()
|
||||
{
|
||||
if(!isStarted) return Status(Status::STATUSTYPE_WARNING,"already stopped");
|
||||
channel->threadAttach();
|
||||
|
||||
int result = ca_clear_subscription(eventID);
|
||||
|
||||
if (result == ECA_NORMAL)
|
||||
{
|
||||
isStarted = false;
|
||||
monitorQueue->stop();
|
||||
return Status::Ok;
|
||||
}
|
||||
@@ -1819,8 +1829,10 @@ void CAChannelMonitor::cancel()
|
||||
|
||||
void CAChannelMonitor::destroy()
|
||||
{
|
||||
if(!isStarted) return;
|
||||
channel->threadAttach();
|
||||
ca_clear_subscription(eventID);
|
||||
isStarted = false;
|
||||
}
|
||||
|
||||
}}}
|
||||
|
||||
@@ -179,13 +179,11 @@ private:
|
||||
CAChannel::shared_pointer channel;
|
||||
ChannelGetRequester::shared_pointer channelGetRequester;
|
||||
epics::pvData::PVStructure::shared_pointer pvRequest;
|
||||
chtype getType;
|
||||
bool lastRequestFlag;
|
||||
|
||||
chtype getType;
|
||||
epics::pvData::PVStructure::shared_pointer pvStructure;
|
||||
epics::pvData::BitSet::shared_pointer bitSet;
|
||||
|
||||
// TODO AtomicBoolean !!!
|
||||
bool lastRequestFlag;
|
||||
};
|
||||
|
||||
|
||||
@@ -248,14 +246,12 @@ private:
|
||||
CAChannel::shared_pointer channel;
|
||||
ChannelPutRequester::shared_pointer channelPutRequester;
|
||||
epics::pvData::PVStructure::shared_pointer pvRequest;
|
||||
chtype getType;
|
||||
bool block;
|
||||
bool lastRequestFlag;
|
||||
|
||||
chtype getType;
|
||||
epics::pvData::PVStructure::shared_pointer pvStructure;
|
||||
epics::pvData::BitSet::shared_pointer bitSet;
|
||||
|
||||
// TODO AtomicBoolean !!!
|
||||
bool lastRequestFlag;
|
||||
bool block;
|
||||
};
|
||||
|
||||
class CACMonitorQueue;
|
||||
@@ -311,6 +307,7 @@ private:
|
||||
CAChannelPtr channel;
|
||||
MonitorRequester::shared_pointer monitorRequester;
|
||||
epics::pvData::PVStructure::shared_pointer pvRequest;
|
||||
bool isStarted;
|
||||
chtype getType;
|
||||
|
||||
epics::pvData::PVStructure::shared_pointer pvStructure;
|
||||
|
||||
Reference in New Issue
Block a user