summaryrefslogtreecommitdiff
path: root/main/astobj2.c
diff options
context:
space:
mode:
authorCorey Farrell <git@cfware.com>2014-07-13 21:57:00 +0000
committerCorey Farrell <git@cfware.com>2014-07-13 21:57:00 +0000
commitfcdc4ad0bf5ef3661e6cb1fa7abd487efb23e46c (patch)
tree1fee74bc3fb6a286f2b46033287f6271f0d7c4ea /main/astobj2.c
parent3e245920d8063a6416ad542e9bb01b2c3f3b38df (diff)
astobj2: work around REF_DEBUG race which causes out of order log entries
* Update refcounter.py to use delta's to track the current reference count. * Use result from internal_ao2_ref to write old_refcount to refs_log. Review: https://reviewboard.asterisk.org/r/3756/ ........ Merged revisions 418504 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 418505 from http://svn.asterisk.org/svn/asterisk/branches/11 ........ Merged revisions 418506 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@418507 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/astobj2.c')
-rw-r--r--main/astobj2.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/main/astobj2.c b/main/astobj2.c
index 96b0cdbe5..d2592ecb5 100644
--- a/main/astobj2.c
+++ b/main/astobj2.c
@@ -498,14 +498,19 @@ static int internal_ao2_ref(void *user_data, int delta, const char *file, int li
int __ao2_ref_debug(void *user_data, int delta, const char *tag, const char *file, int line, const char *func)
{
struct astobj2 *obj = INTERNAL_OBJ(user_data);
+ int old_refcount = -1;
+
+ if (obj) {
+ old_refcount = internal_ao2_ref(user_data, delta, file, line, func);
+ }
if (ref_log && user_data) {
- if (obj && obj->priv_data.ref_counter + delta == 0) {
+ if (obj && old_refcount + delta == 0) {
fprintf(ref_log, "%p,%d,%d,%s,%d,%s,**destructor**,%s\n", user_data, delta, ast_get_tid(), file, line, func, tag);
fflush(ref_log);
} else if (delta != 0) {
fprintf(ref_log, "%p,%s%d,%d,%s,%d,%s,%d,%s\n", user_data, (delta < 0 ? "" : "+"),
- delta, ast_get_tid(), file, line, func, obj ? obj->priv_data.ref_counter : -1, tag);
+ delta, ast_get_tid(), file, line, func, old_refcount, tag);
fflush(ref_log);
}
}
@@ -513,10 +518,9 @@ int __ao2_ref_debug(void *user_data, int delta, const char *tag, const char *fil
if (obj == NULL) {
ast_log_backtrace();
ast_assert(0);
- return -1;
}
- return internal_ao2_ref(user_data, delta, file, line, func);
+ return old_refcount;
}
int __ao2_ref(void *user_data, int delta)