mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-19 19:52:48 +00:00
stasis: Use an implementation specific channel snapshot cache.
Channels no longer use the Stasis cache for channel snapshots. Instead they are stored in a hash table in stasis_channels which reduces the number of Stasis messages created and allows better storage. As a result the following APIs are no longer available since the stasis cache is no longer used: ast_channel_topic_cached() ast_channel_topic_all_cached() The ast_channel_cache_all() and ast_channel_cache_by_name() functions now return an ao2_container of ast_channel_snapshots rather than a container of stasis_messages therefore you can't (and don't need to) call stasis_cache functions on it. The ast_channel_topic_all() function now returns a normal topic not a cached one so you can't use stasis cache functions on it either. The ast_channel_snapshot_type() stasis message now has the ast_channel_snapshot_update structure as it's data. It contains the last snapshot and the new one. ast_channel_snapshot_get_latest() still returns the latest snapshot. The latest snapshot is now stored on the channel itself to eliminate cache hits when Stasis messages that have the snapshot as a payload are created. ASTERISK-28102 Change-Id: I9334febff60a82d7c39703e49059fa3a68825786
This commit is contained in:
25
main/cli.c
25
main/cli.c
@@ -956,7 +956,7 @@ static char *handle_chanlist(struct ast_cli_entry *e, int cmd, struct ast_cli_ar
|
||||
|
||||
struct ao2_container *channels;
|
||||
struct ao2_iterator it_chans;
|
||||
struct stasis_message *msg;
|
||||
struct ast_channel_snapshot *cs;
|
||||
int numchans = 0, concise = 0, verbose = 0, count = 0;
|
||||
|
||||
switch (cmd) {
|
||||
@@ -989,11 +989,7 @@ static char *handle_chanlist(struct ast_cli_entry *e, int cmd, struct ast_cli_ar
|
||||
} else if (a->argc != e->args - 1)
|
||||
return CLI_SHOWUSAGE;
|
||||
|
||||
|
||||
if (!(channels = stasis_cache_dump(ast_channel_cache_by_name(), ast_channel_snapshot_type()))) {
|
||||
ast_cli(a->fd, "Failed to retrieve cached channels\n");
|
||||
return CLI_SUCCESS;
|
||||
}
|
||||
channels = ast_channel_cache_by_name();
|
||||
|
||||
if (!count) {
|
||||
if (!concise && !verbose)
|
||||
@@ -1004,8 +1000,7 @@ static char *handle_chanlist(struct ast_cli_entry *e, int cmd, struct ast_cli_ar
|
||||
}
|
||||
|
||||
it_chans = ao2_iterator_init(channels, 0);
|
||||
for (; (msg = ao2_iterator_next(&it_chans)); ao2_ref(msg, -1)) {
|
||||
struct ast_channel_snapshot *cs = stasis_message_data(msg);
|
||||
for (; (cs = ao2_iterator_next(&it_chans)); ao2_ref(cs, -1)) {
|
||||
char durbuf[16] = "-";
|
||||
|
||||
if (!count) {
|
||||
@@ -1679,29 +1674,25 @@ char *ast_complete_channels(const char *line, const char *word, int pos, int sta
|
||||
struct ao2_container *cached_channels;
|
||||
char *ret = NULL;
|
||||
struct ao2_iterator iter;
|
||||
struct stasis_message *msg;
|
||||
struct ast_channel_snapshot *snapshot;
|
||||
|
||||
if (pos != rpos) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!(cached_channels = stasis_cache_dump(ast_channel_cache(), ast_channel_snapshot_type()))) {
|
||||
return NULL;
|
||||
}
|
||||
cached_channels = ast_channel_cache_all();
|
||||
|
||||
iter = ao2_iterator_init(cached_channels, 0);
|
||||
for (; (msg = ao2_iterator_next(&iter)); ao2_ref(msg, -1)) {
|
||||
struct ast_channel_snapshot *snapshot = stasis_message_data(msg);
|
||||
|
||||
for (; (snapshot = ao2_iterator_next(&iter)); ao2_ref(snapshot, -1)) {
|
||||
if (!strncasecmp(word, snapshot->name, wordlen) && (++which > state)) {
|
||||
if (state != -1) {
|
||||
ret = ast_strdup(snapshot->name);
|
||||
ao2_ref(msg, -1);
|
||||
ao2_ref(snapshot, -1);
|
||||
break;
|
||||
}
|
||||
|
||||
if (ast_cli_completion_add(ast_strdup(snapshot->name))) {
|
||||
ao2_ref(msg, -1);
|
||||
ao2_ref(snapshot, -1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user