[svn-commits] russell: branch 1.4 r134814 - /branches/1.4/channels/iax2-parser.c
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Thu Jul 31 11:45:31 CDT 2008
Author: russell
Date: Thu Jul 31 11:45:31 2008
New Revision: 134814
URL: http://svn.digium.com/view/asterisk?view=rev&rev=134814
Log:
In case we have some processing threads that free more frames than they allocate,
do not let the frame cache grow forever.
(closes issue #13160)
Reported by: tavius
Tested by: tavius, russell
Modified:
branches/1.4/channels/iax2-parser.c
Modified: branches/1.4/channels/iax2-parser.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/channels/iax2-parser.c?view=diff&rev=134814&r1=134813&r2=134814
==============================================================================
--- branches/1.4/channels/iax2-parser.c (original)
+++ branches/1.4/channels/iax2-parser.c Thu Jul 31 11:45:31 2008
@@ -58,7 +58,14 @@
/*! \brief This is just so iax_frames, a list head struct for holding a list of
* iax_frame structures, is defined. */
-AST_LIST_HEAD_NOLOCK(iax_frames, iax_frame);
+AST_LIST_HEAD_NOLOCK(iax_frame_list, iax_frame);
+
+struct iax_frames {
+ struct iax_frame_list list;
+ size_t size;
+};
+
+#define FRAME_CACHE_MAX_SIZE 20
#endif
static void internaloutput(const char *str)
@@ -957,10 +964,11 @@
/* Attempt to get a frame from this thread's cache */
if ((iax_frames = ast_threadstorage_get(&frame_cache, sizeof(*iax_frames)))) {
- AST_LIST_TRAVERSE_SAFE_BEGIN(iax_frames, fr, list) {
+ AST_LIST_TRAVERSE_SAFE_BEGIN(&iax_frames->list, fr, list) {
if (fr->afdatalen >= datalen) {
size_t afdatalen = fr->afdatalen;
- AST_LIST_REMOVE_CURRENT(iax_frames, list);
+ AST_LIST_REMOVE_CURRENT(&iax_frames->list, list);
+ iax_frames->size--;
memset(fr, 0, sizeof(*fr));
fr->afdatalen = afdatalen;
break;
@@ -1017,11 +1025,14 @@
return;
}
- fr->direction = 0;
- AST_LIST_INSERT_HEAD(iax_frames, fr, list);
-#else
+ if (iax_frames->size < FRAME_CACHE_MAX_SIZE) {
+ fr->direction = 0;
+ AST_LIST_INSERT_HEAD(&iax_frames->list, fr, list);
+ iax_frames->size++;
+ return;
+ }
+#endif
free(fr);
-#endif
}
#if !defined(LOW_MEMORY)
@@ -1030,7 +1041,7 @@
struct iax_frames *frames = data;
struct iax_frame *cur;
- while ((cur = AST_LIST_REMOVE_HEAD(frames, list)))
+ while ((cur = AST_LIST_REMOVE_HEAD(&frames->list, list)))
free(cur);
free(frames);
More information about the svn-commits
mailing list