- Timestamp:
- Apr 26, 2012 11:59:34 AM (13 years ago)
- Location:
- pjproject/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk
- Property svn:mergeinfo changed
/pjproject/branches/1.x merged: 4095
- Property svn:mergeinfo changed
-
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_acc.c
r4042 r4096 34 34 35 35 static void schedule_reregistration(pjsua_acc *acc); 36 static void keep_alive_timer_cb(pj_timer_heap_t *th, pj_timer_entry *te); 36 37 37 38 /* … … 573 574 PJ_DEF(pj_status_t) pjsua_acc_del(pjsua_acc_id acc_id) 574 575 { 576 pjsua_acc *acc; 575 577 unsigned i; 576 578 … … 584 586 PJSUA_LOCK(); 585 587 588 acc = &pjsua_var.acc[acc_id]; 589 590 /* Cancel keep-alive timer, if any */ 591 if (acc->ka_timer.id) { 592 pjsip_endpt_cancel_timer(pjsua_var.endpt, &acc->ka_timer); 593 acc->ka_timer.id = PJ_FALSE; 594 } 595 if (acc->ka_transport) { 596 pjsip_transport_dec_ref(acc->ka_transport); 597 acc->ka_transport = NULL; 598 } 599 586 600 /* Cancel any re-registration timer */ 587 pjsua_cancel_timer(& pjsua_var.acc[acc_id].auto_rereg.timer);601 pjsua_cancel_timer(&acc->auto_rereg.timer); 588 602 589 603 /* Delete registration */ 590 if ( pjsua_var.acc[acc_id].regc != NULL) {604 if (acc->regc != NULL) { 591 605 pjsua_acc_set_registration(acc_id, PJ_FALSE); 592 if ( pjsua_var.acc[acc_id].regc) {593 pjsip_regc_destroy( pjsua_var.acc[acc_id].regc);594 } 595 pjsua_var.acc[acc_id].regc = NULL;606 if (acc->regc) { 607 pjsip_regc_destroy(acc->regc); 608 } 609 acc->regc = NULL; 596 610 } 597 611 … … 600 614 601 615 /* Release account pool */ 602 if ( pjsua_var.acc[acc_id].pool) {603 pj_pool_release( pjsua_var.acc[acc_id].pool);604 pjsua_var.acc[acc_id].pool = NULL;616 if (acc->pool) { 617 pj_pool_release(acc->pool); 618 acc->pool = NULL; 605 619 } 606 620 607 621 /* Invalidate */ 608 pjsua_var.acc[acc_id].valid = PJ_FALSE;609 pjsua_var.acc[acc_id].contact.slen = 0;622 acc->valid = PJ_FALSE; 623 acc->contact.slen = 0; 610 624 611 625 /* Remove from array */ … … 866 880 acc->cfg.timer_setting = cfg->timer_setting; 867 881 868 /* Transport and keep-alive*/882 /* Transport */ 869 883 if (acc->cfg.transport_id != cfg->transport_id) { 870 884 acc->cfg.transport_id = cfg->transport_id; 871 885 update_reg = PJ_TRUE; 872 886 } 873 acc->cfg.ka_interval = cfg->ka_interval; 887 888 /* Update keep-alive */ 889 if (acc->cfg.ka_interval != cfg->ka_interval || 890 pj_strcmp(&acc->cfg.ka_data, &cfg->ka_data)) 891 { 892 pjsip_transport *ka_transport = acc->ka_transport; 893 894 if (acc->ka_timer.id) { 895 pjsip_endpt_cancel_timer(pjsua_var.endpt, &acc->ka_timer); 896 acc->ka_timer.id = PJ_FALSE; 897 } 898 if (acc->ka_transport) { 899 pjsip_transport_dec_ref(acc->ka_transport); 900 acc->ka_transport = NULL; 901 } 902 903 acc->cfg.ka_interval = cfg->ka_interval; 904 905 if (cfg->ka_interval) { 906 if (ka_transport) { 907 /* Keep-alive has been running so we can just restart it */ 908 pj_time_val delay; 909 910 pjsip_transport_add_ref(ka_transport); 911 acc->ka_transport = ka_transport; 912 913 acc->ka_timer.cb = &keep_alive_timer_cb; 914 acc->ka_timer.user_data = (void*)acc; 915 916 delay.sec = acc->cfg.ka_interval; 917 delay.msec = 0; 918 status = pjsua_schedule_timer(&acc->ka_timer, &delay); 919 if (status == PJ_SUCCESS) { 920 acc->ka_timer.id = PJ_TRUE; 921 } else { 922 pjsip_transport_dec_ref(ka_transport); 923 acc->ka_transport = NULL; 924 pjsua_perror(THIS_FILE, "Error starting keep-alive timer", 925 status); 926 } 927 928 } else { 929 /* Keep-alive has not been running, we need to (re)register 930 * first. 931 */ 932 update_reg = PJ_TRUE; 933 } 934 } 935 } 936 874 937 if (pj_strcmp(&acc->cfg.ka_data, &cfg->ka_data)) 875 938 pj_strdup(acc->pool, &acc->cfg.ka_data, &cfg->ka_data); … … 1575 1638 } 1576 1639 1640 /* Check just in case keep-alive has been disabled. This shouldn't happen 1641 * though as when ka_interval is changed this timer should have been 1642 * cancelled. 1643 */ 1644 if (acc->cfg.ka_interval == 0) 1645 goto on_return; 1646 1577 1647 /* Reschedule next timer */ 1578 1648 delay.sec = acc->cfg.ka_interval; … … 1585 1655 } 1586 1656 1657 on_return: 1587 1658 PJSUA_UNLOCK(); 1588 1659 }
Note: See TracChangeset
for help on using the changeset viewer.