Ignore:
Timestamp:
Oct 19, 2011 12:45:05 PM (13 years ago)
Author:
bennylp
Message:

Fixed #1216: New pjsua_destroy2() API to allow shutting down the library without sending any outgoing messages

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/branches/1.x/pjsip/src/pjsua-lib/pjsua_core.c

    r3594 r3829  
    12841284 * Destroy pjsua. 
    12851285 */ 
    1286 PJ_DEF(pj_status_t) pjsua_destroy(void) 
     1286PJ_DEF(pj_status_t) pjsua_destroy2(unsigned flags) 
    12871287{ 
    12881288    int i;  /* Must be signed */ 
     
    13031303        unsigned max_wait; 
    13041304 
    1305         PJ_LOG(4,(THIS_FILE, "Shutting down...")); 
     1305        PJ_LOG(4,(THIS_FILE, "Shutting down, flags=%d...", flags)); 
    13061306 
    13071307        /* Terminate all calls. */ 
    1308         pjsua_call_hangup_all(); 
     1308        if ((flags & PJSUA_DESTROY_NO_NETWORK) == 0) { 
     1309            pjsua_call_hangup_all(); 
     1310        } 
    13091311 
    13101312        /* Set all accounts to offline */ 
     
    13171319 
    13181320        /* Terminate all presence subscriptions. */ 
    1319         pjsua_pres_shutdown(); 
     1321        pjsua_pres_shutdown(flags); 
    13201322 
    13211323        /* Destroy media (to shutdown media transports etc) */ 
    1322         pjsua_media_subsys_destroy(); 
     1324        pjsua_media_subsys_destroy(flags); 
    13231325 
    13241326        /* Wait for sometime until all publish client sessions are done 
     
    13341336        } 
    13351337         
     1338        /* No need to wait if we didn't send anything */ 
     1339        if (flags & PJSUA_DESTROY_NO_NETWORK) { 
     1340            max_wait = 0; 
     1341        } 
     1342 
    13361343        /* Second stage, wait for unpublications to complete */ 
    13371344        for (i=0; i<(int)(max_wait/50); ++i) { 
     
    13631370                continue; 
    13641371 
    1365             if (pjsua_var.acc[i].regc) { 
     1372            if (pjsua_var.acc[i].regc && (flags & PJSUA_DESTROY_NO_NETWORK)==0) 
     1373            { 
    13661374                pjsua_acc_set_registration(i, PJ_FALSE); 
    13671375            } 
     
    13881396        } 
    13891397         
     1398        /* No need to wait if we didn't send anything */ 
     1399        if (flags & PJSUA_DESTROY_NO_NETWORK) { 
     1400            max_wait = 0; 
     1401        } 
     1402 
    13901403        /* Second stage, wait for unregistrations to complete */ 
    13911404        for (i=0; i<(int)(max_wait/50); ++i) { 
     
    14081421         * transports shutdown to complete:  
    14091422         */ 
    1410         if (i < 20) 
     1423        if (i < 20 && (flags & PJSUA_DESTROY_NO_NETWORK) == 0) { 
    14111424            busy_sleep(1000 - i*50); 
     1425        } 
    14121426 
    14131427        PJ_LOG(4,(THIS_FILE, "Destroying...")); 
     
    14671481    /* Done. */ 
    14681482    return PJ_SUCCESS; 
     1483} 
     1484 
     1485 
     1486PJ_DEF(pj_status_t) pjsua_destroy(void) 
     1487{ 
     1488    return pjsua_destroy2(0); 
    14691489} 
    14701490 
Note: See TracChangeset for help on using the changeset viewer.