[asterisk-commits] russell: branch russell/frame_caching r38608 - /team/russell/frame_caching/

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Mon Jul 31 12:40:03 MST 2006


Author: russell
Date: Mon Jul 31 14:40:02 2006
New Revision: 38608

URL: http://svn.digium.com/view/asterisk?rev=38608&view=rev
Log:
- ensure all frames pulled out of the cache are zeroed out
- set AST_MALLOCD_HDR on frames pulled from the cache in ast_header_new() to
  make sure they will be cached again after used, and eventually free'd

Modified:
    team/russell/frame_caching/frame.c

Modified: team/russell/frame_caching/frame.c
URL: http://svn.digium.com/view/asterisk/team/russell/frame_caching/frame.c?rev=38608&r1=38607&r2=38608&view=diff
==============================================================================
--- team/russell/frame_caching/frame.c (original)
+++ team/russell/frame_caching/frame.c Mon Jul 31 14:40:02 2006
@@ -279,9 +279,10 @@
 
 	if ((frames = ast_threadstorage_get(&frame_cache, sizeof(*frames)))) {
 		if ((f = AST_LIST_REMOVE_HEAD(frames, frame_list))) {
-			size_t old_len = f->mallocd_hdr_len;
+			size_t mallocd_len = f->mallocd_hdr_len;
 			memset(f, 0, sizeof(*f));
-			f->mallocd_hdr_len = old_len;
+			f->mallocd_hdr_len = mallocd_len;
+			f->mallocd = AST_MALLOCD_HDR;
 			ast_atomic_fetchadd_int((int *) &removed_from_cache, 1);
 			return f;
 		}
@@ -456,7 +457,10 @@
 	if ((frames = ast_threadstorage_get(&frame_cache, sizeof(*frames)))) {
 		AST_LIST_TRAVERSE_SAFE_BEGIN(frames, out, frame_list) {
 			if (out->mallocd_hdr_len >= len) {
+				size_t mallocd_len = out->mallocd_hdr_len;
 				AST_LIST_REMOVE_CURRENT(frames, frame_list);
+				memset(out, 0, sizeof(*out));
+				out->mallocd_hdr_len = mallocd_len;
 				buf = out;
 				ast_atomic_fetchadd_int((int *) &removed_from_cache, 1);
 				break;



More information about the asterisk-commits mailing list