[Asterisk-code-review] core: Fix ABI mismatch of ao2_global_obj. (...asterisk[13])
Corey Farrell
asteriskteam at digium.com
Tue Sep 24 11:24:04 CDT 2019
Corey Farrell has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/12944
Change subject: core: Fix ABI mismatch of ao2_global_obj.
......................................................................
core: Fix ABI mismatch of ao2_global_obj.
astobj2.c declares DEBUG_THREADS_LOOSE_ABI to avoid overhead of debug
threads tracking information in the internal structures of astobj2.
Unfortunately this means that ao2_global_obj contains the statically
allocated debug threads tracking fields which are used by initialization
and cleanup but main/astobj2.c believed those fields and associated
space did not exist.
Change-Id: Icef41ad97d88a8c1d1515e034ec8133cab3b1527
---
M main/astobj2.c
A main/astobj2_global.c
2 files changed, 114 insertions(+), 83 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/44/12944/1
diff --git a/main/astobj2.c b/main/astobj2.c
index 8d8f17e..cc835ec 100644
--- a/main/astobj2.c
+++ b/main/astobj2.c
@@ -638,89 +638,6 @@
}
-void __ao2_global_obj_release(struct ao2_global_obj *holder, const char *tag, const char *file, int line, const char *func, const char *name)
-{
- __ao2_global_obj_replace_unref(holder, NULL, tag, file, line, func, name);
-}
-
-void *__ao2_global_obj_replace(struct ao2_global_obj *holder, void *obj, const char *tag, const char *file, int line, const char *func, const char *name)
-{
- void *obj_old;
-
- if (!holder) {
- /* For sanity */
- ast_log(LOG_ERROR, "Must be called with a global object!\n");
- ast_assert(0);
- return NULL;
- }
- if (__ast_rwlock_wrlock(file, line, func, &holder->lock, name)) {
- /* Could not get the write lock. */
- ast_assert(0);
- return NULL;
- }
-
- if (obj) {
- if (tag) {
- __ao2_ref_debug(obj, +1, tag, file, line, func);
- } else {
- __ao2_ref(obj, +1);
- }
- }
- obj_old = holder->obj;
- holder->obj = obj;
-
- __ast_rwlock_unlock(file, line, func, &holder->lock, name);
-
- return obj_old;
-}
-
-int __ao2_global_obj_replace_unref(struct ao2_global_obj *holder, void *obj, const char *tag, const char *file, int line, const char *func, const char *name)
-{
- void *obj_old;
-
- obj_old = __ao2_global_obj_replace(holder, obj, tag, file, line, func, name);
- if (obj_old) {
- if (tag) {
- __ao2_ref_debug(obj_old, -1, tag, file, line, func);
- } else {
- __ao2_ref(obj_old, -1);
- }
- return 1;
- }
- return 0;
-}
-
-void *__ao2_global_obj_ref(struct ao2_global_obj *holder, const char *tag, const char *file, int line, const char *func, const char *name)
-{
- void *obj;
-
- if (!holder) {
- /* For sanity */
- ast_log(LOG_ERROR, "Must be called with a global object!\n");
- ast_assert(0);
- return NULL;
- }
-
- if (__ast_rwlock_rdlock(file, line, func, &holder->lock, name)) {
- /* Could not get the read lock. */
- ast_assert(0);
- return NULL;
- }
-
- obj = holder->obj;
- if (obj) {
- if (tag) {
- __ao2_ref_debug(obj, +1, tag, file, line, func);
- } else {
- __ao2_ref(obj, +1);
- }
- }
-
- __ast_rwlock_unlock(file, line, func, &holder->lock, name);
-
- return obj;
-}
-
#ifdef AO2_DEBUG
static int print_cb(void *obj, void *arg, int flag)
{
diff --git a/main/astobj2_global.c b/main/astobj2_global.c
new file mode 100644
index 0000000..b4d031f
--- /dev/null
+++ b/main/astobj2_global.c
@@ -0,0 +1,114 @@
+/*
+ * astobj2_global - global containers for AO2 objects.
+ *
+ * Copyright (C) 2006 Marta Carbone, Luigi Rizzo - Univ. di Pisa, Italy
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE file
+ * at the top of the source tree.
+ */
+
+/*! \file
+ *
+ * \brief Functions implementing ao2_global_obj routines.
+ *
+ * \author Richard Mudgett <rmudgett at digium.com>
+ */
+
+/*** MODULEINFO
+ <support_level>core</support_level>
+ ***/
+
+#include "asterisk.h"
+
+#include "asterisk/astobj2.h"
+#include "asterisk/utils.h"
+
+void __ao2_global_obj_release(struct ao2_global_obj *holder, const char *tag, const char *file, int line, const char *func, const char *name)
+{
+ __ao2_global_obj_replace_unref(holder, NULL, tag, file, line, func, name);
+}
+
+void *__ao2_global_obj_replace(struct ao2_global_obj *holder, void *obj, const char *tag, const char *file, int line, const char *func, const char *name)
+{
+ void *obj_old;
+
+ if (!holder) {
+ /* For sanity */
+ ast_log(LOG_ERROR, "Must be called with a global object!\n");
+ ast_assert(0);
+ return NULL;
+ }
+ if (__ast_rwlock_wrlock(file, line, func, &holder->lock, name)) {
+ /* Could not get the write lock. */
+ ast_assert(0);
+ return NULL;
+ }
+
+ if (obj) {
+ if (tag) {
+ __ao2_ref_debug(obj, +1, tag, file, line, func);
+ } else {
+ __ao2_ref(obj, +1);
+ }
+ }
+ obj_old = holder->obj;
+ holder->obj = obj;
+
+ __ast_rwlock_unlock(file, line, func, &holder->lock, name);
+
+ return obj_old;
+}
+
+int __ao2_global_obj_replace_unref(struct ao2_global_obj *holder, void *obj, const char *tag, const char *file, int line, const char *func, const char *name)
+{
+ void *obj_old;
+
+ obj_old = __ao2_global_obj_replace(holder, obj, tag, file, line, func, name);
+ if (obj_old) {
+ if (tag) {
+ __ao2_ref_debug(obj_old, -1, tag, file, line, func);
+ } else {
+ __ao2_ref(obj_old, -1);
+ }
+ return 1;
+ }
+ return 0;
+}
+
+void *__ao2_global_obj_ref(struct ao2_global_obj *holder, const char *tag, const char *file, int line, const char *func, const char *name)
+{
+ void *obj;
+
+ if (!holder) {
+ /* For sanity */
+ ast_log(LOG_ERROR, "Must be called with a global object!\n");
+ ast_assert(0);
+ return NULL;
+ }
+
+ if (__ast_rwlock_rdlock(file, line, func, &holder->lock, name)) {
+ /* Could not get the read lock. */
+ ast_assert(0);
+ return NULL;
+ }
+
+ obj = holder->obj;
+ if (obj) {
+ if (tag) {
+ __ao2_ref_debug(obj, +1, tag, file, line, func);
+ } else {
+ __ao2_ref(obj, +1);
+ }
+ }
+
+ __ast_rwlock_unlock(file, line, func, &holder->lock, name);
+
+ return obj;
+}
--
To view, visit https://gerrit.asterisk.org/c/asterisk/+/12944
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-Change-Id: Icef41ad97d88a8c1d1515e034ec8133cab3b1527
Gerrit-Change-Number: 12944
Gerrit-PatchSet: 1
Gerrit-Owner: Corey Farrell <git at cfware.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20190924/a4a040a4/attachment-0001.html>
More information about the asterisk-code-review
mailing list