mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-05 12:16:00 +00:00
Merged revisions 49458 via svnmerge from
https://svn.digium.com/svn/asterisk/branches/1.4 ........ r49458 | kpfleming | 2007-01-04 12:06:51 -0600 (Thu, 04 Jan 2007) | 2 lines don't do frame caching in LOW_MEMORY mode ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@49462 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -50,10 +50,12 @@ static int frames = 0;
|
|||||||
static int iframes = 0;
|
static int iframes = 0;
|
||||||
static int oframes = 0;
|
static int oframes = 0;
|
||||||
|
|
||||||
|
#if !defined(LOW_MEMORY)
|
||||||
static void frame_cache_cleanup(void *data);
|
static void frame_cache_cleanup(void *data);
|
||||||
|
|
||||||
/*! \brief A per-thread cache of iax_frame structures */
|
/*! \brief A per-thread cache of iax_frame structures */
|
||||||
AST_THREADSTORAGE_CUSTOM(frame_cache, NULL, frame_cache_cleanup);
|
AST_THREADSTORAGE_CUSTOM(frame_cache, NULL, frame_cache_cleanup);
|
||||||
|
#endif
|
||||||
|
|
||||||
/*! \brief This is just so iax_frames, a list head struct for holding a list of
|
/*! \brief This is just so iax_frames, a list head struct for holding a list of
|
||||||
* iax_frame structures, is defined. */
|
* iax_frame structures, is defined. */
|
||||||
@@ -940,6 +942,8 @@ void iax_frame_wrap(struct iax_frame *fr, struct ast_frame *f)
|
|||||||
struct iax_frame *iax_frame_new(int direction, int datalen)
|
struct iax_frame *iax_frame_new(int direction, int datalen)
|
||||||
{
|
{
|
||||||
struct iax_frame *fr = NULL;
|
struct iax_frame *fr = NULL;
|
||||||
|
|
||||||
|
#if !defined(LOW_MEMORY)
|
||||||
struct iax_frames *iax_frames;
|
struct iax_frames *iax_frames;
|
||||||
|
|
||||||
/* Attempt to get a frame from this thread's cache */
|
/* Attempt to get a frame from this thread's cache */
|
||||||
@@ -955,6 +959,7 @@ struct iax_frame *iax_frame_new(int direction, int datalen)
|
|||||||
}
|
}
|
||||||
AST_LIST_TRAVERSE_SAFE_END
|
AST_LIST_TRAVERSE_SAFE_END
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!fr) {
|
if (!fr) {
|
||||||
if (!(fr = ast_calloc_cache(1, sizeof(*fr) + datalen)))
|
if (!(fr = ast_calloc_cache(1, sizeof(*fr) + datalen)))
|
||||||
@@ -975,7 +980,9 @@ struct iax_frame *iax_frame_new(int direction, int datalen)
|
|||||||
|
|
||||||
void iax_frame_free(struct iax_frame *fr)
|
void iax_frame_free(struct iax_frame *fr)
|
||||||
{
|
{
|
||||||
|
#if !defined(LOW_MEMORY)
|
||||||
struct iax_frames *iax_frames;
|
struct iax_frames *iax_frames;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Note: does not remove from scheduler! */
|
/* Note: does not remove from scheduler! */
|
||||||
if (fr->direction == DIRECTION_INGRESS)
|
if (fr->direction == DIRECTION_INGRESS)
|
||||||
@@ -986,17 +993,22 @@ void iax_frame_free(struct iax_frame *fr)
|
|||||||
errorf("Attempt to double free frame detected\n");
|
errorf("Attempt to double free frame detected\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
fr->direction = 0;
|
|
||||||
ast_atomic_fetchadd_int(&frames, -1);
|
ast_atomic_fetchadd_int(&frames, -1);
|
||||||
|
|
||||||
|
#if !defined(LOW_MEMORY)
|
||||||
if (!(iax_frames = ast_threadstorage_get(&frame_cache, sizeof(*iax_frames)))) {
|
if (!(iax_frames = ast_threadstorage_get(&frame_cache, sizeof(*iax_frames)))) {
|
||||||
free(fr);
|
free(fr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fr->direction = 0;
|
||||||
AST_LIST_INSERT_HEAD(iax_frames, fr, list);
|
AST_LIST_INSERT_HEAD(iax_frames, fr, list);
|
||||||
|
#else
|
||||||
|
free(fr);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !defined(LOW_MEMORY)
|
||||||
static void frame_cache_cleanup(void *data)
|
static void frame_cache_cleanup(void *data)
|
||||||
{
|
{
|
||||||
struct iax_frames *frames = data;
|
struct iax_frames *frames = data;
|
||||||
@@ -1007,6 +1019,7 @@ static void frame_cache_cleanup(void *data)
|
|||||||
|
|
||||||
free(frames);
|
free(frames);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int iax_get_frames(void) { return frames; }
|
int iax_get_frames(void) { return frames; }
|
||||||
int iax_get_iframes(void) { return iframes; }
|
int iax_get_iframes(void) { return iframes; }
|
||||||
|
Reference in New Issue
Block a user