summaryrefslogtreecommitdiff
path: root/pjlib/src/pj/except.c
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2006-11-21 12:39:31 +0000
committerBenny Prijono <bennylp@teluu.com>2006-11-21 12:39:31 +0000
commit271cf23083b38b3f0d12a36bb1f28e458ee43861 (patch)
treed3c5bc170635051fd0aaa3fa41ba26fc421693f1 /pjlib/src/pj/except.c
parentc0cd0b4450fdcf785bb9184b4d6231d452cb8df5 (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/except.c')
-rw-r--r--pjlib/src/pj/except.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/pjlib/src/pj/except.c b/pjlib/src/pj/except.c
index 1074828f..bb21e05b 100644
--- a/pjlib/src/pj/except.c
+++ b/pjlib/src/pj/except.c
@@ -51,6 +51,14 @@ PJ_DEF(void) pj_throw_exception_(int exception_id)
pj_longjmp(handler->state, exception_id);
}
+static void exception_cleanup(void)
+{
+ if (thread_local_id != -1) {
+ pj_thread_local_free(thread_local_id);
+ thread_local_id = -1;
+ }
+}
+
PJ_DEF(void) pj_push_exception_handler_(struct pj_exception_state_t *rec)
{
struct pj_exception_state_t *parent_handler = NULL;
@@ -58,6 +66,7 @@ PJ_DEF(void) pj_push_exception_handler_(struct pj_exception_state_t *rec)
if (thread_local_id == -1) {
pj_thread_local_alloc(&thread_local_id);
pj_assert(thread_local_id != -1);
+ pj_atexit(&exception_cleanup);
}
parent_handler = pj_thread_local_get(thread_local_id);
rec->prev = parent_handler;