diff options
author | Benny Prijono <bennylp@teluu.com> | 2012-03-30 07:10:13 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2012-03-30 07:10:13 +0000 |
commit | 6b4964727bffb379aca9601e1cf69051ccbf600c (patch) | |
tree | 1d9739ea8b3b5e0421f1d99b39e798b1514fb644 /pjlib/src/pj/os_core_symbian.cpp | |
parent | 85ac546acb235df62169c4ad317da74a62e56a88 (diff) |
Re #1474: Merged all changes from 1.12 - HEAD (from the 1.x branch)
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@3999 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjlib/src/pj/os_core_symbian.cpp')
-rw-r--r-- | pjlib/src/pj/os_core_symbian.cpp | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/pjlib/src/pj/os_core_symbian.cpp b/pjlib/src/pj/os_core_symbian.cpp index 5446df5d..d6a1df22 100644 --- a/pjlib/src/pj/os_core_symbian.cpp +++ b/pjlib/src/pj/os_core_symbian.cpp @@ -75,6 +75,9 @@ struct pj_sem_t int max; }; +/* Flag and reference counter for PJLIB instance */ +static int initialized; + /* Flags to indicate which TLS variables have been used */ static int tls_vars[PJ_MAX_TLS]; @@ -83,8 +86,6 @@ static unsigned atexit_count; static void (*atexit_func[32])(void); - - ///////////////////////////////////////////////////////////////////////////// // // CPjTimeoutTimer implementation @@ -335,6 +336,12 @@ PJ_DEF(pj_status_t) pj_init(void) char stack_ptr; pj_status_t status; + /* Check if PJLIB have been initialized */ + if (initialized) { + ++initialized; + return PJ_SUCCESS; + } + pj_ansi_strcpy(main_thread.obj_name, "pjthread"); // Init main thread @@ -368,6 +375,10 @@ PJ_DEF(pj_status_t) pj_init(void) stack_ptr = '\0'; #endif + /* Flag PJLIB as initialized */ + ++initialized; + pj_assert(initialized == 1); + PJ_LOG(5,(THIS_FILE, "PJLIB initialized.")); return PJ_SUCCESS; @@ -390,6 +401,11 @@ PJ_DEF(pj_status_t) pj_atexit(pj_exit_callback func) PJ_DEF(void) pj_shutdown(void) { + /* Only perform shutdown operation when 'initialized' reaches zero */ + pj_assert(initialized > 0); + if (--initialized != 0) + return; + /* Call atexit() functions */ while (atexit_count > 0) { (*atexit_func[atexit_count-1])(); |