[asterisk-commits] kmoore: branch group/media_formats-reviewed-trunk r418348 - in /team/group/me...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Jul 10 13:17:34 CDT 2014


Author: kmoore
Date: Thu Jul 10 13:17:27 2014
New Revision: 418348

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=418348
Log:
main/frame: Only unref formats on non-static frames

The format on the frame was being unreffed on static frames that had
not bumped the ref resulting in a crash when compiled with the DO_CRASH
flag due to the refcount on the format going negative.

This also fixes some frame leaks on startup resulting from this patch.

ASTERISK-23960
Review: https://reviewboard.asterisk.org/r/3738/

Modified:
    team/group/media_formats-reviewed-trunk/codecs/ex_adpcm.h
    team/group/media_formats-reviewed-trunk/codecs/ex_alaw.h
    team/group/media_formats-reviewed-trunk/codecs/ex_g722.h
    team/group/media_formats-reviewed-trunk/codecs/ex_g726.h
    team/group/media_formats-reviewed-trunk/codecs/ex_gsm.h
    team/group/media_formats-reviewed-trunk/codecs/ex_ilbc.h
    team/group/media_formats-reviewed-trunk/codecs/ex_lpc10.h
    team/group/media_formats-reviewed-trunk/codecs/ex_speex.h
    team/group/media_formats-reviewed-trunk/codecs/ex_ulaw.h
    team/group/media_formats-reviewed-trunk/include/asterisk/slin.h
    team/group/media_formats-reviewed-trunk/main/frame.c

Modified: team/group/media_formats-reviewed-trunk/codecs/ex_adpcm.h
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed-trunk/codecs/ex_adpcm.h?view=diff&rev=418348&r1=418347&r2=418348
==============================================================================
--- team/group/media_formats-reviewed-trunk/codecs/ex_adpcm.h (original)
+++ team/group/media_formats-reviewed-trunk/codecs/ex_adpcm.h Thu Jul 10 13:17:27 2014
@@ -27,7 +27,7 @@
 		.data.ptr = ex_adpcm,
 	};
 
-	f.subclass.format = ao2_bump(ast_format_adpcm);
+	f.subclass.format = ast_format_adpcm;
 
 	return &f;
 }

Modified: team/group/media_formats-reviewed-trunk/codecs/ex_alaw.h
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed-trunk/codecs/ex_alaw.h?view=diff&rev=418348&r1=418347&r2=418348
==============================================================================
--- team/group/media_formats-reviewed-trunk/codecs/ex_alaw.h (original)
+++ team/group/media_formats-reviewed-trunk/codecs/ex_alaw.h Thu Jul 10 13:17:27 2014
@@ -31,6 +31,6 @@
 		.src = __PRETTY_FUNCTION__,
 		.data.ptr = ex_alaw,
 	};
-	f.subclass.format = ao2_bump(ast_format_alaw);
+	f.subclass.format = ast_format_alaw;
 	return &f;
 }

Modified: team/group/media_formats-reviewed-trunk/codecs/ex_g722.h
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed-trunk/codecs/ex_g722.h?view=diff&rev=418348&r1=418347&r2=418348
==============================================================================
--- team/group/media_formats-reviewed-trunk/codecs/ex_g722.h (original)
+++ team/group/media_formats-reviewed-trunk/codecs/ex_g722.h Thu Jul 10 13:17:27 2014
@@ -42,7 +42,7 @@
 		.data.ptr = ex_g722,
 	};
 
-	f.subclass.format = ao2_bump(ast_format_slin);
+	f.subclass.format = ast_format_slin;
 
 	return &f;
 }

Modified: team/group/media_formats-reviewed-trunk/codecs/ex_g726.h
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed-trunk/codecs/ex_g726.h?view=diff&rev=418348&r1=418347&r2=418348
==============================================================================
--- team/group/media_formats-reviewed-trunk/codecs/ex_g726.h (original)
+++ team/group/media_formats-reviewed-trunk/codecs/ex_g726.h Thu Jul 10 13:17:27 2014
@@ -27,7 +27,7 @@
 		.data.ptr = ex_g726,
 	};
 
-	f.subclass.format = ao2_bump(ast_format_g726);
+	f.subclass.format = ast_format_g726;
 
 	return &f;
 }

Modified: team/group/media_formats-reviewed-trunk/codecs/ex_gsm.h
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed-trunk/codecs/ex_gsm.h?view=diff&rev=418348&r1=418347&r2=418348
==============================================================================
--- team/group/media_formats-reviewed-trunk/codecs/ex_gsm.h (original)
+++ team/group/media_formats-reviewed-trunk/codecs/ex_gsm.h Thu Jul 10 13:17:27 2014
@@ -27,7 +27,7 @@
 		.data.ptr = ex_gsm,
 	};
 
-	f.subclass.format = ao2_bump(ast_format_gsm);
+	f.subclass.format = ast_format_gsm;
 
 	return &f;
 }

Modified: team/group/media_formats-reviewed-trunk/codecs/ex_ilbc.h
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed-trunk/codecs/ex_ilbc.h?view=diff&rev=418348&r1=418347&r2=418348
==============================================================================
--- team/group/media_formats-reviewed-trunk/codecs/ex_ilbc.h (original)
+++ team/group/media_formats-reviewed-trunk/codecs/ex_ilbc.h Thu Jul 10 13:17:27 2014
@@ -28,7 +28,7 @@
 		.data.ptr = ex_ilbc,
 	};
 
