CAProvider: Fix cleanup during provider destruction

CAChannel's channelProvider pointers have all expired by
now, so the destructor must empty caChannelList itself.
This commit is contained in:
Andrew Johnson
2021-10-21 14:23:40 -05:00
parent c44f90fd49
commit 3a20a064e5

View File

@ -32,8 +32,11 @@ CAChannelProvider::CAChannelProvider(const std::tr1::shared_ptr<Configuration> &
CAChannelProvider::~CAChannelProvider()
{
epicsGuard<epicsMutex> G(channelListMutex);
while (CAChannel *ch = caChannelList.first()) {
ch->disconnectChannel(); // Removes itself from the list
while (CAChannel *ch = caChannelList.get()) {
// Here disconnectChannel() can't call our delChannel()
// beacuse its CAChannelProviderPtr has by now expired.
// That's why we removed it from caChannelList above.
ch->disconnectChannel();
}
}