Merge pull request #15 from mrkraimer/master
pvaClientChannel.cpp fix possible race conditions; pvaClientNTMultiDa…
This commit is contained in:
@@ -170,12 +170,16 @@ PvaClientChannel::~PvaClientChannel()
|
||||
|
||||
void PvaClientChannel::channelCreated(const Status& status, Channel::shared_pointer const & channel)
|
||||
{
|
||||
Lock xx(mutex);
|
||||
if(isDestroyed) throw std::runtime_error("pvaClientChannel was destroyed");
|
||||
if(status.isOK()) {
|
||||
this->channel = channel;
|
||||
if(channel->isConnected()) {
|
||||
bool waitingForConnect = false;
|
||||
if(connectState==connectActive) waitingForConnect = true;
|
||||
connectState = connected;
|
||||
channelConnectStatus = Status::Ok;
|
||||
if(waitingForConnect) waitForConnect.signal();
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -258,15 +262,18 @@ void PvaClientChannel::connect(double timeout)
|
||||
|
||||
void PvaClientChannel::issueConnect()
|
||||
{
|
||||
if(isDestroyed) throw std::runtime_error("pvaClientChannel was destroyed");
|
||||
if(connectState!=connectIdle) {
|
||||
throw std::runtime_error("pvaClientChannel already connected");
|
||||
}
|
||||
{
|
||||
Lock xx(mutex);
|
||||
if(isDestroyed) throw std::runtime_error("pvaClientChannel was destroyed");
|
||||
if(connectState!=connectIdle) {
|
||||
throw std::runtime_error("pvaClientChannel already connected");
|
||||
}
|
||||
|
||||
channelConnectStatus = Status(
|
||||
Status::STATUSTYPE_ERROR,
|
||||
getChannelName() + " createChannel failed");
|
||||
connectState = connectActive;
|
||||
channelConnectStatus = Status(
|
||||
Status::STATUSTYPE_ERROR,
|
||||
getChannelName() + " createChannel failed");
|
||||
connectState = connectActive;
|
||||
}
|
||||
ChannelProviderRegistry::shared_pointer reg = getChannelProviderRegistry();
|
||||
ChannelProvider::shared_pointer provider = reg->getProvider(providerName);
|
||||
if(!provider) {
|
||||
@@ -281,8 +288,11 @@ void PvaClientChannel::issueConnect()
|
||||
|
||||
Status PvaClientChannel::waitConnect(double timeout)
|
||||
{
|
||||
if(isDestroyed) throw std::runtime_error("pvaClientChannel was destroyed");
|
||||
if(channel->isConnected()) return Status::Ok;
|
||||
{
|
||||
Lock xx(mutex);
|
||||
if(isDestroyed) throw std::runtime_error("pvaClientChannel was destroyed");
|
||||
if(channel->isConnected()) return Status::Ok;
|
||||
}
|
||||
waitForConnect.wait(timeout);
|
||||
return channelConnectStatus;
|
||||
}
|
||||
|
||||
@@ -155,23 +155,22 @@ void PvaClientNTMultiData::endDeltaTime()
|
||||
{
|
||||
PVStructurePtr pvst = topPVStructure[i];
|
||||
if(!pvst) {
|
||||
unionValue[i] = PVUnionPtr();
|
||||
unionValue[i] = PVUnionPtr();
|
||||
} else {
|
||||
unionValue[i]->set(pvst->getSubField("value"));
|
||||
}
|
||||
if(gotAlarm)
|
||||
{
|
||||
severity[i] = pvst->getSubField<PVInt>("alarm.severity")->get();
|
||||
status[i] = pvst->getSubField<PVInt>("alarm.status")->get();
|
||||
message[i] = pvst->getSubField<PVString>("alarm.message")->get();
|
||||
}
|
||||
if(gotTimeStamp)
|
||||
{
|
||||
secondsPastEpoch[i] = pvst->getSubField<PVLong>("timeStamp.secondsPastEpoch")->get();
|
||||
nanoseconds[i] = pvst->getSubField<PVInt>("timeStamp.nanoseconds")->get();
|
||||
userTag[i] = pvst->getSubField<PVInt>("timeStamp.userTag")->get();
|
||||
}
|
||||
|
||||
unionValue[i]->set(pvst->getSubField("value"));
|
||||
if(gotAlarm)
|
||||
{
|
||||
severity[i] = pvst->getSubField<PVInt>("alarm.severity")->get();
|
||||
status[i] = pvst->getSubField<PVInt>("alarm.status")->get();
|
||||
message[i] = pvst->getSubField<PVString>("alarm.message")->get();
|
||||
}
|
||||
if(gotTimeStamp)
|
||||
{
|
||||
secondsPastEpoch[i] = pvst->getSubField<PVLong>("timeStamp.secondsPastEpoch")->get();
|
||||
nanoseconds[i] = pvst->getSubField<PVInt>("timeStamp.nanoseconds")->get();
|
||||
userTag[i] = pvst->getSubField<PVInt>("timeStamp.userTag")->get();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user