[asterisk-commits] coreyfarrell: branch coreyfarrell/media_formats-next r417209 - in /team/corey...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Jun 25 02:53:08 CDT 2014


Author: coreyfarrell
Date: Wed Jun 25 02:52:59 2014
New Revision: 417209

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=417209
Log:
stuff from other reviews, additional ao2 debugging help

Modified:
    team/coreyfarrell/media_formats-next/contrib/scripts/refcounter.py
    team/coreyfarrell/media_formats-next/main/astobj2.c
    team/coreyfarrell/media_formats-next/main/astobj2_container.c
    team/coreyfarrell/media_formats-next/main/codec.c
    team/coreyfarrell/media_formats-next/main/format.c

Modified: team/coreyfarrell/media_formats-next/contrib/scripts/refcounter.py
URL: http://svnview.digium.com/svn/asterisk/team/coreyfarrell/media_formats-next/contrib/scripts/refcounter.py?view=diff&rev=417209&r1=417208&r2=417209
==============================================================================
--- team/coreyfarrell/media_formats-next/contrib/scripts/refcounter.py (original)
+++ team/coreyfarrell/media_formats-next/contrib/scripts/refcounter.py Wed Jun 25 02:52:59 2014
@@ -50,7 +50,7 @@
     return processed_line
 
 
-def process_file(filename):
+def process_file(options):
     """The routine that kicks off processing a ref file
 
     Keyword Arguments:
@@ -63,10 +63,11 @@
         - A list of objects whose lifetimes are skewed
     """
 
-    finished_objects = []
-    leaked_objects = []
-    skewed_objects = []
+    finished_objects = {}
+    leaked_objects = {}
+    skewed_objects = {}
     current_objects = {}
+    filename = options.filepath
 
     with open(filename, 'r') as ref_file:
         for line in ref_file:
@@ -78,16 +79,25 @@
 
             if obj not in current_objects:
                 current_objects[obj] = []
-                if 'constructor' not in parsed_line['state']:
-                    skewed_objects.append(current_objects[obj])
-            current_objects[obj].append(parsed_line)
+                if options.skewed and 'constructor' not in parsed_line['state']:
+                    skewed_objects[obj] = current_objects[obj]
+            current_objects[obj].append("[%s] %s:%s %s: %s %s - [%s]" % (
+                                                parsed_line['thread_id'],
+                                                parsed_line['file'],
+                                                parsed_line['line'],
+                                                parsed_line['function'],
+                                                parsed_line['delta'],
+                                                parsed_line['tag'],
+                                                parsed_line['state']))
 
             if 'destructor' in parsed_line['state']:
                 lifetime = current_objects.get(obj)
-                finished_objects.append(lifetime)
+                if options.normal:
+                    finished_objects[obj] = lifetime
                 del current_objects[obj]
 
-    leaked_objects = current_objects.values()
+    if options.leaks:
+        leaked_objects = current_objects
     return (finished_objects, leaked_objects, skewed_objects)
 
 
@@ -102,14 +112,10 @@
 
     print "======== %s Objects ========" % prefix
     print "\n"
-    for obj in objects:
-        print "==== %s Object %s history ====" % (prefix, obj[0]['addr'])
-        for entry in obj:
-            print "[%s] %s:%s %s: %s %s - [%s]" % (entry['thread_id'],
-                                              entry['file'], entry['line'],
-                                              entry['function'],
-                                              entry['delta'], entry['tag'],
-                                              entry['state'])
+    for key, lines in objects.iteritems():
+        print "==== %s Object %s history ====" % (prefix, key)
+        for line in lines:
+            print line
         print "\n"
 
 
@@ -140,6 +146,10 @@
 
     (options, args) = parser.parse_args(argv)
 
+    if not options.leaks and not options.skewed and not options.normal:
+        print >>sys.stderr, "All options disabled"
+        return -1
+
     if not os.path.isfile(options.filepath):
         print >>sys.stderr, "File not found: %s" % options.filepath
         return -1
@@ -147,7 +157,7 @@
     try:
         (finished_objects,
          leaked_objects,
-         skewed_objects) = process_file(options.filepath)
+         skewed_objects) = process_file(options)
 
         if options.leaks and len(leaked_objects):
             print_objects(leaked_objects, "Leaked")

