Ignore:
Timestamp:
Jan 28, 2020 1:47:56 AM (4 years ago)
Author:
riza
Message:

Close #2262: Notify when IP change handling is completed.

File:
1 edited

Legend:

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

    r6015 r6137  
    35723572 
    35733573    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 
    35743583    /* Reset ip_change_active flag. */ 
    35753584    for (; i < (int)PJ_ARRAY_SIZE(pjsua_var.acc); ++i) { 
    35763585        pjsua_var.acc[i].ip_change_op = PJSUA_IP_CHANGE_OP_NULL; 
    35773586        acc_done[i] = PJ_FALSE; 
    3578     }     
    3579      
     3587    } 
     3588 
    35803589    for (i = 0; i < (int)PJ_ARRAY_SIZE(pjsua_var.acc); ++i) { 
    35813590        pj_bool_t shutdown_transport = PJ_FALSE; 
     
    35953604 
    35963605            pjsip_regc_get_info(acc->regc, &regc_info); 
    3597              
     3606 
    35983607            /* Check if transport restart listener succeed. */ 
    35993608            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 && 
    36013610                  pjsua_var.tpdata[j].restart_status != PJ_SUCCESS && 
    36023611                  pjsua_var.tpdata[j].type == regc_info.transport->key.type) 
     
    36053614                                           == regc_info.transport->factory) || 
    36063615                        (pjsua_var.tpdata[j].data.tp 
    3607                                                == regc_info.transport))  
     3616                                               == regc_info.transport)) 
    36083617                    { 
    36093618                        found_restart_tp_fail = PJ_TRUE; 
     
    36233632                    } 
    36243633                } 
    3625                      
     3634                pjsua_acc_end_ip_change(acc); 
    36263635                continue; 
    36273636            } 
     
    36333642                shutdown_transport = acc->cfg.ip_change_cfg.shutdown_tp; 
    36343643                shut_acc_ids[shut_acc_cnt++] = acc->index; 
    3635             }    
     3644            } 
    36363645        } else if (acc->cfg.reg_uri.slen && 
    3637                    acc->reg_last_code != PJSIP_SC_BAD_GATEWAY && 
     3646                   acc->reg_last_code != PJSIP_SC_OK && 
    36383647                   acc->reg_last_code != PJSIP_SC_REQUEST_TIMEOUT && 
    36393648                   acc->reg_last_code != PJSIP_SC_INTERNAL_SERVER_ERROR && 
     
    36413650                   acc->reg_last_code != PJSIP_SC_SERVICE_UNAVAILABLE && 
    36423651                   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) 
    36443653        { 
     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); 
    36453658            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); 
    36483661 
    36493662        if (transport) { 
     
    36563669 
    36573670                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)) 
    36593672                { 
    36603673                    continue; 
     
    36833696        if (shutdown_transport) { 
    36843697            unsigned j; 
    3685             /* Shutdown the transport. */            
     3698            /* Shutdown the transport. */ 
    36863699            PJ_LOG(3, (THIS_FILE, "Shutdown transport %s used by account %s " 
    36873700                       "triggered by IP change", transport->obj_name, acc_id)); 
     
    36943707 
    36953708            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             } 
    37143709        } else { 
    37153710            acc_done[i] = PJ_TRUE; 
     
    37263721 
    37273722 
    3728 static pj_status_t restart_listener(pjsua_transport_id id,  
     3723static pj_status_t restart_listener(pjsua_transport_id id, 
    37293724                                    unsigned restart_lis_delay) 
    37303725{ 
    37313726    pj_sockaddr bind_addr; 
    37323727    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); 
    37363731    pj_sockaddr_init(pjsip_transport_type_get_af(tp_info.type), 
    37373732                     &bind_addr, 
    37383733                     NULL, 
    37393734                     pj_sockaddr_get_port(&tp_info.local_addr)); 
    3740      
     3735 
    37413736    switch (tp_info.type) { 
    37423737    case PJSIP_TRANSPORT_UDP: 
     
    37713766    } 
    37723767 
    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)); 
    37753770 
    37763771    if (status != PJ_SUCCESS && (restart_lis_delay > 0)) { 
    37773772        /* 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, 
    37803775                              restart_lis_delay); 
    37813776 
    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)); 
    37853779 
    37863780        status = PJ_SUCCESS; 
     
    37973791            info.lis_restart.transport_id = id; 
    37983792            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, 
    38013795                                                &info); 
    38023796        } 
     
    38043798        /* Move forward if all listener has been restarted. */ 
    38053799        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) 
    38083802            { 
    38093803                all_done = PJ_FALSE; 
     
    38323826    PJ_ASSERT_RETURN(param, PJ_EINVAL); 
    38333827 
     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 
    38343838    PJ_LOG(3, (THIS_FILE, "Start handling IP address change")); 
    3835      
    38363839    if (param->restart_listener) { 
    38373840        PJSUA_LOCK(); 
     
    38463849        } 
    38473850        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) { 
    38493852                status = restart_listener(i, param->restart_lis_delay); 
    38503853            } 
Note: See TracChangeset for help on using the changeset viewer.