core: Don't create snapshots with locks.
authorJoshua Colp <jcolp@digium.com>
Tue, 10 Mar 2015 23:09:49 +0000 (23:09 +0000)
committerJoshua Colp <jcolp@digium.com>
Tue, 10 Mar 2015 23:09:49 +0000 (23:09 +0000)
Snapshots are immutable and are never changed. Allocating them
with a lock is wasteful.

Review: https://reviewboard.asterisk.org/r/4469/
........

Merged revisions 432742 from http://svn.asterisk.org/svn/asterisk/branches/13

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@432743 65c4cc65-6c06-0410-ace0-fbb531ad65f3

main/endpoints.c
main/stasis_bridges.c
main/stasis_channels.c

index f8cca45..3a6f494 100644 (file)
@@ -467,9 +467,10 @@ struct ast_endpoint_snapshot *ast_endpoint_snapshot_create(
 
        channel_count = ao2_container_count(endpoint->channel_ids);
 
-       snapshot = ao2_alloc(
+       snapshot = ao2_alloc_options(
                sizeof(*snapshot) + channel_count * sizeof(char *),
-               endpoint_snapshot_dtor);
+               endpoint_snapshot_dtor,
+               AO2_ALLOC_OPT_LOCK_NOLOCK);
 
        if (ast_string_field_init(snapshot, 80) != 0) {
                return NULL;
index fbdb98c..1838557 100644 (file)
@@ -232,7 +232,8 @@ struct ast_bridge_snapshot *ast_bridge_snapshot_create(struct ast_bridge *bridge
        RAII_VAR(struct ast_bridge_snapshot *, snapshot, NULL, ao2_cleanup);
        struct ast_bridge_channel *bridge_channel;
 
-       snapshot = ao2_alloc(sizeof(*snapshot), bridge_snapshot_dtor);
+       snapshot = ao2_alloc_options(sizeof(*snapshot), bridge_snapshot_dtor,
+               AO2_ALLOC_OPT_LOCK_NOLOCK);
        if (!snapshot || ast_string_field_init(snapshot, 128)) {
                return NULL;
        }
index 6b3f765..85abe58 100644 (file)
@@ -209,7 +209,8 @@ struct ast_channel_snapshot *ast_channel_snapshot_create(struct ast_channel *cha
                return NULL;
        }
 
-       snapshot = ao2_alloc(sizeof(*snapshot), channel_snapshot_dtor);
+       snapshot = ao2_alloc_options(sizeof(*snapshot), channel_snapshot_dtor,
+               AO2_ALLOC_OPT_LOCK_NOLOCK);
        if (!snapshot || ast_string_field_init(snapshot, 1024)) {
                ao2_cleanup(snapshot);
                return NULL;
@@ -617,7 +618,8 @@ void ast_multi_channel_blob_add_channel(struct ast_multi_channel_blob *obj, cons
                return;
        }
 
-       role_snapshot = ao2_alloc(sizeof(*role_snapshot) + role_len, channel_role_snapshot_dtor);
+       role_snapshot = ao2_alloc_options(sizeof(*role_snapshot) + role_len, channel_role_snapshot_dtor,
+               AO2_ALLOC_OPT_LOCK_NOLOCK);
        if (!role_snapshot) {
                return;
        }