Ignore:
Timestamp:
Mar 22, 2012 11:29:20 AM (12 years ago)
Author:
nanang
Message:

Close #1466 (using PJLIB outside PJSUA-LIB context):

  • static reference counter for PJLIB init/shutdown.
  • implemented atexit() in PJMEDIA and PJSIP level: pjmedia_endpt_atexit() & pjsip_endpt_atexit().
  • updated pjmedia/transport_srtp.c, pjsip/sip_timer.c, and pjsip/sip_replaces.c to use the new atexit() functions.
  • API change: pjmedia_srtp_init_lib() now requires 'pjmedia_endpt' param.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/branches/1.x/pjlib/src/pj/os_core_unix.c

    r3553 r3986  
    103103 
    104104 
     105/* 
     106 * Flag and reference counter for PJLIB instance. 
     107 */ 
     108static int initialized; 
     109 
    105110#if PJ_HAS_THREADS 
    106111    static pj_thread_t main_thread; 
     
    127132    pj_str_t guid; 
    128133    pj_status_t rc; 
     134 
     135    /* Check if PJLIB have been initialized */ 
     136    if (initialized) { 
     137        ++initialized; 
     138        return PJ_SUCCESS; 
     139    } 
    129140 
    130141#if PJ_HAS_THREADS 
     
    168179#endif    
    169180 
     181    /* Flag PJLIB as initialized */ 
     182    ++initialized; 
     183    pj_assert(initialized == 1); 
     184 
    170185    PJ_LOG(4,(THIS_FILE, "pjlib %s for POSIX initialized", 
    171186              PJ_VERSION)); 
     
    192207{ 
    193208    int i; 
     209 
     210    /* Only perform shutdown operation when 'initialized' reaches zero */ 
     211    pj_assert(initialized > 0); 
     212    if (--initialized != 0) 
     213        return; 
    194214 
    195215    /* Call atexit() functions */ 
Note: See TracChangeset for help on using the changeset viewer.