[Asterisk-code-review] core: Disable astobj2 locking for some common objects. (asterisk[master])
Corey Farrell
asteriskteam at digium.com
Tue Oct 2 14:44:20 CDT 2018
Corey Farrell has uploaded this change for review. ( https://gerrit.asterisk.org/10378
Change subject: core: Disable astobj2 locking for some common objects.
......................................................................
core: Disable astobj2 locking for some common objects.
Create ao2_alloc_nolock and ao2_t_alloc_nolock. Use it in some places
that allocate many objects that are never locked:
* 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 include/asterisk/astobj2.h
M main/config_options.c
M main/indications.c
M main/loader.c
M main/media_index.c
M main/xmldoc.c
6 files changed, 17 insertions(+), 7 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/78/10378/1
diff --git a/include/asterisk/astobj2.h b/include/asterisk/astobj2.h
index 8e3a105..47331b2 100644
--- a/include/asterisk/astobj2.h
+++ b/include/asterisk/astobj2.h
@@ -405,6 +405,11 @@
#define ao2_alloc_options(data_size, destructor_fn, options) \
__ao2_alloc((data_size), (destructor_fn), (options), "", __FILE__, __LINE__, __PRETTY_FUNCTION__)
+#define ao2_alloc_nolock(data_size, destructor_fn) \
+ __ao2_alloc((data_size), (destructor_fn), AO2_ALLOC_OPT_LOCK_NOLOCK, "", __FILE__, __LINE__, __PRETTY_FUNCTION__)
+#define ao2_t_alloc_nolock(data_size, destructor_fn, tag) \
+ __ao2_alloc((data_size), (destructor_fn), AO2_ALLOC_OPT_LOCK_NOLOCK, (tag), __FILE__, __LINE__, __PRETTY_FUNCTION__)
+
#define ao2_t_alloc(data_size, destructor_fn, debug_msg) \
__ao2_alloc((data_size), (destructor_fn), AO2_ALLOC_OPT_LOCK_MUTEX, (debug_msg), __FILE__, __LINE__, __PRETTY_FUNCTION__)
#define ao2_alloc(data_size, destructor_fn) \
diff --git a/main/config_options.c b/main/config_options.c
index 41c8b22..6b79541 100644
--- a/main/config_options.c
+++ b/main/config_options.c
@@ -222,7 +222,8 @@
return -1;
}
- if (!(opt = ao2_alloc(sizeof(*opt), config_option_destroy))) {
+ opt = ao2_alloc_nolock(sizeof(*opt), config_option_destroy);
+ if (!opt) {
return -1;
}
@@ -313,7 +314,8 @@
return -1;
}
- if (!(opt = ao2_alloc(sizeof(*opt) + argc * sizeof(opt->args[0]), config_option_destroy))) {
+ opt = ao2_alloc_nolock(sizeof(*opt) + argc * sizeof(opt->args[0]), config_option_destroy);
+ if (!opt) {
return -1;
}
diff --git a/main/indications.c b/main/indications.c
index 6a7414d..ea9af46 100644
--- a/main/indications.c
+++ b/main/indications.c
@@ -588,7 +588,8 @@
}
AST_LIST_TRAVERSE_SAFE_END;
- if (!(ts = ao2_alloc(sizeof(*ts), ast_tone_zone_sound_destructor))) {
+ ts = ao2_alloc_nolock(sizeof(*ts), ast_tone_zone_sound_destructor);
+ if (!ts) {
return -1;
}
diff --git a/main/loader.c b/main/loader.c
index eb345b5..ea94607 100644
--- a/main/loader.c
+++ b/main/loader.c
@@ -554,7 +554,7 @@
mod->info = info;
if (ast_opt_ref_debug) {
- mod->ref_debug = ao2_t_alloc(0, NULL, info->name);
+ mod->ref_debug = ao2_t_alloc_nolock(0, NULL, info->name);
}
AST_LIST_HEAD_INIT(&mod->users);
AST_VECTOR_INIT(&mod->requires, 0);
diff --git a/main/media_index.c b/main/media_index.c
index 72bc1cc..00e6d24 100644
--- a/main/media_index.c
+++ b/main/media_index.c
@@ -64,7 +64,7 @@
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_nolock(sizeof(*variant) + str_sz, media_variant_destroy);
if (!variant) {
return NULL;
}
@@ -110,8 +110,9 @@
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_nolock(sizeof(*info) + name_sz, media_info_destroy);
if (!info) {
return NULL;
}
diff --git a/main/xmldoc.c b/main/xmldoc.c
index b4649ac..f9e5cf0 100644
--- a/main/xmldoc.c
+++ b/main/xmldoc.c
@@ -2290,7 +2290,8 @@
{
struct ast_xml_doc_item *item;
- if (!(item = ao2_alloc(sizeof(*item), ast_xml_doc_item_destructor))) {
+ item = ao2_alloc_nolock(sizeof(*item), ast_xml_doc_item_destructor);
+ 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/10378
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie999b9941760be3d1946cdb6e30cb85fd97504d8
Gerrit-Change-Number: 10378
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/20181002/73de00dd/attachment-0001.html>
More information about the asterisk-code-review
mailing list