Changeset 5997


Ignore:
Timestamp:
May 22, 2019 12:39:46 AM (15 months ago)
Author:
ming
Message:

Fixed #2134: STUN server resolution failure causes delay

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjnath/src/pjnath/stun_sock.c

    r5983 r5997  
    6262    pj_ioqueue_op_key_t  send_key;      /* Default send key for app */ 
    6363    pj_ioqueue_op_key_t  int_send_key;  /* Send key for internal    */ 
     64    pj_status_t          last_err;      /* Last error status        */ 
    6465 
    6566    pj_uint16_t          tsx_id[6];     /* .. to match STUN msg     */ 
     
    423424            opt = PJ_DNS_SRV_FALLBACK_A; 
    424425 
     426        stun_sock->last_err = PJ_SUCCESS; 
    425427        status = pj_dns_srv_resolve(domain, &res_name, default_port,  
    426428                                    stun_sock->pool, resolver, opt, 
     
    430432            PJ_PERROR(4,(stun_sock->obj_name, status, 
    431433                         "Failed in pj_dns_srv_resolve()")); 
     434        } else { 
     435            /* DNS SRV callback may have been called here, such as when 
     436             * the result is cached, so we need to check the last error 
     437             * status. If the callback hasn't been called, processing 
     438             * will resume later. 
     439             */ 
     440            status = stun_sock->last_err; 
     441            if (stun_sock->last_err != PJ_SUCCESS) { 
     442                PJ_PERROR(4,(stun_sock->obj_name, status, 
     443                             "Failed in sending Binding request (2)")); 
     444            } 
    432445        } 
    433  
    434         /* Processing will resume when the DNS SRV callback is called */ 
    435446 
    436447    } else { 
     
    578589    /* Handle error */ 
    579590    if (status != PJ_SUCCESS) { 
     591        stun_sock->last_err = status; 
    580592        sess_fail(stun_sock, PJ_STUN_SOCK_DNS_OP, status); 
    581593        pj_grp_lock_release(stun_sock->grp_lock); 
     
    599611 
    600612    /* Start sending Binding request */ 
    601     get_mapped_addr(stun_sock); 
     613    stun_sock->last_err = get_mapped_addr(stun_sock); 
    602614 
    603615    pj_grp_lock_release(stun_sock->grp_lock); 
Note: See TracChangeset for help on using the changeset viewer.