Changeset 6137 for pjproject/trunk/pjsip/src/pjsua-lib/pjsua_core.c
- Timestamp:
- Jan 28, 2020 1:47:56 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_core.c
r6015 r6137 3572 3572 3573 3573 PJSUA_LOCK(); 3574 3575 if (pjsua_var.acc_cnt == 0) { 3576 PJ_LOG(3, (THIS_FILE, 3577 "No account is set, IP change handling will stop")); 3578 pjsua_acc_end_ip_change(NULL); 3579 PJSUA_UNLOCK(); 3580 return status; 3581 } 3582 3574 3583 /* Reset ip_change_active flag. */ 3575 3584 for (; i < (int)PJ_ARRAY_SIZE(pjsua_var.acc); ++i) { 3576 3585 pjsua_var.acc[i].ip_change_op = PJSUA_IP_CHANGE_OP_NULL; 3577 3586 acc_done[i] = PJ_FALSE; 3578 } 3579 3587 } 3588 3580 3589 for (i = 0; i < (int)PJ_ARRAY_SIZE(pjsua_var.acc); ++i) { 3581 3590 pj_bool_t shutdown_transport = PJ_FALSE; … … 3595 3604 3596 3605 pjsip_regc_get_info(acc->regc, ®c_info); 3597 3606 3598 3607 /* Check if transport restart listener succeed. */ 3599 3608 for (; j < PJ_ARRAY_SIZE(pjsua_var.tpdata); ++j) { 3600 if (pjsua_var.tpdata[j].data.ptr != NULL && 3609 if (pjsua_var.tpdata[j].data.ptr != NULL && 3601 3610 pjsua_var.tpdata[j].restart_status != PJ_SUCCESS && 3602 3611 pjsua_var.tpdata[j].type == regc_info.transport->key.type) … … 3605 3614 == regc_info.transport->factory) || 3606 3615 (pjsua_var.tpdata[j].data.tp 3607 == regc_info.transport)) 3616 == regc_info.transport)) 3608 3617 { 3609 3618 found_restart_tp_fail = PJ_TRUE; … … 3623 3632 } 3624 3633 } 3625 3634 pjsua_acc_end_ip_change(acc); 3626 3635 continue; 3627 3636 } … … 3633 3642 shutdown_transport = acc->cfg.ip_change_cfg.shutdown_tp; 3634 3643 shut_acc_ids[shut_acc_cnt++] = acc->index; 3635 } 3644 } 3636 3645 } else if (acc->cfg.reg_uri.slen && 3637 acc->reg_last_code != PJSIP_SC_ BAD_GATEWAY&&3646 acc->reg_last_code != PJSIP_SC_OK && 3638 3647 acc->reg_last_code != PJSIP_SC_REQUEST_TIMEOUT && 3639 3648 acc->reg_last_code != PJSIP_SC_INTERNAL_SERVER_ERROR && … … 3641 3650 acc->reg_last_code != PJSIP_SC_SERVICE_UNAVAILABLE && 3642 3651 acc->reg_last_code != PJSIP_SC_SERVER_TIMEOUT && 3643 acc->reg_last_code != PJSIP_SC_TEMPORARILY_UNAVAILABLE) 3652 acc->reg_last_code != PJSIP_SC_TEMPORARILY_UNAVAILABLE) 3644 3653 { 3654 PJ_LOG(3, (THIS_FILE, "Permanent registration failure, " 3655 "IP change handling will stop for acc %d", acc->index)); 3656 3657 pjsua_acc_end_ip_change(acc); 3645 3658 continue; 3646 } 3647 pj_ansi_snprintf(acc_id, sizeof(acc_id), "#%d", i); 3659 } 3660 pj_ansi_snprintf(acc_id, sizeof(acc_id), "#%d", i); 3648 3661 3649 3662 if (transport) { … … 3656 3669 3657 3670 if (!next_acc->valid || !next_acc->regc || 3658 (next_acc->ip_change_op > PJSUA_IP_CHANGE_OP_NULL)) 3671 (next_acc->ip_change_op > PJSUA_IP_CHANGE_OP_NULL)) 3659 3672 { 3660 3673 continue; … … 3683 3696 if (shutdown_transport) { 3684 3697 unsigned j; 3685 /* Shutdown the transport. */ 3698 /* Shutdown the transport. */ 3686 3699 PJ_LOG(3, (THIS_FILE, "Shutdown transport %s used by account %s " 3687 3700 "triggered by IP change", transport->obj_name, acc_id)); … … 3694 3707 3695 3708 status = pjsip_transport_shutdown2(transport, PJ_TRUE); 3696 3697 /* Report progress to each acc which uses the same transport. */3698 for (j = 0; j < shut_acc_cnt; ++j) {3699 pjsua_acc *tmp_acc = &pjsua_var.acc[shut_acc_ids[j]];3700 3701 if (pjsua_var.ua_cfg.cb.on_ip_change_progress) {3702 pjsua_ip_change_op_info info;3703 3704 pj_bzero(&info, sizeof(info));3705 info.acc_shutdown_tp.acc_id = tmp_acc->index;3706 3707 pjsua_var.ua_cfg.cb.on_ip_change_progress(3708 tmp_acc->ip_change_op,3709 status,3710 &info);3711 }3712 3713 }3714 3709 } else { 3715 3710 acc_done[i] = PJ_TRUE; … … 3726 3721 3727 3722 3728 static pj_status_t restart_listener(pjsua_transport_id id, 3723 static pj_status_t restart_listener(pjsua_transport_id id, 3729 3724 unsigned restart_lis_delay) 3730 3725 { 3731 3726 pj_sockaddr bind_addr; 3732 3727 pjsua_transport_info tp_info; 3733 pj_status_t status; 3734 3735 pjsua_transport_get_info(id, &tp_info); 3728 pj_status_t status; 3729 3730 pjsua_transport_get_info(id, &tp_info); 3736 3731 pj_sockaddr_init(pjsip_transport_type_get_af(tp_info.type), 3737 3732 &bind_addr, 3738 3733 NULL, 3739 3734 pj_sockaddr_get_port(&tp_info.local_addr)); 3740 3735 3741 3736 switch (tp_info.type) { 3742 3737 case PJSIP_TRANSPORT_UDP: … … 3771 3766 } 3772 3767 3773 PJ_PERROR(3,(THIS_FILE, status, "Listener % s restart",3774 pjsip_transport_get_type_name(tp_info.type)));3768 PJ_PERROR(3,(THIS_FILE, status, "Listener %.*s restart", 3769 tp_info.info.slen, tp_info.info.ptr)); 3775 3770 3776 3771 if (status != PJ_SUCCESS && (restart_lis_delay > 0)) { 3777 3772 /* Try restarting again, with delay. */ 3778 pjsua_schedule_timer2(&restart_listener_cb, 3779 (void*)(pj_size_t)id, 3773 pjsua_schedule_timer2(&restart_listener_cb, 3774 (void*)(pj_size_t)id, 3780 3775 restart_lis_delay); 3781 3776 3782 PJ_LOG(3,(THIS_FILE, "Retry listener %s restart in %d ms", 3783 pjsip_transport_get_type_name(tp_info.type), 3784 restart_lis_delay)); 3777 PJ_LOG(3,(THIS_FILE, "Retry listener %.*s restart in %d ms", 3778 tp_info.info.slen, tp_info.info.ptr, restart_lis_delay)); 3785 3779 3786 3780 status = PJ_SUCCESS; … … 3797 3791 info.lis_restart.transport_id = id; 3798 3792 pjsua_var.ua_cfg.cb.on_ip_change_progress( 3799 PJSUA_IP_CHANGE_OP_RESTART_LIS, 3800 status, 3793 PJSUA_IP_CHANGE_OP_RESTART_LIS, 3794 status, 3801 3795 &info); 3802 3796 } … … 3804 3798 /* Move forward if all listener has been restarted. */ 3805 3799 for (; i < PJ_ARRAY_SIZE(pjsua_var.tpdata); ++i) { 3806 if (pjsua_var.tpdata[i].data.ptr != NULL && 3807 pjsua_var.tpdata[i].is_restarting) 3800 if (pjsua_var.tpdata[i].data.ptr != NULL && 3801 pjsua_var.tpdata[i].is_restarting) 3808 3802 { 3809 3803 all_done = PJ_FALSE; … … 3832 3826 PJ_ASSERT_RETURN(param, PJ_EINVAL); 3833 3827 3828 for (; i < (int)PJ_ARRAY_SIZE(pjsua_var.acc); ++i) { 3829 if (pjsua_var.acc[i].valid && 3830 pjsua_var.acc[i].ip_change_op != PJSUA_IP_CHANGE_OP_NULL && 3831 pjsua_var.acc[i].ip_change_op != PJSUA_IP_CHANGE_OP_COMPLETED) 3832 { 3833 PJ_LOG(2, (THIS_FILE, 3834 "Previous IP address change handling still in progress")); 3835 } 3836 } 3837 3834 3838 PJ_LOG(3, (THIS_FILE, "Start handling IP address change")); 3835 3836 3839 if (param->restart_listener) { 3837 3840 PJSUA_LOCK(); … … 3846 3849 } 3847 3850 for (i = 0; i < PJ_ARRAY_SIZE(pjsua_var.tpdata); ++i) { 3848 if (pjsua_var.tpdata[i].data.ptr != NULL) { 3851 if (pjsua_var.tpdata[i].data.ptr != NULL) { 3849 3852 status = restart_listener(i, param->restart_lis_delay); 3850 3853 }
Note: See TracChangeset
for help on using the changeset viewer.