mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-18 18:46:16 +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:
@@ -576,11 +576,6 @@ static struct ast_manager_event_blob *channel_state_change(
|
||||
{
|
||||
int is_hungup, was_hungup;
|
||||
|
||||
if (!new_snapshot) {
|
||||
/* Ignore cache clearing events; we'll see the hangup first */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* The Newchannel, Newstate and Hangup events are closely related, in
|
||||
* in that they are mutually exclusive, basically different flavors
|
||||
* of a new channel state event.
|
||||
@@ -616,11 +611,6 @@ static struct ast_manager_event_blob *channel_newexten(
|
||||
struct ast_channel_snapshot *old_snapshot,
|
||||
struct ast_channel_snapshot *new_snapshot)
|
||||
{
|
||||
/* No Newexten event on cache clear */
|
||||
if (!new_snapshot) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Empty application is not valid for a Newexten event */
|
||||
if (ast_strlen_zero(new_snapshot->appl)) {
|
||||
return NULL;
|
||||
@@ -654,8 +644,8 @@ static struct ast_manager_event_blob *channel_new_callerid(
|
||||
struct ast_manager_event_blob *res;
|
||||
char *callerid;
|
||||
|
||||
/* No NewCallerid event on cache clear or first event */
|
||||
if (!old_snapshot || !new_snapshot) {
|
||||
/* No NewCallerid event on first channel snapshot */
|
||||
if (!old_snapshot) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -682,8 +672,8 @@ static struct ast_manager_event_blob *channel_new_connected_line(
|
||||
struct ast_channel_snapshot *old_snapshot,
|
||||
struct ast_channel_snapshot *new_snapshot)
|
||||
{
|
||||
/* No NewConnectedLine event on cache clear or first event */
|
||||
if (!old_snapshot || !new_snapshot) {
|
||||
/* No NewConnectedLine event on first channel snapshot */
|
||||
if (!old_snapshot) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -699,7 +689,7 @@ static struct ast_manager_event_blob *channel_new_accountcode(
|
||||
struct ast_channel_snapshot *old_snapshot,
|
||||
struct ast_channel_snapshot *new_snapshot)
|
||||
{
|
||||
if (!old_snapshot || !new_snapshot) {
|
||||
if (!old_snapshot) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -724,21 +714,14 @@ static void channel_snapshot_update(void *data, struct stasis_subscription *sub,
|
||||
struct stasis_message *message)
|
||||
{
|
||||
RAII_VAR(struct ast_str *, channel_event_string, NULL, ast_free);
|
||||
struct stasis_cache_update *update;
|
||||
struct ast_channel_snapshot *old_snapshot;
|
||||
struct ast_channel_snapshot *new_snapshot;
|
||||
struct ast_channel_snapshot_update *update;
|
||||
size_t i;
|
||||
|
||||
update = stasis_message_data(message);
|
||||
|
||||
ast_assert(ast_channel_snapshot_type() == update->type);
|
||||
|
||||
old_snapshot = stasis_message_data(update->old_snapshot);
|
||||
new_snapshot = stasis_message_data(update->new_snapshot);
|
||||
|
||||
for (i = 0; i < ARRAY_LEN(channel_monitors); ++i) {
|
||||
RAII_VAR(struct ast_manager_event_blob *, ev, NULL, ao2_cleanup);
|
||||
ev = channel_monitors[i](old_snapshot, new_snapshot);
|
||||
ev = channel_monitors[i](update->old_snapshot, update->new_snapshot);
|
||||
|
||||
if (!ev) {
|
||||
continue;
|
||||
@@ -747,7 +730,7 @@ static void channel_snapshot_update(void *data, struct stasis_subscription *sub,
|
||||
/* If we haven't already, build the channel event string */
|
||||
if (!channel_event_string) {
|
||||
channel_event_string =
|
||||
ast_manager_build_channel_state_string(new_snapshot);
|
||||
ast_manager_build_channel_state_string(update->new_snapshot);
|
||||
if (!channel_event_string) {
|
||||
return;
|
||||
}
|
||||
@@ -1260,7 +1243,7 @@ int manager_channels_init(void)
|
||||
if (!message_router) {
|
||||
return -1;
|
||||
}
|
||||
channel_topic = ast_channel_topic_all_cached();
|
||||
channel_topic = ast_channel_topic_all();
|
||||
if (!channel_topic) {
|
||||
return -1;
|
||||
}
|
||||
@@ -1272,7 +1255,7 @@ int manager_channels_init(void)
|
||||
|
||||
ast_register_cleanup(manager_channels_shutdown);
|
||||
|
||||
ret |= stasis_message_router_add_cache_update(message_router,
|
||||
ret |= stasis_message_router_add(message_router,
|
||||
ast_channel_snapshot_type(), channel_snapshot_update, NULL);
|
||||
|
||||
ret |= stasis_message_router_add(message_router,
|
||||
|
Reference in New Issue
Block a user