Ignore:
Timestamp:
Feb 15, 2018 1:57:11 PM (6 years ago)
Author:
riza
Message:

Fix #2091: On iOS11, replace_udp_sock() might fail and lead to unusable UDP transport.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip/src/pjsip/sip_transport_udp.c

    r5649 r5737  
    143143        goto on_return; 
    144144 
     145#if defined(PJ_IPHONE_OS_HAS_MULTITASKING_SUPPORT) && \ 
     146            PJ_IPHONE_OS_HAS_MULTITASKING_SUPPORT!=0 
     147    if (-bytes_read == PJ_ESOCKETSTOP) { 
     148        --tp->read_loop_spin; 
     149        /* Try to recover by restarting the transport. */ 
     150        PJ_LOG(4,(tp->base.obj_name, "Restarting SIP UDP transport")); 
     151        status = pjsip_udp_transport_restart2( 
     152                            &tp->base, 
     153                            PJSIP_UDP_TRANSPORT_DESTROY_SOCKET, 
     154                            PJ_INVALID_SOCKET, 
     155                            &tp->base.local_addr, 
     156                            &tp->base.local_name); 
     157 
     158        if (status != PJ_SUCCESS) { 
     159            PJ_PERROR(1,(THIS_FILE, status, 
     160                         "Error restarting SIP UDP transport")); 
     161        } 
     162        return; 
     163    } 
     164#endif 
     165 
    145166    /* 
    146167     * The idea of the loop is to process immediate data received by 
     
    262283                    status != PJ_STATUS_FROM_OS(OSERR_ECONNRESET))  
    263284                { 
    264  
    265285                    PJSIP_ENDPT_LOG_ERROR((rdata->tp_info.transport->endpt, 
    266286                                           rdata->tp_info.transport->obj_name, 
     
    305325    tdata_op_key->tdata = NULL; 
    306326 
     327#if defined(PJ_IPHONE_OS_HAS_MULTITASKING_SUPPORT) && \ 
     328            PJ_IPHONE_OS_HAS_MULTITASKING_SUPPORT!=0 
     329    if (-bytes_sent == PJ_ESOCKETSTOP) { 
     330        pj_status_t status; 
     331        /* Try to recover by restarting the transport. */ 
     332        PJ_LOG(4,(tp->base.obj_name, "Restarting SIP UDP transport")); 
     333        status = pjsip_udp_transport_restart2( 
     334                            &tp->base, 
     335                            PJSIP_UDP_TRANSPORT_DESTROY_SOCKET, 
     336                            PJ_INVALID_SOCKET, 
     337                            &tp->base.local_addr, 
     338                            &tp->base.local_name); 
     339 
     340        if (status != PJ_SUCCESS) { 
     341            PJ_PERROR(1,(THIS_FILE, status, 
     342                         "Error restarting SIP UDP transport")); 
     343        } 
     344        return; 
     345    } 
     346#endif 
     347 
    307348    if (tdata_op_key->callback) { 
    308349        tdata_op_key->callback(&tp->base, tdata_op_key->token, bytes_sent); 
     
    562603 
    563604    pj_assert(a_name->host.slen != 0); 
     605     
     606    if (pj_strcmp(&tp->base.local_name.host, &a_name->host) == 0 && 
     607        tp->base.local_name.port == a_name->port) 
     608    { 
     609        return; 
     610    } 
     611     
    564612    pj_strdup_with_null(tp->base.pool, &tp->base.local_name.host,  
    565613                        &a_name->host); 
     
    11331181        /* Create the socket if it's not specified */ 
    11341182        if (sock == PJ_INVALID_SOCKET) { 
    1135             status = create_socket(local->addr.sa_family, local,  
    1136                                    pj_sockaddr_get_len(local), &sock); 
     1183            status = create_socket(local?local->addr.sa_family:pj_AF_UNSPEC(),  
     1184                                   local, local?pj_sockaddr_get_len(local):0,  
     1185                                   &sock); 
    11371186            if (status != PJ_SUCCESS) 
    11381187                return status; 
Note: See TracChangeset for help on using the changeset viewer.