45 #ifndef SWITCH_POOL_RECYCLE
46 #define PER_POOL_LOCK 1
84 (
void *) session->pool, (
void *) session, apr_pool_tag(session->pool, NULL), (
int) memory);
87 ptr = apr_palloc(session->pool, memory);
153 len = strlen(todup) + 1;
200 result = apr_pvsprintf(pool, fmt, ap);
252 (
void *) session->pool, (
void *)session, apr_pool_tag(session->pool, NULL), strlen(todup));
255 duped = apr_pstrdup(session->pool, todup);
286 len = strlen(todup) + 1;
291 (
void *) pool, apr_pool_tag(pool, NULL), (
int)len);
294 duped = apr_pstrmemdup(pool, todup, len);
308 apr_pool_userdata_set(data, key, NULL, pool);
315 apr_pool_userdata_get(&data, key, pool);
322 apr_pool_tag(pool, tag);
328 apr_thread_mutex_t *my_mutex;
329 apr_pool_mutex_set(p, NULL);
336 if ((apr_thread_mutex_create(&my_mutex, APR_THREAD_MUTEX_NESTED, p)) != APR_SUCCESS) {
340 apr_pool_mutex_set(p, my_mutex);
351 #ifdef INSTANTLY_DESTROY_POOLS
352 apr_pool_create(pool, NULL);
357 apr_allocator_t *my_allocator = NULL;
358 apr_thread_mutex_t *my_mutex;
368 #ifndef PER_POOL_LOCK
375 if ((apr_allocator_create(&my_allocator)) != APR_SUCCESS) {
379 if ((apr_pool_create_ex(pool, NULL, NULL, my_allocator)) != APR_SUCCESS) {
383 if ((apr_thread_mutex_create(&my_mutex, APR_THREAD_MUTEX_NESTED, *pool)) != APR_SUCCESS) {
387 apr_allocator_mutex_set(my_allocator, my_mutex);
388 apr_allocator_owner_set(my_allocator, *pool);
390 apr_pool_mutex_set(*pool, my_mutex);
393 apr_pool_create(pool, NULL);
400 apr_pool_tag(*pool, tmp);
422 #ifdef INSTANTLY_DESTROY_POOLS
426 apr_pool_destroy(*pool);
435 apr_pool_destroy(*pool);
462 (
void *) pool, apr_pool_tag(pool, NULL), (
int) memory);
466 ptr = apr_palloc(pool, memory);
481 #if !defined(PER_POOL_LOCK) && !defined(INSTANTLY_DESTROY_POOLS)
495 apr_pool_destroy(pool);
512 int x = len, done = 0;
524 #if defined(PER_POOL_LOCK) || defined(DESTROY_POOLS)
532 apr_pool_destroy(pop);
537 apr_pool_mutex_set(pop, NULL);
549 apr_pool_destroy(pop);
578 apr_pool_destroy(pop);
592 #ifndef INSTANTLY_DESTROY_POOLS
598 #ifndef INSTANTLY_DESTROY_POOLS
609 apr_pool_destroy(pop);
616 #ifndef INSTANTLY_DESTROY_POOLS
620 apr_allocator_t *my_allocator = NULL;
621 apr_thread_mutex_t *my_mutex;
627 if ((apr_allocator_create(&my_allocator)) != APR_SUCCESS) {
631 if ((apr_pool_create_ex(&
memory_manager.memory_pool, NULL, NULL, my_allocator)) != APR_SUCCESS) {
632 apr_allocator_destroy(my_allocator);
637 if ((apr_thread_mutex_create(&my_mutex, APR_THREAD_MUTEX_NESTED,
memory_manager.memory_pool)) != APR_SUCCESS) {
641 apr_allocator_mutex_set(my_allocator, my_mutex);
643 apr_allocator_owner_set(my_allocator,
memory_manager.memory_pool);
654 #ifdef INSTANTLY_DESTROY_POOLS
struct apr_queue_t switch_queue_t
unsigned int switch_queue_size(switch_queue_t *queue)
#define SWITCH_CHANNEL_LOG
switch_status_t switch_core_perform_destroy_memory_pool(switch_memory_pool_t **pool, const char *file, const char *func, int line)
switch_status_t switch_threadattr_stacksize_set(switch_threadattr_t *attr, switch_size_t stacksize)
switch_memory_pool_t * pool
switch_status_t switch_core_perform_new_memory_pool(switch_memory_pool_t **pool, const char *file, const char *func, int line)
static void *SWITCH_THREAD_FUNC pool_thread(switch_thread_t *thread, void *obj)
void * switch_core_memory_pool_get_data(switch_memory_pool_t *pool, const char *key)
char * switch_core_sprintf(switch_memory_pool_t *pool, const char *fmt,...)
switch_status_t switch_queue_trypop(switch_queue_t *queue, void **data)
switch_status_t switch_queue_pop(switch_queue_t *queue, void **data)
static switch_thread_t * thread
switch_memory_pool_t * switch_core_memory_init(void)
switch_queue_t * pool_queue
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
switch_status_t switch_thread_join(switch_status_t *retval, switch_thread_t *thd)
#define SWITCH_MUTEX_NESTED
void switch_core_memory_stop(void)
#define switch_yield(ms)
Wait a desired number of microseconds and yield the CPU.
char * switch_core_perform_session_strdup(switch_core_session_t *session, const char *todup, const char *file, const char *func, int line)
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
#define SWITCH_THREAD_STACKSIZE
static struct @2 memory_manager
switch_status_t switch_mutex_init(switch_mutex_t **lock, unsigned int flags, switch_memory_pool_t *pool)
#define SWITCH_BLANK_STRING
void switch_pool_clear(switch_memory_pool_t *p)
char * switch_core_session_vsprintf(switch_core_session_t *session, const char *fmt, va_list ap)
printf-style style printing routine. The data is output to a string allocated from the session ...
void switch_cond_next(void)
void * switch_core_perform_permanent_alloc(switch_size_t memory, const char *file, const char *func, int line)
char * switch_core_perform_permanent_strdup(const char *todup, const char *file, const char *func, int line)
switch_memory_pool_t * memory_pool
char * switch_core_perform_strdup(switch_memory_pool_t *pool, const char *todup, const char *file, const char *func, int line)
static switch_thread_t * pool_thread_p
struct apr_thread_mutex_t switch_mutex_t
switch_status_t
Common return values.
void * switch_core_perform_session_alloc(switch_core_session_t *session, switch_size_t memory, const char *file, const char *func, int line)
void switch_core_memory_pool_set_data(switch_memory_pool_t *pool, const char *key, void *data)
struct apr_thread_t switch_thread_t
switch_memory_pool_t * switch_core_session_get_pool(switch_core_session_t *session)
char * switch_core_session_sprintf(switch_core_session_t *session, const char *fmt,...)
switch_status_t switch_queue_trypush(switch_queue_t *queue, void *data)
void switch_core_memory_pool_tag(switch_memory_pool_t *pool, const char *tag)
switch_status_t switch_queue_push(switch_queue_t *queue, void *data)
struct apr_pool_t switch_memory_pool_t
void switch_log_printf(_In_ switch_text_channel_t channel, _In_z_ const char *file, _In_z_ const char *func, _In_ int line, _In_opt_z_ const char *userdata, _In_ switch_log_level_t level, _In_z_ _Printf_format_string_ const char *fmt,...) PRINTF_FUNCTION(7
Write log data to the logging engine.
switch_status_t switch_threadattr_create(switch_threadattr_t **new_attr, switch_memory_pool_t *pool)
switch_status_t switch_thread_create(switch_thread_t **new_thread, switch_threadattr_t *attr, switch_thread_start_t func, void *data, switch_memory_pool_t *cont)
switch_status_t switch_queue_create(switch_queue_t **queue, unsigned int queue_capacity, switch_memory_pool_t *pool)
switch_queue_t * pool_recycle_queue
void switch_core_memory_reclaim(void)
void * switch_core_perform_alloc(switch_memory_pool_t *pool, switch_size_t memory, const char *file, const char *func, int line)
char * switch_core_vsprintf(switch_memory_pool_t *pool, const char *fmt, va_list ap)