- Timestamp:
- Oct 14, 2009 1:58:04 AM (15 years ago)
- Location:
- pjproject/trunk/pjsip
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h
r2942 r2943 1726 1726 1727 1727 /** 1728 * Default maximum time to wait for account unregistration transactions to 1729 * complete during library shutdown sequence. 1730 * 1731 * Default: 4000 (4 seconds) 1732 */ 1733 #ifndef PJSUA_UNREG_TIMEOUT 1734 # define PJSUA_UNREG_TIMEOUT 4000 1735 #endif 1736 1737 1738 /** 1728 1739 * Default PUBLISH expiration 1729 1740 */ … … 1919 1930 */ 1920 1931 unsigned reg_timeout; 1932 1933 /** 1934 * Specify the maximum time to wait for unregistration requests to 1935 * complete during library shutdown sequence. 1936 * 1937 * Default: PJSUA_UNREG_TIMEOUT 1938 */ 1939 unsigned unreg_timeout; 1921 1940 1922 1941 /** -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_call.c
r2938 r2943 645 645 if (dlg || tsx) 646 646 return PJ_FALSE; 647 648 /* Don't want to accept the call if shutdown is in progress */ 649 if (pjsua_var.thread_quit_flag) { 650 pjsip_endpt_respond_stateless(pjsua_var.endpt, rdata, 651 PJSIP_SC_TEMPORARILY_UNAVAILABLE, NULL, 652 NULL, NULL); 653 return PJ_TRUE; 654 } 647 655 648 656 PJSUA_LOCK(); -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_core.c
r2942 r2943 162 162 163 163 cfg->reg_timeout = PJSUA_REG_INTERVAL; 164 cfg->unreg_timeout = PJSUA_UNREG_TIMEOUT; 164 165 pjsip_publishc_opt_default(&cfg->publish_opt); 165 166 cfg->unpublish_max_wait_time_msec = PJSUA_UNPUBLISH_MAX_WAIT_TIME_MSEC; … … 304 305 { 305 306 return PJ_FALSE; 307 } 308 309 /* Don't want to handle if shutdown is in progress */ 310 if (pjsua_var.thread_quit_flag) { 311 pjsip_endpt_respond_stateless(pjsua_var.endpt, rdata, 312 PJSIP_SC_TEMPORARILY_UNAVAILABLE, NULL, 313 NULL, NULL); 314 return PJ_TRUE; 306 315 } 307 316 … … 1232 1241 unsigned max_wait; 1233 1242 1243 PJ_LOG(4,(THIS_FILE, "Shutting down...")); 1244 1234 1245 /* Terminate all calls. */ 1235 1246 pjsua_call_hangup_all(); … … 1245 1256 /* Terminate all presence subscriptions. */ 1246 1257 pjsua_pres_shutdown(); 1258 1259 /* Destroy media (to shutdown media transports etc) */ 1260 pjsua_media_subsys_destroy(); 1247 1261 1248 1262 /* Wait for sometime until all publish client sessions are done … … 1291 1305 } 1292 1306 } 1293 }1294 1295 /* Destroy endpoint. */1296 if (pjsua_var.endpt) {1297 1307 1298 1308 /* Terminate any pending STUN resolution */ … … 1306 1316 } 1307 1317 1318 /* Wait until all unregistrations are done (ticket #364) */ 1319 /* First stage, get the maximum wait time */ 1320 max_wait = 100; 1321 for (i=0; i<PJ_ARRAY_SIZE(pjsua_var.acc); ++i) { 1322 if (!pjsua_var.acc[i].valid) 1323 continue; 1324 if (pjsua_var.acc[i].cfg.unreg_timeout > max_wait) 1325 max_wait = pjsua_var.acc[i].cfg.unreg_timeout; 1326 } 1327 1328 /* Second stage, wait for unregistrations to complete */ 1329 for (i=0; i<(int)(max_wait/50); ++i) { 1330 unsigned j; 1331 for (j=0; j<PJ_ARRAY_SIZE(pjsua_var.acc); ++j) { 1332 if (!pjsua_var.acc[j].valid) 1333 continue; 1334 1335 if (pjsua_var.acc[j].regc) 1336 break; 1337 } 1338 if (j != PJ_ARRAY_SIZE(pjsua_var.acc)) 1339 busy_sleep(50); 1340 else 1341 break; 1342 } 1343 /* Note variable 'i' is used below */ 1344 1308 1345 /* Wait for some time to allow unregistration and ICE/TURN 1309 1346 * transports shutdown to complete: 1310 */1311 PJ_LOG(4,(THIS_FILE, "Shutting down..."));1312 busy_sleep(1000);1347 */ 1348 if (i < 20) 1349 busy_sleep(1000 - i*50); 1313 1350 1314 1351 PJ_LOG(4,(THIS_FILE, "Destroying...")); 1315 1316 /* Terminate all calls again, just in case there's new call1317 * picked up during busy_sleep()1318 */1319 pjsua_call_hangup_all();1320 1321 /* Destroy media after all polling is done, as there may be1322 * incoming request that needs handling (e.g. OPTIONS)1323 */1324 pjsua_media_subsys_destroy();1325 1352 1326 1353 /* Must destroy endpoint first before destroying pools in … … 1347 1374 } 1348 1375 } 1349 } else {1350 /* Destroy media */1351 pjsua_media_subsys_destroy();1352 1376 } 1353 1377 -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_media.c
r2869 r2943 640 640 { 641 641 unsigned i; 642 643 PJ_LOG(4,(THIS_FILE, "Shutting down media..")); 642 644 643 645 close_snd_dev(); -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_pres.c
r2942 r2943 683 683 /* Incoming SUBSCRIBE: */ 684 684 685 /* Don't want to accept the request if shutdown is in progress */ 686 if (pjsua_var.thread_quit_flag) { 687 pjsip_endpt_respond_stateless(pjsua_var.endpt, rdata, 688 PJSIP_SC_TEMPORARILY_UNAVAILABLE, NULL, 689 NULL, NULL); 690 return PJ_TRUE; 691 } 692 685 693 PJSUA_LOCK(); 686 694 … … 1722 1730 unsigned i; 1723 1731 1732 PJ_LOG(4,(THIS_FILE, "Shutting down presence..")); 1733 1724 1734 if (pjsua_var.pres_timer.id != 0) { 1725 1735 pjsip_endpt_cancel_timer(pjsua_var.endpt, &pjsua_var.pres_timer);
Note: See TracChangeset
for help on using the changeset viewer.