diff options
author | Corey Farrell <git@cfware.com> | 2015-04-17 03:16:59 -0400 |
---|---|---|
committer | Corey Farrell <git@cfware.com> | 2015-04-27 18:37:26 -0400 |
commit | 5c1d07baf083fd791c8f717209551d9227413ef7 (patch) | |
tree | 7eff8c651efb82e89fd7918038102b84fe888ced /res/res_musiconhold.c | |
parent | d7f4788341f08f386341416aa3944c7f9bc0dc1b (diff) |
Astobj2: Allow reference debugging to be enabled/disabled by config.
* The REF_DEBUG compiler flag no longer has any effect on code that uses
Astobj2. It is used to determine if reference debugging is enabled by
default. Reference debugging can be enabled or disabled in asterisk.conf.
* Caller information is provided in logger errors for ao2 bad magic numbers.
* Optimizes AO2 by merging internal functions with the public counterpart.
This was possible now that we no longer require a dual ABI.
ASTERISK-24974 #close
Reported by: Corey Farrell
Change-Id: Icf3552721fe999365ba8a8cf00a965aa6b897cc1
Diffstat (limited to 'res/res_musiconhold.c')
-rw-r--r-- | res/res_musiconhold.c | 26 |
1 files changed, 7 insertions, 19 deletions
diff --git a/res/res_musiconhold.c b/res/res_musiconhold.c index 24a3a280f..eaf1f4ea8 100644 --- a/res/res_musiconhold.c +++ b/res/res_musiconhold.c @@ -210,7 +210,7 @@ static int reload(void); #define mohclass_ref(class,string) (ao2_t_ref((class), +1, (string)), class) -#ifndef REF_DEBUG +#ifndef AST_DEVMODE #define mohclass_unref(class,string) ({ ao2_t_ref((class), -1, (string)); (struct mohclass *) NULL; }) #else #define mohclass_unref(class,string) _mohclass_unref(class, string, __FILE__,__LINE__,__PRETTY_FUNCTION__) @@ -219,14 +219,14 @@ static struct mohclass *_mohclass_unref(struct mohclass *class, const char *tag, struct mohclass *dup = ao2_callback(mohclasses, OBJ_POINTER, ao2_match_by_addr, class); if (dup) { - if (__ao2_ref_debug(dup, -1, (char *) tag, (char *) file, line, funcname) == 2) { + if (__ao2_ref(dup, -1, tag, file, line, funcname) == 2) { ast_log(LOG_WARNING, "Attempt to unref mohclass %p (%s) when only 1 ref remained, and class is still in a container! (at %s:%d (%s))\n", class, class->name, file, line, funcname); } else { ao2_ref(class, -1); } } else { - __ao2_ref_debug(class, -1, (char *) tag, (char *) file, line, funcname); + __ao2_ref(class, -1, tag, file, line, funcname); } return NULL; } @@ -877,12 +877,8 @@ static struct mohclass *_get_mohbyname(const char *name, int warn, int flags, co ast_copy_string(tmp_class.name, name, sizeof(tmp_class.name)); -#ifdef REF_DEBUG - moh = __ao2_find_debug(mohclasses, &tmp_class, flags, + moh = __ao2_find(mohclasses, &tmp_class, flags, "get_mohbyname", file, lineno, funcname); -#else - moh = __ao2_find(mohclasses, &tmp_class, flags); -#endif if (!moh && warn) { ast_debug(1, "Music on Hold class '%s' not found in memory\n", name); @@ -1373,17 +1369,9 @@ static struct mohclass *_moh_class_malloc(const char *file, int line, const char { struct mohclass *class; - if ((class = -#ifdef REF_DEBUG - __ao2_alloc_debug(sizeof(*class), moh_class_destructor, - AO2_ALLOC_OPT_LOCK_MUTEX, "Allocating new moh class", file, line, funcname, 1) -#elif defined(__AST_DEBUG_MALLOC) - __ao2_alloc_debug(sizeof(*class), moh_class_destructor, - AO2_ALLOC_OPT_LOCK_MUTEX, "Allocating new moh class", file, line, funcname, 0) -#else - ao2_alloc(sizeof(*class), moh_class_destructor) -#endif - )) { + class = __ao2_alloc(sizeof(*class), moh_class_destructor, AO2_ALLOC_OPT_LOCK_MUTEX, + "Allocating new moh class", file, line, funcname); + if (class) { class->format = ao2_bump(ast_format_slin); class->srcfd = -1; } |