[asterisk-commits] coreyfarrell: branch 1.8 r418504 - in /branches/1.8: contrib/scripts/ main/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sun Jul 13 16:47:10 CDT 2014


Author: coreyfarrell
Date: Sun Jul 13 16:47:06 2014
New Revision: 418504

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=418504
Log:
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/

Modified:
    branches/1.8/contrib/scripts/refcounter.py
    branches/1.8/main/astobj2.c

Modified: branches/1.8/contrib/scripts/refcounter.py
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/contrib/scripts/refcounter.py?view=diff&rev=418504&r1=418503&r2=418504
==============================================================================
--- branches/1.8/contrib/scripts/refcounter.py (original)
+++ branches/1.8/contrib/scripts/refcounter.py Sun Jul 13 16:47:06 2014
@@ -79,10 +79,15 @@
             obj = parsed_line['addr']
 
             if obj not in current_objects:
-                current_objects[obj] = []
-                if options.skewed and 'constructor' not in parsed_line['state']:
-                    skewed_objects.append((obj, current_objects[obj]))
-            current_objects[obj].append("[%s] %s:%s %s: %s %s - [%s]" % (
+                current_objects[obj] = {'log': [], 'curcount': 1,}
+                if 'constructor' not in parsed_line['state']:
+                    current_objects[obj]['curcount'] = parsed_line['state']
+                    if options.skewed:
+                        skewed_objects.append((obj, current_objects[obj]))
+            else:
+                current_objects[obj]['curcount'] += int(parsed_line['delta'])
+
+            current_objects[obj]['log'].append("[%s] %s:%s %s: %s %s - [%s]" % (
                 parsed_line['thread_id'],
                 parsed_line['file'],
                 parsed_line['line'],
@@ -91,7 +96,7 @@
                 parsed_line['tag'],
                 parsed_line['state']))
 
-            if 'destructor' in parsed_line['state']:
+            if current_objects[obj]['curcount'] == 0:
                 if options.normal:
                     finished_objects.append((obj, current_objects[obj]))
                 del current_objects[obj]
@@ -115,7 +120,7 @@
     print "\n"
     for obj in objects:
         print "==== %s Object %s history ====" % (prefix, obj[0])
-        for line in obj[1]:
+        for line in obj[1]['log']:
             print line
         print "\n"
 

Modified: branches/1.8/main/astobj2.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/main/astobj2.c?view=diff&rev=418504&r1=418503&r2=418504
==============================================================================
--- branches/1.8/main/astobj2.c (original)
+++ branches/1.8/main/astobj2.c Sun Jul 13 16:47:06 2014
@@ -219,23 +219,24 @@
 int __ao2_ref_debug(void *user_data, const int delta, const char *tag, const char *file, int line, const char *funcname)
 {
 	struct astobj2 *obj = INTERNAL_OBJ(user_data);
+	int old_refcount = -1;
+
+	if (obj) {
+		old_refcount = internal_ao2_ref(user_data, delta);
+	}
 
 	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, funcname, 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, funcname, obj ? obj->priv_data.ref_counter : -1, tag);
+				delta, ast_get_tid(), file, line, funcname, old_refcount, tag);
 			fflush(ref_log);
 		}
 	}
 
-	if (obj == NULL) {
-		return -1;
-	}
-
-	return internal_ao2_ref(user_data, delta);
+	return old_refcount;
 }
 
 int __ao2_ref(void *user_data, const int delta)




More information about the asterisk-commits mailing list