fix issue #77
This commit is contained in:
@@ -52,7 +52,28 @@ CAChannelProvider::CAChannelProvider(const std::tr1::shared_ptr<Configuration>&)
|
||||
|
||||
CAChannelProvider::~CAChannelProvider()
|
||||
{
|
||||
if(DEBUG_LEVEL>0) std::cout << "CAChannelProvider::~CAChannelProvider()\n";
|
||||
if(DEBUG_LEVEL>0) {
|
||||
std::cout << "CAChannelProvider::~CAChannelProvider()"
|
||||
<< " caChannelList.size() " << caChannelList.size()
|
||||
<< std::endl;
|
||||
}
|
||||
std::queue<CAChannelPtr> channelQ;
|
||||
{
|
||||
Lock lock(channelListMutex);
|
||||
for(size_t i=0; i< caChannelList.size(); ++i) {
|
||||
CAChannelPtr caChannel(caChannelList[i].lock());
|
||||
if(caChannel) channelQ.push(caChannel);
|
||||
}
|
||||
}
|
||||
while(!channelQ.empty()) {
|
||||
if(DEBUG_LEVEL>0) {
|
||||
std::cout << "disconnectAllChannels calling disconnectChannel "
|
||||
<< channelQ.front()->getChannelName()
|
||||
<< std::endl;
|
||||
}
|
||||
channelQ.front()->disconnectChannel();
|
||||
channelQ.pop();
|
||||
}
|
||||
}
|
||||
|
||||
std::string CAChannelProvider::getProviderName()
|
||||
@@ -112,6 +133,23 @@ Channel::shared_pointer CAChannelProvider::createChannel(
|
||||
return CAChannel::create(shared_from_this(), channelName, priority, channelRequester);
|
||||
}
|
||||
|
||||
void CAChannelProvider::addChannel(const CAChannelPtr & channel)
|
||||
{
|
||||
if(DEBUG_LEVEL>0) {
|
||||
std::cout << "CAChannelProvider::addChannel "
|
||||
<< channel->getChannelName()
|
||||
<< std::endl;
|
||||
}
|
||||
Lock lock(channelListMutex);
|
||||
for(size_t i=0; i< caChannelList.size(); ++i) {
|
||||
if(!(caChannelList[i].lock())) {
|
||||
caChannelList[i] = channel;
|
||||
return;
|
||||
}
|
||||
}
|
||||
caChannelList.push_back(channel);
|
||||
}
|
||||
|
||||
void CAChannelProvider::configure(epics::pvData::PVStructure::shared_pointer /*configuration*/)
|
||||
{
|
||||
}
|
||||
@@ -136,13 +174,11 @@ void CAChannelProvider::initialize()
|
||||
/* Create Channel Access */
|
||||
int result = ca_context_create(ca_enable_preemptive_callback);
|
||||
if (result != ECA_NORMAL) {
|
||||
throw std::runtime_error(std::string("CA error %s occurred while trying "
|
||||
"to start channel access:") + ca_message(result));
|
||||
throw std::runtime_error(
|
||||
std::string("CA error %s occurred while trying to start channel access:")
|
||||
+ ca_message(result));
|
||||
}
|
||||
|
||||
current_context = ca_current_context();
|
||||
|
||||
// TODO create a ca_poll thread, if ca_disable_preemptive_callback
|
||||
}
|
||||
|
||||
|
||||
@@ -154,7 +190,9 @@ void ca_factory_cleanup(void*)
|
||||
ChannelProviderRegistry::clients()->remove("ca");
|
||||
ca_context_destroy();
|
||||
} catch(std::exception& e) {
|
||||
LOG(logLevelWarn, "Error when unregister \"ca\" factory");
|
||||
std::string message("Error when unregister \"ca\" factory");
|
||||
message += e.what();
|
||||
LOG(logLevelWarn,message.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -173,7 +211,7 @@ void CAClientFactory::start()
|
||||
registerRefCounter("CAChannelPut", &CAChannelPut::num_instances);
|
||||
registerRefCounter("CAChannelMonitor", &CAChannelMonitor::num_instances);
|
||||
|
||||
if(ChannelProviderRegistry::clients()->add<CAChannelProvider>("ca", false))
|
||||
if(ChannelProviderRegistry::clients()->add<CAChannelProvider>("ca", true))
|
||||
{
|
||||
epicsAtExit(&ca_factory_cleanup, NULL);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user