[asterisk-commits] kpfleming: branch 1.4 r49458 - /branches/1.4/channels/iax2-parser.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Thu Jan 4 11:06:52 MST 2007


Author: kpfleming
Date: Thu Jan  4 12:06:51 2007
New Revision: 49458

URL: http://svn.digium.com/view/asterisk?view=rev&rev=49458
Log:
don't do frame caching in LOW_MEMORY mode

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=49458&r1=49457&r2=49458
==============================================================================
--- branches/1.4/channels/iax2-parser.c (original)
+++ branches/1.4/channels/iax2-parser.c Thu Jan  4 12:06:51 2007
@@ -50,10 +50,12 @@
 static int iframes = 0;
 static int oframes = 0;
 
+#if !defined(LOW_MEMORY)
 static void frame_cache_cleanup(void *data);
 
 /*! \brief A per-thread cache of iax_frame structures */
 AST_THREADSTORAGE_CUSTOM(frame_cache, frame_cache_init, frame_cache_cleanup);
+#endif
 
 /*! \brief This is just so iax_frames, a list head struct for holding a list of
  *  iax_frame structures, is defined. */
@@ -940,6 +942,8 @@
 struct iax_frame *iax_frame_new(int direction, int datalen)
 {
 	struct iax_frame *fr = NULL;
+
+#if !defined(LOW_MEMORY)
 	struct iax_frames *iax_frames;
 
 	/* Attempt to get a frame from this thread's cache */
@@ -955,6 +959,7 @@
 		}
 		AST_LIST_TRAVERSE_SAFE_END
 	}
+#endif
 
 	if (!fr) {
 		if (!(fr = ast_calloc_cache(1, sizeof(*fr) + datalen)))
@@ -975,7 +980,9 @@
 
 void iax_frame_free(struct iax_frame *fr)
 {
+#if !defined(LOW_MEMORY)
 	struct iax_frames *iax_frames;
+#endif
 
 	/* Note: does not remove from scheduler! */
 	if (fr->direction == DIRECTION_INGRESS)
@@ -986,17 +993,22 @@
 		errorf("Attempt to double free frame detected\n");
 		return;
 	}
-	fr->direction = 0;
 	ast_atomic_fetchadd_int(&frames, -1);
 
+#if !defined(LOW_MEMORY)
 	if (!(iax_frames = ast_threadstorage_get(&frame_cache, sizeof(*iax_frames)))) {
 		free(fr);
 		return;
 	}
 
+	fr->direction = 0;
 	AST_LIST_INSERT_HEAD(iax_frames, fr, list);
-}
-
+#else
+	free(fr);
+#endif
+}
+
+#if !defined(LOW_MEMORY)
 static void frame_cache_cleanup(void *data)
 {
 	struct iax_frames *frames = data;
@@ -1007,6 +1019,7 @@
 
 	free(frames);
 }
+#endif
 
 int iax_get_frames(void) { return frames; }
 int iax_get_iframes(void) { return iframes; }



More information about the asterisk-commits mailing list