[Asterisk-code-review] core: Disable astobj2 locking for some common objects. (asterisk[13])

Corey Farrell asteriskteam at digium.com
Wed Oct 3 03:24:33 CDT 2018


Corey Farrell has uploaded this change for review. ( https://gerrit.asterisk.org/10393


Change subject: core: Disable astobj2 locking for some common objects.
......................................................................

core: Disable astobj2 locking for some common objects.

* ACO options
* Indications
* Module loader ref_debug object
* Media index info and variants
* xmldoc items

These allocation locations were identified using reflocks.py on the
master branch.

Change-Id: Ie999b9941760be3d1946cdb6e30cb85fd97504d8
---
M main/config_options.c
M main/indications.c
M main/loader.c
M main/media_index.c
M main/xmldoc.c
5 files changed, 17 insertions(+), 7 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/93/10393/1

diff --git a/main/config_options.c b/main/config_options.c
index c78f95d..f8b2be8 100644
--- a/main/config_options.c
+++ b/main/config_options.c
@@ -224,7 +224,8 @@
 		return -1;
 	}
 
-	if (!(opt = ao2_alloc(sizeof(*opt), config_option_destroy))) {
+	opt = ao2_alloc_options(sizeof(*opt), config_option_destroy, AO2_ALLOC_OPT_LOCK_NOLOCK);
+	if (!opt) {
 		return -1;
 	}
 
@@ -315,7 +316,9 @@
 		return -1;
 	}
 
-	if (!(opt = ao2_alloc(sizeof(*opt) + argc * sizeof(opt->args[0]), config_option_destroy))) {
+	opt = ao2_alloc_options(sizeof(*opt) + argc * sizeof(opt->args[0]),
+		config_option_destroy, AO2_ALLOC_OPT_LOCK_NOLOCK);
+	if (!opt) {
 		return -1;
 	}
 
diff --git a/main/indications.c b/main/indications.c
index 13e968f..e0ba59b 100644
--- a/main/indications.c
+++ b/main/indications.c
@@ -604,7 +604,9 @@
 	}
 	AST_LIST_TRAVERSE_SAFE_END;
 
-	if (!(ts = ao2_alloc(sizeof(*ts), ast_tone_zone_sound_destructor))) {
+	ts = ao2_alloc_options(sizeof(*ts), ast_tone_zone_sound_destructor,
+		AO2_ALLOC_OPT_LOCK_NOLOCK);
+	if (!ts) {
 		return -1;
 	}
 
diff --git a/main/loader.c b/main/loader.c
index 30a9832..3ac0ad5 100644
--- a/main/loader.c
+++ b/main/loader.c
@@ -235,7 +235,7 @@
 
 	mod->info = info;
 #ifdef REF_DEBUG
-	mod->ref_debug = ao2_t_alloc(0, NULL, info->name);
+	mod->ref_debug = ao2_t_alloc_options(0, NULL, AO2_ALLOC_OPT_LOCK_NOLOCK, info->name);
 #endif
 	AST_LIST_HEAD_INIT(&mod->users);
 
diff --git a/main/media_index.c b/main/media_index.c
index 72bc1cc..bfaa580 100644
--- a/main/media_index.c
+++ b/main/media_index.c
@@ -64,7 +64,8 @@
 	size_t str_sz = strlen(variant_str) + 1;
 	struct media_variant *variant;
 
-	variant = ao2_alloc(sizeof(*variant) + str_sz, media_variant_destroy);
+	variant = ao2_alloc_options(sizeof(*variant) + str_sz, media_variant_destroy,
+		AO2_ALLOC_OPT_LOCK_NOLOCK);
 	if (!variant) {
 		return NULL;
 	}
@@ -110,8 +111,10 @@
 static struct media_info *media_info_alloc(const char *name)
 {
 	size_t name_sz = strlen(name) + 1;
-	struct media_info *info = ao2_alloc(sizeof(*info) + name_sz, media_info_destroy);
+	struct media_info *info;
 
+	info = ao2_alloc_options(sizeof(*info) + name_sz, media_info_destroy,
+		AO2_ALLOC_OPT_LOCK_NOLOCK);
 	if (!info) {
 		return NULL;
 	}
diff --git a/main/xmldoc.c b/main/xmldoc.c
index d242453..37b2861 100644
--- a/main/xmldoc.c
+++ b/main/xmldoc.c
@@ -2292,7 +2292,9 @@
 {
 	struct ast_xml_doc_item *item;
 
-	if (!(item = ao2_alloc(sizeof(*item), ast_xml_doc_item_destructor))) {
+	item = ao2_alloc_options(sizeof(*item), ast_xml_doc_item_destructor,
+		AO2_ALLOC_OPT_LOCK_NOLOCK);
+	if (!item) {
 		ast_log(AST_LOG_ERROR, "Failed to allocate memory for ast_xml_doc_item instance\n");
 		return NULL;
 	}

-- 
To view, visit https://gerrit.asterisk.org/10393
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie999b9941760be3d1946cdb6e30cb85fd97504d8
Gerrit-Change-Number: 10393
Gerrit-PatchSet: 1
Gerrit-Owner: Corey Farrell <git at cfware.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20181003/2203fd81/attachment.html>


More information about the asterisk-code-review mailing list