diff options
author | Benny Prijono <bennylp@teluu.com> | 2006-11-21 12:39:31 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2006-11-21 12:39:31 +0000 |
commit | 271cf23083b38b3f0d12a36bb1f28e458ee43861 (patch) | |
tree | d3c5bc170635051fd0aaa3fa41ba26fc421693f1 /pjlib/src/pj/pool_buf.c | |
parent | c0cd0b4450fdcf785bb9184b4d6231d452cb8df5 (diff) |
Fixed handles leak upon program exit, by introducing pj_shutdown() and pj_atexit(). Also fixed handle leaks in SIP transaction layer and SIP endpoint.
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@815 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjlib/src/pj/pool_buf.c')
-rw-r--r-- | pjlib/src/pj/pool_buf.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/pjlib/src/pj/pool_buf.c b/pjlib/src/pj/pool_buf.c index 0da6c5e1..44115f3a 100644 --- a/pjlib/src/pj/pool_buf.c +++ b/pjlib/src/pj/pool_buf.c @@ -29,11 +29,21 @@ struct creation_param }; static int is_initialized; -static long tls; +static long tls = -1; static void* stack_alloc(pj_pool_factory *factory, pj_size_t size); -static pj_status_t initialize() +static void pool_buf_cleanup(void) { + if (tls != -1) { + pj_thread_local_free(tls); + tls = -1; + } +} + +static pj_status_t pool_buf_initialize() +{ + pj_atexit(&pool_buf_cleanup); + stack_based_factory.policy.block_alloc = &stack_alloc; return pj_thread_local_alloc(&tls); } @@ -64,7 +74,7 @@ PJ_DEF(pj_pool_t*) pj_pool_create_on_buf(const char *name, PJ_ASSERT_RETURN(buf && size, NULL); if (!is_initialized) { - if (initialize() != PJ_SUCCESS) + if (pool_buf_initialize() != PJ_SUCCESS) return NULL; is_initialized = 1; } |