<p>George Joseph <strong>merged</strong> this change.</p><p><a href="https://gerrit.asterisk.org/10504">View Change</a></p><div style="white-space:pre-wrap">Approvals:
Richard Mudgett: Looks good to me, but someone else must approve
George Joseph: Looks good to me, approved; Approved for Submit
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">astobj2: Eliminate usage of legacy container allocation macros.<br><br>These macros have been documented as legacy for a long time but are<br>still used in new code because they exist. Remove all references to:<br>* ao2_container_alloc_options<br>* ao2_t_container_alloc_options<br>* ao2_t_container_alloc<br><br>These macro's are still available for use but only in modules. Only<br>ao2_container_alloc remains due to it's use in over 100 places.<br><br>Change-Id: I1a26258b5bf3deb081aaeed11a0baa175c933c7a<br>---<br>M channels/chan_sip.c<br>M include/asterisk/astobj2.h<br>M main/bridge.c<br>M main/bucket.c<br>M main/ccss.c<br>M main/channel.c<br>M main/codec.c<br>M main/features_config.c<br>M main/format.c<br>M main/format_cache.c<br>M main/media_cache.c<br>M main/pbx.c<br>M main/pickup.c<br>M main/sorcery.c<br>M res/res_musiconhold.c<br>M res/res_pjsip_notify.c<br>M res/res_pjsip_outbound_publish.c<br>M res/res_sorcery_memory_cache.c<br>M res/res_srtp.c<br>M tests/test_astobj2.c<br>20 files changed, 86 insertions(+), 54 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/channels/chan_sip.c b/channels/chan_sip.c</span><br><span>index c8a2dea..c54789a 100644</span><br><span>--- a/channels/chan_sip.c</span><br><span>+++ b/channels/chan_sip.c</span><br><span>@@ -35360,12 +35360,18 @@</span><br><span> </span><br><span> /* the fact that ao2_containers can't resize automatically is a major worry! */</span><br><span> /* if the number of objects gets above MAX_XXX_BUCKETS, things will slow down */</span><br><span style="color: hsl(0, 100%, 40%);">- peers = ao2_t_container_alloc(HASH_PEER_SIZE, peer_hash_cb, peer_cmp_cb, "allocate peers");</span><br><span style="color: hsl(0, 100%, 40%);">- peers_by_ip = ao2_t_container_alloc(HASH_PEER_SIZE, peer_iphash_cb, NULL, "allocate peers_by_ip");</span><br><span style="color: hsl(0, 100%, 40%);">- dialogs = ao2_t_container_alloc(HASH_DIALOG_SIZE, dialog_hash_cb, dialog_cmp_cb, "allocate dialogs");</span><br><span style="color: hsl(0, 100%, 40%);">- dialogs_needdestroy = ao2_t_container_alloc(1, NULL, NULL, "allocate dialogs_needdestroy");</span><br><span style="color: hsl(0, 100%, 40%);">- dialogs_rtpcheck = ao2_t_container_alloc(HASH_DIALOG_SIZE, dialog_hash_cb, dialog_cmp_cb, "allocate dialogs for rtpchecks");</span><br><span style="color: hsl(0, 100%, 40%);">- threadt = ao2_t_container_alloc(HASH_DIALOG_SIZE, threadt_hash_cb, threadt_cmp_cb, "allocate threadt table");</span><br><span style="color: hsl(120, 100%, 40%);">+ peers = ao2_t_container_alloc_hash(AO2_ALLOC_OPT_LOCK_MUTEX, 0, HASH_PEER_SIZE,</span><br><span style="color: hsl(120, 100%, 40%);">+ peer_hash_cb, NULL, peer_cmp_cb, "allocate peers");</span><br><span style="color: hsl(120, 100%, 40%);">+ peers_by_ip = ao2_t_container_alloc_hash(AO2_ALLOC_OPT_LOCK_MUTEX, 0, HASH_PEER_SIZE,</span><br><span style="color: hsl(120, 100%, 40%);">+ peer_iphash_cb, NULL, NULL, "allocate peers_by_ip");</span><br><span style="color: hsl(120, 100%, 40%);">+ dialogs = ao2_t_container_alloc_hash(AO2_ALLOC_OPT_LOCK_MUTEX, 0, HASH_DIALOG_SIZE,</span><br><span style="color: hsl(120, 100%, 40%);">+ dialog_hash_cb, NULL, dialog_cmp_cb, "allocate dialogs");</span><br><span style="color: hsl(120, 100%, 40%);">+ dialogs_needdestroy = ao2_t_container_alloc_hash(AO2_ALLOC_OPT_LOCK_MUTEX, 0, 1,</span><br><span style="color: hsl(120, 100%, 40%);">+ NULL, NULL, NULL, "allocate dialogs_needdestroy");</span><br><span style="color: hsl(120, 100%, 40%);">+ dialogs_rtpcheck = ao2_t_container_alloc_hash(AO2_ALLOC_OPT_LOCK_MUTEX, 0, HASH_DIALOG_SIZE,</span><br><span style="color: hsl(120, 100%, 40%);">+ dialog_hash_cb, NULL, dialog_cmp_cb, "allocate dialogs for rtpchecks");</span><br><span style="color: hsl(120, 100%, 40%);">+ threadt = ao2_t_container_alloc_hash(AO2_ALLOC_OPT_LOCK_MUTEX, 0, HASH_DIALOG_SIZE,</span><br><span style="color: hsl(120, 100%, 40%);">+ threadt_hash_cb, NULL, threadt_cmp_cb, "allocate threadt table");</span><br><span> if (!peers || !peers_by_ip || !dialogs || !dialogs_needdestroy || !dialogs_rtpcheck</span><br><span> || !threadt) {</span><br><span> ast_log(LOG_ERROR, "Unable to create primary SIP container(s)\n");</span><br><span>@@ -35379,7 +35385,8 @@</span><br><span> }</span><br><span> ast_format_cap_append_by_type(sip_tech.capabilities, AST_MEDIA_TYPE_AUDIO);</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- registry_list = ao2_t_container_alloc(HASH_REGISTRY_SIZE, registry_hash_cb, registry_cmp_cb, "allocate registry_list");</span><br><span style="color: hsl(120, 100%, 40%);">+ registry_list = ao2_t_container_alloc_hash(AO2_ALLOC_OPT_LOCK_MUTEX, 0, HASH_REGISTRY_SIZE,</span><br><span style="color: hsl(120, 100%, 40%);">+ registry_hash_cb, NULL, registry_cmp_cb, "allocate registry_list");</span><br><span> subscription_mwi_list = ao2_t_container_alloc_list(AO2_ALLOC_OPT_LOCK_MUTEX,</span><br><span> AO2_CONTAINER_ALLOC_OPT_INSERT_BEGIN, NULL, NULL, "allocate subscription_mwi_list");</span><br><span> </span><br><span>diff --git a/include/asterisk/astobj2.h b/include/asterisk/astobj2.h</span><br><span>index 8e3a105..2910304 100644</span><br><span>--- a/include/asterisk/astobj2.h</span><br><span>+++ b/include/asterisk/astobj2.h</span><br><span>@@ -1298,6 +1298,7 @@</span><br><span> struct ao2_container;</span><br><span> </span><br><span> /*!</span><br><span style="color: hsl(120, 100%, 40%);">+ * \deprecated</span><br><span> * \brief Allocate and initialize a hash container with the desired number of buckets.</span><br><span> *</span><br><span> * \details</span><br><span>@@ -1315,16 +1316,20 @@</span><br><span> * \note Destructor is set implicitly.</span><br><span> * \note This is legacy container creation that is mapped to the new method.</span><br><span> */</span><br><span style="color: hsl(120, 100%, 40%);">+#define ao2_container_alloc(n_buckets, hash_fn, cmp_fn) \</span><br><span style="color: hsl(120, 100%, 40%);">+ ao2_container_alloc_hash(AO2_ALLOC_OPT_LOCK_MUTEX, 0, (n_buckets), (hash_fn), NULL, (cmp_fn))</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+#ifndef AST_IN_CORE</span><br><span style="color: hsl(120, 100%, 40%);">+/* These macros are removed from Asterisk 17. They are still available to modules</span><br><span style="color: hsl(120, 100%, 40%);">+ * but should only be used by third party modules that have not been updated. */</span><br><span> #define ao2_t_container_alloc_options(options, n_buckets, hash_fn, cmp_fn, tag) \</span><br><span> ao2_t_container_alloc_hash((options), 0, (n_buckets), (hash_fn), NULL, (cmp_fn), (tag))</span><br><span> #define ao2_container_alloc_options(options, n_buckets, hash_fn, cmp_fn) \</span><br><span> ao2_container_alloc_hash((options), 0, (n_buckets), (hash_fn), NULL, (cmp_fn))</span><br><span> </span><br><span> #define ao2_t_container_alloc(n_buckets, hash_fn, cmp_fn, tag) \</span><br><span style="color: hsl(0, 100%, 40%);">- ao2_t_container_alloc_options(AO2_ALLOC_OPT_LOCK_MUTEX, (n_buckets), (hash_fn), (cmp_fn), (tag))</span><br><span style="color: hsl(0, 100%, 40%);">-#define ao2_container_alloc(n_buckets, hash_fn, cmp_fn) \</span><br><span style="color: hsl(0, 100%, 40%);">- ao2_container_alloc_options(AO2_ALLOC_OPT_LOCK_MUTEX, (n_buckets), (hash_fn), (cmp_fn))</span><br><span style="color: hsl(120, 100%, 40%);">+ ao2_t_container_alloc_hash(AO2_ALLOC_OPT_LOCK_MUTEX, 0, (n_buckets), (hash_fn), NULL, (cmp_fn), (tag))</span><br><span style="color: hsl(120, 100%, 40%);">+#endif</span><br><span> </span><br><span> /*!</span><br><span> * \brief Allocate and initialize a hash container with the desired number of buckets.</span><br><span>diff --git a/main/bridge.c b/main/bridge.c</span><br><span>index 2b347fd..db49180 100644</span><br><span>--- a/main/bridge.c</span><br><span>+++ b/main/bridge.c</span><br><span>@@ -4068,8 +4068,8 @@</span><br><span> struct ao2_container *channels;</span><br><span> struct ast_bridge_channel *iter;</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- channels = ao2_container_alloc_options(AO2_ALLOC_OPT_LOCK_NOLOCK,</span><br><span style="color: hsl(0, 100%, 40%);">- 13, channel_hash, channel_cmp);</span><br><span style="color: hsl(120, 100%, 40%);">+ channels = ao2_container_alloc_hash(AO2_ALLOC_OPT_LOCK_NOLOCK, 0,</span><br><span style="color: hsl(120, 100%, 40%);">+ 13, channel_hash, NULL, channel_cmp);</span><br><span> if (!channels) {</span><br><span> return NULL;</span><br><span> }</span><br><span>diff --git a/main/bucket.c b/main/bucket.c</span><br><span>index 07cd016..8f6eafa 100644</span><br><span>--- a/main/bucket.c</span><br><span>+++ b/main/bucket.c</span><br><span>@@ -649,8 +649,8 @@</span><br><span> return NULL;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- file->metadata = ao2_container_alloc_options(AO2_ALLOC_OPT_LOCK_NOLOCK, METADATA_BUCKETS,</span><br><span style="color: hsl(0, 100%, 40%);">- ast_bucket_metadata_hash_fn, ast_bucket_metadata_cmp_fn);</span><br><span style="color: hsl(120, 100%, 40%);">+ file->metadata = ao2_container_alloc_hash(AO2_ALLOC_OPT_LOCK_NOLOCK, 0, METADATA_BUCKETS,</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_bucket_metadata_hash_fn, NULL, ast_bucket_metadata_cmp_fn);</span><br><span> if (!file->metadata) {</span><br><span> return NULL;</span><br><span> }</span><br><span>@@ -954,8 +954,8 @@</span><br><span> {</span><br><span> ast_register_cleanup(&bucket_cleanup);</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- schemes = ao2_container_alloc_options(AO2_ALLOC_OPT_LOCK_RWLOCK, SCHEME_BUCKETS,</span><br><span style="color: hsl(0, 100%, 40%);">- ast_bucket_scheme_hash_fn, ast_bucket_scheme_cmp_fn);</span><br><span style="color: hsl(120, 100%, 40%);">+ schemes = ao2_container_alloc_hash(AO2_ALLOC_OPT_LOCK_RWLOCK, 0, SCHEME_BUCKETS,</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_bucket_scheme_hash_fn, NULL, ast_bucket_scheme_cmp_fn);</span><br><span> if (!schemes) {</span><br><span> ast_log(LOG_ERROR, "Failed to create container for Bucket schemes\n");</span><br><span> return -1;</span><br><span>diff --git a/main/ccss.c b/main/ccss.c</span><br><span>index 9cf16e3..5758574 100644</span><br><span>--- a/main/ccss.c</span><br><span>+++ b/main/ccss.c</span><br><span>@@ -4649,14 +4649,19 @@</span><br><span> {</span><br><span> int res;</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- if (!(cc_core_instances = ao2_t_container_alloc(CC_CORE_INSTANCES_BUCKETS,</span><br><span style="color: hsl(0, 100%, 40%);">- cc_core_instance_hash_fn, cc_core_instance_cmp_fn,</span><br><span style="color: hsl(0, 100%, 40%);">- "Create core instance container"))) {</span><br><span style="color: hsl(120, 100%, 40%);">+ cc_core_instances = ao2_t_container_alloc_hash(AO2_ALLOC_OPT_LOCK_MUTEX, 0,</span><br><span style="color: hsl(120, 100%, 40%);">+ CC_CORE_INSTANCES_BUCKETS,</span><br><span style="color: hsl(120, 100%, 40%);">+ cc_core_instance_hash_fn, NULL, cc_core_instance_cmp_fn,</span><br><span style="color: hsl(120, 100%, 40%);">+ "Create core instance container");</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!cc_core_instances) {</span><br><span> return AST_MODULE_LOAD_FAILURE;</span><br><span> }</span><br><span style="color: hsl(0, 100%, 40%);">- if (!(generic_monitors = ao2_t_container_alloc(CC_CORE_INSTANCES_BUCKETS,</span><br><span style="color: hsl(0, 100%, 40%);">- generic_monitor_instance_list_hash_fn, generic_monitor_instance_list_cmp_fn,</span><br><span style="color: hsl(0, 100%, 40%);">- "Create generic monitor container"))) {</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ generic_monitors = ao2_t_container_alloc_hash(AO2_ALLOC_OPT_LOCK_MUTEX, 0,</span><br><span style="color: hsl(120, 100%, 40%);">+ CC_CORE_INSTANCES_BUCKETS,</span><br><span style="color: hsl(120, 100%, 40%);">+ generic_monitor_instance_list_hash_fn, NULL, generic_monitor_instance_list_cmp_fn,</span><br><span style="color: hsl(120, 100%, 40%);">+ "Create generic monitor container");</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!generic_monitors) {</span><br><span> return AST_MODULE_LOAD_FAILURE;</span><br><span> }</span><br><span> if (!(cc_core_taskprocessor = ast_taskprocessor_get("CCSS_core", TPS_REF_DEFAULT))) {</span><br><span>diff --git a/main/channel.c b/main/channel.c</span><br><span>index 2bacfa4..a72439c 100644</span><br><span>--- a/main/channel.c</span><br><span>+++ b/main/channel.c</span><br><span>@@ -7536,8 +7536,8 @@</span><br><span> return NULL;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- namedgroups = ao2_container_alloc_options(AO2_ALLOC_OPT_LOCK_NOLOCK, 19,</span><br><span style="color: hsl(0, 100%, 40%);">- namedgroup_hash_cb, namedgroup_cmp_cb);</span><br><span style="color: hsl(120, 100%, 40%);">+ namedgroups = ao2_container_alloc_hash(AO2_ALLOC_OPT_LOCK_NOLOCK, 0, 19,</span><br><span style="color: hsl(120, 100%, 40%);">+ namedgroup_hash_cb, NULL, namedgroup_cmp_cb);</span><br><span> if (!namedgroups) {</span><br><span> return NULL;</span><br><span> }</span><br><span>diff --git a/main/codec.c b/main/codec.c</span><br><span>index d6de072..32350f1 100644</span><br><span>--- a/main/codec.c</span><br><span>+++ b/main/codec.c</span><br><span>@@ -248,8 +248,8 @@</span><br><span> </span><br><span> int ast_codec_init(void)</span><br><span> {</span><br><span style="color: hsl(0, 100%, 40%);">- codecs = ao2_container_alloc_options(AO2_ALLOC_OPT_LOCK_RWLOCK, CODEC_BUCKETS,</span><br><span style="color: hsl(0, 100%, 40%);">- ast_codec_hash_fn, codec_cmp);</span><br><span style="color: hsl(120, 100%, 40%);">+ codecs = ao2_container_alloc_hash(AO2_ALLOC_OPT_LOCK_RWLOCK, 0, CODEC_BUCKETS,</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_codec_hash_fn, NULL, codec_cmp);</span><br><span> if (!codecs) {</span><br><span> return -1;</span><br><span> }</span><br><span>diff --git a/main/features_config.c b/main/features_config.c</span><br><span>index f116e89..c74d849 100644</span><br><span>--- a/main/features_config.c</span><br><span>+++ b/main/features_config.c</span><br><span>@@ -759,8 +759,8 @@</span><br><span> return NULL;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- cfg->featuregroups = ao2_container_alloc_options(AO2_ALLOC_OPT_LOCK_NOLOCK, 11, featuregroup_hash,</span><br><span style="color: hsl(0, 100%, 40%);">- featuregroup_cmp);</span><br><span style="color: hsl(120, 100%, 40%);">+ cfg->featuregroups = ao2_container_alloc_hash(AO2_ALLOC_OPT_LOCK_NOLOCK, 0, 11,</span><br><span style="color: hsl(120, 100%, 40%);">+ featuregroup_hash, NULL, featuregroup_cmp);</span><br><span> if (!cfg->featuregroups) {</span><br><span> return NULL;</span><br><span> }</span><br><span>diff --git a/main/format.c b/main/format.c</span><br><span>index 5ba9ffe..f0da43c 100644</span><br><span>--- a/main/format.c</span><br><span>+++ b/main/format.c</span><br><span>@@ -76,8 +76,8 @@</span><br><span> </span><br><span> int ast_format_init(void)</span><br><span> {</span><br><span style="color: hsl(0, 100%, 40%);">- interfaces = ao2_container_alloc_options(AO2_ALLOC_OPT_LOCK_RWLOCK, FORMAT_INTERFACE_BUCKETS,</span><br><span style="color: hsl(0, 100%, 40%);">- format_interface_hash_fn, format_interface_cmp_fn);</span><br><span style="color: hsl(120, 100%, 40%);">+ interfaces = ao2_container_alloc_hash(AO2_ALLOC_OPT_LOCK_RWLOCK, 0,</span><br><span style="color: hsl(120, 100%, 40%);">+ FORMAT_INTERFACE_BUCKETS, format_interface_hash_fn, NULL, format_interface_cmp_fn);</span><br><span> if (!interfaces) {</span><br><span> return -1;</span><br><span> }</span><br><span>diff --git a/main/format_cache.c b/main/format_cache.c</span><br><span>index db0d9b9..95ad5ea 100644</span><br><span>--- a/main/format_cache.c</span><br><span>+++ b/main/format_cache.c</span><br><span>@@ -363,8 +363,8 @@</span><br><span> </span><br><span> int ast_format_cache_init(void)</span><br><span> {</span><br><span style="color: hsl(0, 100%, 40%);">- formats = ao2_container_alloc_options(AO2_ALLOC_OPT_LOCK_RWLOCK, CACHE_BUCKETS,</span><br><span style="color: hsl(0, 100%, 40%);">- format_hash_cb, format_cmp_cb);</span><br><span style="color: hsl(120, 100%, 40%);">+ formats = ao2_container_alloc_hash(AO2_ALLOC_OPT_LOCK_RWLOCK, 0, CACHE_BUCKETS,</span><br><span style="color: hsl(120, 100%, 40%);">+ format_hash_cb, NULL, format_cmp_cb);</span><br><span> if (!formats) {</span><br><span> return -1;</span><br><span> }</span><br><span>diff --git a/main/media_cache.c b/main/media_cache.c</span><br><span>index e0a6dbb..97a80d5 100644</span><br><span>--- a/main/media_cache.c</span><br><span>+++ b/main/media_cache.c</span><br><span>@@ -697,8 +697,8 @@</span><br><span> {</span><br><span> ast_register_cleanup(media_cache_shutdown);</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- media_cache = ao2_container_alloc_options(AO2_ALLOC_OPT_LOCK_MUTEX, AO2_BUCKETS,</span><br><span style="color: hsl(0, 100%, 40%);">- ast_sorcery_object_id_hash, ast_sorcery_object_id_compare);</span><br><span style="color: hsl(120, 100%, 40%);">+ media_cache = ao2_container_alloc_hash(AO2_ALLOC_OPT_LOCK_MUTEX, 0, AO2_BUCKETS,</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_sorcery_object_id_hash, NULL, ast_sorcery_object_id_compare);</span><br><span> if (!media_cache) {</span><br><span> return -1;</span><br><span> }</span><br><span>diff --git a/main/pbx.c b/main/pbx.c</span><br><span>index 727018b..f961295 100644</span><br><span>--- a/main/pbx.c</span><br><span>+++ b/main/pbx.c</span><br><span>@@ -3054,7 +3054,7 @@</span><br><span> </span><br><span> static struct ao2_container *alloc_device_state_info(void)</span><br><span> {</span><br><span style="color: hsl(0, 100%, 40%);">- return ao2_container_alloc_options(AO2_ALLOC_OPT_LOCK_NOLOCK, 1, NULL, NULL);</span><br><span style="color: hsl(120, 100%, 40%);">+ return ao2_container_alloc_list(AO2_ALLOC_OPT_LOCK_NOLOCK, 0, NULL, NULL);</span><br><span> }</span><br><span> </span><br><span> static int ast_extension_state3(struct ast_str *hint_app, struct ao2_container *device_state_info)</span><br><span>@@ -8916,8 +8916,8 @@</span><br><span> ao2_container_register("hintdevices", hintdevices, print_hintdevices_key);</span><br><span> }</span><br><span> /* This is protected by the context_and_merge lock */</span><br><span style="color: hsl(0, 100%, 40%);">- autohints = ao2_container_alloc_options(AO2_ALLOC_OPT_LOCK_NOLOCK, HASH_EXTENHINT_SIZE,</span><br><span style="color: hsl(0, 100%, 40%);">- autohint_hash_cb, autohint_cmp);</span><br><span style="color: hsl(120, 100%, 40%);">+ autohints = ao2_container_alloc_hash(AO2_ALLOC_OPT_LOCK_NOLOCK, 0, HASH_EXTENHINT_SIZE,</span><br><span style="color: hsl(120, 100%, 40%);">+ autohint_hash_cb, NULL, autohint_cmp);</span><br><span> if (autohints) {</span><br><span> ao2_container_register("autohints", autohints, print_autohint_key);</span><br><span> }</span><br><span>diff --git a/main/pickup.c b/main/pickup.c</span><br><span>index f0936dd..484f98b 100644</span><br><span>--- a/main/pickup.c</span><br><span>+++ b/main/pickup.c</span><br><span>@@ -135,7 +135,7 @@</span><br><span> struct ao2_container *candidates;/*!< Candidate channels found to pickup. */</span><br><span> struct ast_channel *target;/*!< Potential pickup target */</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- candidates = ao2_container_alloc_options(AO2_ALLOC_OPT_LOCK_NOLOCK, 1, NULL, NULL);</span><br><span style="color: hsl(120, 100%, 40%);">+ candidates = ao2_container_alloc_list(AO2_ALLOC_OPT_LOCK_NOLOCK, 0, NULL, NULL);</span><br><span> if (!candidates) {</span><br><span> return NULL;</span><br><span> }</span><br><span>diff --git a/main/sorcery.c b/main/sorcery.c</span><br><span>index 9028707..beaad21 100644</span><br><span>--- a/main/sorcery.c</span><br><span>+++ b/main/sorcery.c</span><br><span>@@ -621,8 +621,8 @@</span><br><span> goto failure_cleanup;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- sorcery->types = ao2_container_alloc_options(AO2_ALLOC_OPT_LOCK_RWLOCK, TYPE_BUCKETS,</span><br><span style="color: hsl(0, 100%, 40%);">- ast_sorcery_object_type_hash_fn, ast_sorcery_object_type_cmp_fn);</span><br><span style="color: hsl(120, 100%, 40%);">+ sorcery->types = ao2_container_alloc_hash(AO2_ALLOC_OPT_LOCK_RWLOCK, 0, TYPE_BUCKETS,</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_sorcery_object_type_hash_fn, NULL, ast_sorcery_object_type_cmp_fn);</span><br><span> if (!sorcery->types) {</span><br><span> goto failure_cleanup;</span><br><span> }</span><br><span>@@ -1792,7 +1792,8 @@</span><br><span> </span><br><span> /* If returning multiple objects create a container to store them in */</span><br><span> if ((flags & AST_RETRIEVE_FLAG_MULTIPLE)) {</span><br><span style="color: hsl(0, 100%, 40%);">- if (!(object = ao2_container_alloc_options(AO2_ALLOC_OPT_LOCK_NOLOCK, 1, NULL, NULL))) {</span><br><span style="color: hsl(120, 100%, 40%);">+ object = ao2_container_alloc_list(AO2_ALLOC_OPT_LOCK_NOLOCK, 0, NULL, NULL);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!object) {</span><br><span> return NULL;</span><br><span> }</span><br><span> }</span><br><span>@@ -1836,7 +1837,12 @@</span><br><span> struct ao2_container *objects;</span><br><span> int i;</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- if (!object_type || !(objects = ao2_container_alloc_options(AO2_ALLOC_OPT_LOCK_NOLOCK, 1, NULL, NULL))) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!object_type) {</span><br><span style="color: hsl(120, 100%, 40%);">+ return NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ objects = ao2_container_alloc_list(AO2_ALLOC_OPT_LOCK_NOLOCK, 0, NULL, NULL);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!objects) {</span><br><span> return NULL;</span><br><span> }</span><br><span> </span><br><span>@@ -1866,7 +1872,12 @@</span><br><span> struct ao2_container *objects;</span><br><span> int i;</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- if (!object_type || !(objects = ao2_container_alloc_options(AO2_ALLOC_OPT_LOCK_NOLOCK, 1, NULL, NULL))) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!object_type) {</span><br><span style="color: hsl(120, 100%, 40%);">+ return NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ objects = ao2_container_alloc_list(AO2_ALLOC_OPT_LOCK_NOLOCK, 0, NULL, NULL);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!objects) {</span><br><span> return NULL;</span><br><span> }</span><br><span> </span><br><span>diff --git a/res/res_musiconhold.c b/res/res_musiconhold.c</span><br><span>index 5c739ab..d14e209 100644</span><br><span>--- a/res/res_musiconhold.c</span><br><span>+++ b/res/res_musiconhold.c</span><br><span>@@ -2005,7 +2005,9 @@</span><br><span> {</span><br><span> int res;</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- if (!(mohclasses = ao2_t_container_alloc(53, moh_class_hash, moh_class_cmp, "Moh class container"))) {</span><br><span style="color: hsl(120, 100%, 40%);">+ mohclasses = ao2_t_container_alloc_hash(AO2_ALLOC_OPT_LOCK_MUTEX, 0, 53,</span><br><span style="color: hsl(120, 100%, 40%);">+ moh_class_hash, NULL, moh_class_cmp, "Moh class container");</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!mohclasses) {</span><br><span> return AST_MODULE_LOAD_DECLINE;</span><br><span> }</span><br><span> </span><br><span>diff --git a/res/res_pjsip_notify.c b/res/res_pjsip_notify.c</span><br><span>index 98a75c9..35144fe 100644</span><br><span>--- a/res/res_pjsip_notify.c</span><br><span>+++ b/res/res_pjsip_notify.c</span><br><span>@@ -226,9 +226,9 @@</span><br><span> return NULL;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- if (!(cfg->notify_options = ao2_container_alloc_options(</span><br><span style="color: hsl(0, 100%, 40%);">- AO2_ALLOC_OPT_LOCK_NOLOCK, 20, notify_option_hash,</span><br><span style="color: hsl(0, 100%, 40%);">- notify_option_cmp))) {</span><br><span style="color: hsl(120, 100%, 40%);">+ cfg->notify_options = ao2_container_alloc_hash(AO2_ALLOC_OPT_LOCK_NOLOCK, 0,</span><br><span style="color: hsl(120, 100%, 40%);">+ 20, notify_option_hash, NULL, notify_option_cmp);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!cfg->notify_options) {</span><br><span> ao2_cleanup(cfg);</span><br><span> return NULL;</span><br><span> }</span><br><span>diff --git a/res/res_pjsip_outbound_publish.c b/res/res_pjsip_outbound_publish.c</span><br><span>index 4894e55..e4e9fd4 100644</span><br><span>--- a/res/res_pjsip_outbound_publish.c</span><br><span>+++ b/res/res_pjsip_outbound_publish.c</span><br><span>@@ -1555,9 +1555,9 @@</span><br><span> * object if created/updated, or keep the old object if an error occurs.</span><br><span> */</span><br><span> if (!new_states) {</span><br><span style="color: hsl(0, 100%, 40%);">- new_states = ao2_container_alloc_options(</span><br><span style="color: hsl(0, 100%, 40%);">- AO2_ALLOC_OPT_LOCK_NOLOCK, DEFAULT_STATE_BUCKETS,</span><br><span style="color: hsl(0, 100%, 40%);">- outbound_publish_state_hash, outbound_publish_state_cmp);</span><br><span style="color: hsl(120, 100%, 40%);">+ new_states = ao2_container_alloc_hash(</span><br><span style="color: hsl(120, 100%, 40%);">+ AO2_ALLOC_OPT_LOCK_NOLOCK, 0, DEFAULT_STATE_BUCKETS,</span><br><span style="color: hsl(120, 100%, 40%);">+ outbound_publish_state_hash, NULL, outbound_publish_state_cmp);</span><br><span> </span><br><span> if (!new_states) {</span><br><span> ast_log(LOG_ERROR, "Unable to allocate new states container\n");</span><br><span>diff --git a/res/res_sorcery_memory_cache.c b/res/res_sorcery_memory_cache.c</span><br><span>index 30e6ef0..9a1ade0 100644</span><br><span>--- a/res/res_sorcery_memory_cache.c</span><br><span>+++ b/res/res_sorcery_memory_cache.c</span><br><span>@@ -1556,9 +1556,9 @@</span><br><span> }</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- cache->objects = ao2_container_alloc_options(AO2_ALLOC_OPT_LOCK_RWLOCK,</span><br><span style="color: hsl(120, 100%, 40%);">+ cache->objects = ao2_container_alloc_hash(AO2_ALLOC_OPT_LOCK_RWLOCK, 0,</span><br><span> cache->maximum_objects ? cache->maximum_objects : CACHE_CONTAINER_BUCKET_SIZE,</span><br><span style="color: hsl(0, 100%, 40%);">- sorcery_memory_cached_object_hash, sorcery_memory_cached_object_cmp);</span><br><span style="color: hsl(120, 100%, 40%);">+ sorcery_memory_cached_object_hash, NULL, sorcery_memory_cached_object_cmp);</span><br><span> if (!cache->objects) {</span><br><span> ast_log(LOG_ERROR, "Could not create a container to hold cached objects for memory cache\n");</span><br><span> return NULL;</span><br><span>diff --git a/res/res_srtp.c b/res/res_srtp.c</span><br><span>index bebcbe6..06d5188 100644</span><br><span>--- a/res/res_srtp.c</span><br><span>+++ b/res/res_srtp.c</span><br><span>@@ -194,7 +194,9 @@</span><br><span> return NULL;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- if (!(srtp->policies = ao2_t_container_alloc(5, policy_hash_fn, policy_cmp_fn, "SRTP policy container"))) {</span><br><span style="color: hsl(120, 100%, 40%);">+ srtp->policies = ao2_t_container_alloc_hash(AO2_ALLOC_OPT_LOCK_MUTEX, 0, 5,</span><br><span style="color: hsl(120, 100%, 40%);">+ policy_hash_fn, NULL, policy_cmp_fn, "SRTP policy container");</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!srtp->policies) {</span><br><span> ast_free(srtp);</span><br><span> return NULL;</span><br><span> }</span><br><span>diff --git a/tests/test_astobj2.c b/tests/test_astobj2.c</span><br><span>index 3158a66..4abe28a 100644</span><br><span>--- a/tests/test_astobj2.c</span><br><span>+++ b/tests/test_astobj2.c</span><br><span>@@ -456,7 +456,7 @@</span><br><span> test_sort_cb, test_cmp_cb, "test");</span><br><span> break;</span><br><span> }</span><br><span style="color: hsl(0, 100%, 40%);">- c2 = ao2_t_container_alloc(1, NULL, NULL, "test");</span><br><span style="color: hsl(120, 100%, 40%);">+ c2 = ao2_t_container_alloc_list(AO2_ALLOC_OPT_LOCK_MUTEX, 0, NULL, NULL, "test");</span><br><span> </span><br><span> if (!c1 || !c2) {</span><br><span> ast_test_status_update(test, "ao2_container_alloc failed.\n");</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/10504">change 10504</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/10504"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 16 </div>
<div style="display:none"> Gerrit-MessageType: merged </div>
<div style="display:none"> Gerrit-Change-Id: I1a26258b5bf3deb081aaeed11a0baa175c933c7a </div>
<div style="display:none"> Gerrit-Change-Number: 10504 </div>
<div style="display:none"> Gerrit-PatchSet: 3 </div>
<div style="display:none"> Gerrit-Owner: Corey Farrell <git@cfware.com> </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins2 (1000185) </div>
<div style="display:none"> Gerrit-Reviewer: Richard Mudgett <rmudgett@digium.com> </div>