diff options
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])(); |