]> git.ipfire.org Git - thirdparty/asterisk.git/commit
stasis_channels: Use uniqueid and name to delete old snapshots
authorGeorge Joseph <gjoseph@sangoma.com>
Wed, 8 May 2024 17:32:36 +0000 (11:32 -0600)
committerAsterisk Development Team <asteriskteam@digium.com>
Fri, 28 Jun 2024 19:52:53 +0000 (13:52 -0600)
commitb8c440a52f7b60d1f717804da33fe530501d660a
treecc08693ef39a56c974817b11980a59ba573f9dbe
parente5b6a5be5e4e21c1780960e23fa54bf79b768d16
stasis_channels: Use uniqueid and name to delete old snapshots

Whenver a new channel snapshot is created or when a channel is
destroyed, we need to delete any existing channel snapshot from
the snapshot cache.  Historically, we used the channel->snapshot
pointer to delete any existing snapshots but this has two issues.

First, if something (possibly ast_channel_internal_swap_snapshots)
sets channel->snapshot to NULL while there's still a snapshot in
the cache, we wouldn't be able to delete it and it would be orphaned
when the channel is destroyed.  Since we use the cache to list
channels from the CLI, AMI and ARI, it would appear as though the
channel was still there when it wasn't.

Second, since there are actually two caches, one indexed by the
channel's uniqueid, and another indexed by the channel's name,
deleting from the caches by pointer requires a sequential search of
all of the hash table buckets in BOTH caches to find the matching
snapshots.  Not very efficient.

So, we now delete from the caches using the channel's uniqueid
and name.  This solves both issues.

This doesn't address how channel->snapshot might have been set
to NULL in the first place because although we have concrete
evidence that it's happening, we haven't been able to reproduce it.

Resolves: #783
main/stasis_channels.c