-	f.subclass.format = ao2_bump(ast_format_ilbc);
+	f.subclass.format = ast_format_ilbc;
 
 	return &f;
 }

Modified: team/group/media_formats-reviewed-trunk/codecs/ex_lpc10.h
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed-trunk/codecs/ex_lpc10.h?view=diff&rev=418348&r1=418347&r2=418348
==============================================================================
--- team/group/media_formats-reviewed-trunk/codecs/ex_lpc10.h (original)
+++ team/group/media_formats-reviewed-trunk/codecs/ex_lpc10.h Thu Jul 10 13:17:27 2014
@@ -25,7 +25,7 @@
 		.data.ptr = ex_lpc10,
 	};
 
-	f.subclass.format = ao2_bump(ast_format_lpc10);
+	f.subclass.format = ast_format_lpc10;
 
 	return &f;
 }

Modified: team/group/media_formats-reviewed-trunk/codecs/ex_speex.h
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed-trunk/codecs/ex_speex.h?view=diff&rev=418348&r1=418347&r2=418348
==============================================================================
--- team/group/media_formats-reviewed-trunk/codecs/ex_speex.h (original)
+++ team/group/media_formats-reviewed-trunk/codecs/ex_speex.h Thu Jul 10 13:17:27 2014
@@ -27,7 +27,7 @@
 		.data.ptr = ex_speex,
 	};
 
-	f.subclass.format = ao2_bump(ast_format_speex);
+	f.subclass.format = ast_format_speex;
 
 	return &f;
 }
@@ -59,7 +59,7 @@
 		.data.ptr = ex_speex16,
 	};
 
-	f.subclass.format = ao2_bump(ast_format_speex16);
+	f.subclass.format = ast_format_speex16;
 
 	return &f;
 }

Modified: team/group/media_formats-reviewed-trunk/codecs/ex_ulaw.h
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed-trunk/codecs/ex_ulaw.h?view=diff&rev=418348&r1=418347&r2=418348
==============================================================================
--- team/group/media_formats-reviewed-trunk/codecs/ex_ulaw.h (original)
+++ team/group/media_formats-reviewed-trunk/codecs/ex_ulaw.h Thu Jul 10 13:17:27 2014
@@ -32,7 +32,7 @@
 		.data.ptr = ex_ulaw,
 	};
 
-	f.subclass.format = ao2_bump(ast_format_ulaw);
+	f.subclass.format = ast_format_ulaw;
 
 	return &f;
 }

Modified: team/group/media_formats-reviewed-trunk/include/asterisk/slin.h
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed-trunk/include/asterisk/slin.h?view=diff&rev=418348&r1=418347&r2=418348
==============================================================================
--- team/group/media_formats-reviewed-trunk/include/asterisk/slin.h (original)
+++ team/group/media_formats-reviewed-trunk/include/asterisk/slin.h Thu Jul 10 13:17:27 2014
@@ -70,7 +70,7 @@
 		.data.ptr = ex_slin8,
 	};
 
-	f.subclass.format = ao2_bump(ast_format_slin);
+	f.subclass.format = ast_format_slin;
 
 	return &f;
 }
@@ -87,7 +87,7 @@
 		.data.ptr = ex_slin16,
 	};
 
-	f.subclass.format = ao2_bump(ast_format_slin16);
+	f.subclass.format = ast_format_slin16;
 
 	return &f;
 }

Modified: team/group/media_formats-reviewed-trunk/main/frame.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed-trunk/main/frame.c?view=diff&rev=418348&r1=418347&r2=418348
==============================================================================
--- team/group/media_formats-reviewed-trunk/main/frame.c (original)
+++ team/group/media_formats-reviewed-trunk/main/frame.c Thu Jul 10 13:17:27 2014
@@ -118,13 +118,6 @@
 
 static void __frame_free(struct ast_frame *fr, int cache)
 {
-	if ((fr->frametype == AST_FRAME_VOICE) || (fr->frametype == AST_FRAME_VIDEO) ||
-		(fr->frametype == AST_FRAME_IMAGE)) {
-		ao2_cleanup(fr->subclass.format);
-	} else {
-		memset(&fr->subclass, 0, sizeof(fr->subclass));
-	}
-
 	if (!fr->mallocd)
 		return;
 
@@ -133,6 +126,10 @@
 		/* Cool, only the header is malloc'd, let's just cache those for now
 		 * to keep things simple... */
 		struct ast_frame_cache *frames;
+		if ((fr->frametype == AST_FRAME_VOICE) || (fr->frametype == AST_FRAME_VIDEO) ||
+			(fr->frametype == AST_FRAME_IMAGE)) {
+			ao2_cleanup(fr->subclass.format);
+		}
 
 		if ((frames = ast_threadstorage_get(&frame_cache, sizeof(*frames))) &&
 		    (frames->size < FRAME_CACHE_MAX_SIZE)) {
@@ -152,6 +149,11 @@
 			ast_free((void *) fr->src);
 	}
 	if (fr->mallocd & AST_MALLOCD_HDR) {
+		if ((fr->frametype == AST_FRAME_VOICE) || (fr->frametype == AST_FRAME_VIDEO) ||
+			(fr->frametype == AST_FRAME_IMAGE)) {
+			ao2_cleanup(fr->subclass.format);
+		}
+
 		ast_free(fr);
 	}
 }




More information about the asterisk-commits mailing list