summaryrefslogtreecommitdiff
path: root/main/endpoints.c
diff options
context:
space:
mode:
authorKinsey Moore <kmoore@digium.com>2013-06-07 12:56:56 +0000
committerKinsey Moore <kmoore@digium.com>2013-06-07 12:56:56 +0000
commit759a7e4a30b5e69738670494e5c19b6982a34644 (patch)
tree56e190b02bf90267738a4da3f0c8bb87e55424eb /main/endpoints.c
parent611416623748504be81c58b455205a4bc7fff414 (diff)
Rework stasis cache clear events
Stasis cache clear message payloads now consist of a stasis_message representative of the message to be cleared from the cache. This allows multiple parallel caches to coexist and be cleared properly by the same cache clear message even when keyed on different fields. This change fixes a bug where multiple cache clears could be posted for channels. The cache clear is now produced in the destructor instead of ast_hangup. Additionally, dummy channels are no longer capable of producing channel snapshots. Review: https://reviewboard.asterisk.org/r/2596 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@390830 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/endpoints.c')
-rw-r--r--main/endpoints.c36
1 files changed, 29 insertions, 7 deletions
diff --git a/main/endpoints.c b/main/endpoints.c
index c2d0577f9..a5d50cfde 100644
--- a/main/endpoints.c
+++ b/main/endpoints.c
@@ -145,18 +145,25 @@ static void endpoint_channel_snapshot(void *data,
}
}
+/*! \brief Handler for channel snapshot cache clears */
static void endpoint_cache_clear(void *data,
struct stasis_subscription *sub, struct stasis_topic *topic,
struct stasis_message *message)
{
struct ast_endpoint *endpoint = data;
- struct stasis_cache_clear *clear = stasis_message_data(message);
+ struct stasis_message *clear_msg = stasis_message_data(message);
+ struct ast_channel_snapshot *clear_snapshot;
+
+ if (stasis_message_type(clear_msg) != ast_channel_snapshot_type()) {
+ return;
+ }
+
+ clear_snapshot = stasis_message_data(clear_msg);
ast_assert(endpoint != NULL);
- ast_assert(clear != NULL);
ao2_lock(endpoint);
- ao2_find(endpoint->channel_ids, clear->id, OBJ_POINTER | OBJ_NODATA | OBJ_UNLINK);
+ ast_str_container_remove(endpoint->channel_ids, clear_snapshot->uniqueid);
ao2_unlock(endpoint);
endpoint_publish_snapshot(endpoint);
}
@@ -247,17 +254,32 @@ const char *ast_endpoint_get_tech(const struct ast_endpoint *endpoint)
return endpoint->tech;
}
+static struct stasis_message *create_endpoint_snapshot_message(struct ast_endpoint *endpoint)
+{
+ RAII_VAR(struct ast_endpoint_snapshot *, snapshot, NULL, ao2_cleanup);
+ snapshot = ast_endpoint_snapshot_create(endpoint);
+ if (!snapshot) {
+ return NULL;
+ }
+
+ return stasis_message_create(ast_endpoint_snapshot_type(), snapshot);
+}
+
void ast_endpoint_shutdown(struct ast_endpoint *endpoint)
{
- RAII_VAR(struct stasis_message *, message, NULL, ao2_cleanup);
+ RAII_VAR(struct stasis_message *, clear_msg, NULL, ao2_cleanup);
if (endpoint == NULL) {
return;
}
- message = stasis_cache_clear_create(ast_endpoint_snapshot_type(), endpoint->id);
- if (message) {
- stasis_publish(endpoint->topic, message);
+ clear_msg = create_endpoint_snapshot_message(endpoint);
+ if (clear_msg) {
+ RAII_VAR(struct stasis_message *, message, NULL, ao2_cleanup);
+ message = stasis_cache_clear_create(clear_msg);
+ if (message) {
+ stasis_publish(endpoint->topic, message);
+ }
}
/* Bump refcount to hold on to the router */