Ignore:
Timestamp:
Oct 13, 2009 2:01:59 PM (15 years ago)
Author:
bennylp
Message:

Ticket #364: Upon unregistration, (un)REGISTER should be sent only after (un)PUBLISH has completed successfully

  • wait for unpublication to complete or some delay expires, before sending unregistration
  • added unpublish_max_wait_time_msec field in account config to control how long to wait
File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip/src/pjsua-lib/pjsua_core.c

    r2940 r2942  
    163163    cfg->reg_timeout = PJSUA_REG_INTERVAL; 
    164164    pjsip_publishc_opt_default(&cfg->publish_opt); 
     165    cfg->unpublish_max_wait_time_msec = PJSUA_UNPUBLISH_MAX_WAIT_TIME_MSEC; 
    165166    cfg->transport_id = PJSUA_INVALID_ID; 
    166167    cfg->allow_contact_rewrite = PJ_TRUE; 
     
    12291230     
    12301231    if (pjsua_var.endpt) { 
     1232        unsigned max_wait; 
     1233 
    12311234        /* Terminate all calls. */ 
    12321235        pjsua_call_hangup_all(); 
     
    12421245        /* Terminate all presence subscriptions. */ 
    12431246        pjsua_pres_shutdown(); 
     1247 
     1248        /* Wait for sometime until all publish client sessions are done 
     1249         * (ticket #364) 
     1250         */ 
     1251        /* First stage, get the maximum wait time */ 
     1252        max_wait = 100; 
     1253        for (i=0; i<PJ_ARRAY_SIZE(pjsua_var.acc); ++i) { 
     1254            if (!pjsua_var.acc[i].valid) 
     1255                continue; 
     1256            if (pjsua_var.acc[i].cfg.unpublish_max_wait_time_msec > max_wait) 
     1257                max_wait = pjsua_var.acc[i].cfg.unpublish_max_wait_time_msec; 
     1258        } 
     1259         
     1260        /* Second stage, wait for unpublications to complete */ 
     1261        for (i=0; i<(int)(max_wait/50); ++i) { 
     1262            unsigned j; 
     1263            for (j=0; j<PJ_ARRAY_SIZE(pjsua_var.acc); ++j) { 
     1264                if (!pjsua_var.acc[j].valid) 
     1265                    continue; 
     1266 
     1267                if (pjsua_var.acc[j].publish_sess) 
     1268                    break; 
     1269            } 
     1270            if (j != PJ_ARRAY_SIZE(pjsua_var.acc)) 
     1271                busy_sleep(50); 
     1272            else 
     1273                break; 
     1274        } 
     1275 
     1276        /* Third stage, forcefully destroy unfinished unpublications */ 
     1277        for (i=0; i<PJ_ARRAY_SIZE(pjsua_var.acc); ++i) { 
     1278            if (pjsua_var.acc[i].publish_sess) { 
     1279                pjsip_publishc_destroy(pjsua_var.acc[i].publish_sess); 
     1280                pjsua_var.acc[i].publish_sess = NULL; 
     1281            } 
     1282        } 
    12441283 
    12451284        /* Unregister all accounts */ 
Note: See TracChangeset for help on using the changeset viewer.