Modified: team/coreyfarrell/media_formats-next/main/astobj2.c
URL: http://svnview.digium.com/svn/asterisk/team/coreyfarrell/media_formats-next/main/astobj2.c?view=diff&rev=417209&r1=417208&r2=417209
==============================================================================
--- team/coreyfarrell/media_formats-next/main/astobj2.c (original)
+++ team/coreyfarrell/media_formats-next/main/astobj2.c Wed Jun 25 02:52:59 2014
@@ -150,7 +150,6 @@
 				"bad magic number for object %p. Object is likely destroyed.\n",
 				user_data);
 		}
-		ast_assert(0);
 		return NULL;
 	}
 
@@ -358,6 +357,11 @@
 	struct astobj2 *obj = INTERNAL_OBJ(user_data);
 	struct astobj2_rwlock *obj_rwlock;
 	enum ao2_lock_req orig_lock;
+
+	if (obj == NULL) {
+		ast_assert(0);
+		return AO2_LOCK_REQ_MUTEX;
+	}
 
 	switch (obj->priv_data.options & AO2_ALLOC_OPT_LOCK_MASK) {
 	case AO2_ALLOC_OPT_LOCK_RWLOCK:
@@ -501,6 +505,9 @@
 
 	if (obj == NULL) {
 		ast_log_backtrace();
+		fprintf(ref_log, "%p,%s%d,%d,%s,%d,%s,%d,%s\n", user_data, (delta < 0 ? "" : "+"),
+			delta, ast_get_tid(), file, line, func, -1, tag);
+		fflush(ref_log);
 		ast_assert(0);
 		return -1;
 	}
@@ -511,7 +518,7 @@
 			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, obj->priv_data.ref_counter, tag);
 			fflush(ref_log);
 		}
 	}
@@ -608,6 +615,7 @@
 {
 	struct astobj2 *orig_obj = INTERNAL_OBJ(obj);
 	if (!orig_obj) {
+		ast_assert(0);
 		return 0;
 	}
 	return orig_obj->priv_data.options;

Modified: team/coreyfarrell/media_formats-next/main/astobj2_container.c
URL: http://svnview.digium.com/svn/asterisk/team/coreyfarrell/media_formats-next/main/astobj2_container.c?view=diff&rev=417209&r1=417208&r2=417209
==============================================================================
--- team/coreyfarrell/media_formats-next/main/astobj2_container.c (original)
+++ team/coreyfarrell/media_formats-next/main/astobj2_container.c Wed Jun 25 02:52:59 2014
@@ -75,7 +75,7 @@
 	}
 
 	if (flags & AO2_UNLINK_NODE_UNREF_NODE) {
-		ao2_t_ref(node, -1, "Remove node from container");
+		__ao2_ref(node, -1);
 	}
 
 	return 1;

Modified: team/coreyfarrell/media_formats-next/main/codec.c
URL: http://svnview.digium.com/svn/asterisk/team/coreyfarrell/media_formats-next/main/codec.c?view=diff&rev=417209&r1=417208&r2=417209
==============================================================================
--- team/coreyfarrell/media_formats-next/main/codec.c (original)
+++ team/coreyfarrell/media_formats-next/main/codec.c Wed Jun 25 02:52:59 2014
@@ -275,7 +275,7 @@
 		return -1;
 	}
 
-	codec_new = ao2_alloc_options(sizeof(*codec_new), NULL, AO2_ALLOC_OPT_LOCK_NOLOCK);
+	codec_new = ao2_t_alloc_options(sizeof(*codec_new), NULL, AO2_ALLOC_OPT_LOCK_NOLOCK, codec->name);
 	if (!codec_new) {
 		ast_log(LOG_ERROR, "Could not allocate a codec with name '%s' of type '%s' and sample rate '%d'\n",
 			codec->name, ast_codec_media_type2str(codec->type), codec->sample_rate);

Modified: team/coreyfarrell/media_formats-next/main/format.c
URL: http://svnview.digium.com/svn/asterisk/team/coreyfarrell/media_formats-next/main/format.c?view=diff&rev=417209&r1=417208&r2=417209
==============================================================================
--- team/coreyfarrell/media_formats-next/main/format.c (original)
+++ team/coreyfarrell/media_formats-next/main/format.c Wed Jun 25 02:52:59 2014
@@ -174,7 +174,7 @@
 	struct ast_format *format;
 	struct format_interface *format_interface;
 
-	format = ao2_alloc(sizeof(*format), format_destroy);
+	format = ao2_t_alloc(sizeof(*format), format_destroy, format_name);
 	if (!format) {
 		return NULL;
 	}




More information about the asterisk-commits mailing list