Changeset 1192


Ignore:
Timestamp:
Apr 11, 2007 7:48:42 PM (17 years ago)
Author:
bennylp
Message:

Applying ticket #220 to Symbian branch: Bug in retransmission of non-INVITE SIP requests in UAC transaction (thanks Martin Peterzon)

Location:
pjproject/branches/symbian
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • pjproject/branches/symbian/pjlib/src/pj/addr_resolv_sock.c

    r65 r1192  
    5050} 
    5151 
     52/* Resolve the IP address of local machine */ 
     53PJ_DEF(pj_status_t) pj_gethostip(pj_in_addr *addr) 
     54{ 
     55    const pj_str_t *hostname = pj_gethostname(); 
     56    struct pj_hostent he; 
     57    pj_status_t status; 
     58 
     59 
     60#ifdef _MSC_VER 
     61    /* Get rid of "uninitialized he variable" with MS compilers */ 
     62    pj_memset(&he, 0, sizeof(he)); 
     63#endif 
     64 
     65    /* Try with resolving local hostname first */ 
     66    status = pj_gethostbyname(hostname, &he); 
     67    if (status == PJ_SUCCESS) { 
     68        *addr = *(pj_in_addr*)he.h_addr; 
     69    } 
     70 
     71 
     72    /* If we end up with 127.x.x.x, resolve the IP by getting the default 
     73     * interface to connect to some public host. 
     74     */ 
     75    if (status != PJ_SUCCESS || (pj_ntohl(addr->s_addr) >> 24)==127) { 
     76        pj_sock_t fd; 
     77        pj_str_t cp; 
     78        pj_sockaddr_in a; 
     79        int len; 
     80 
     81        status = pj_sock_socket(PJ_AF_INET, PJ_SOCK_DGRAM, 0, &fd); 
     82        if (status != PJ_SUCCESS) { 
     83            return status; 
     84        } 
     85 
     86        cp = pj_str("1.1.1.1"); 
     87        pj_sockaddr_in_init(&a, &cp, 53); 
     88 
     89        status = pj_sock_connect(fd, &a, sizeof(a)); 
     90        if (status != PJ_SUCCESS) { 
     91            pj_sock_close(fd); 
     92            /* Return 127.0.0.1 as the address */ 
     93            return PJ_SUCCESS; 
     94        } 
     95 
     96        len = sizeof(a); 
     97        status = pj_sock_getsockname(fd, &a, &len); 
     98        if (status != PJ_SUCCESS) { 
     99            pj_sock_close(fd); 
     100            /* Return 127.0.0.1 as the address */ 
     101            return PJ_SUCCESS; 
     102        } 
     103 
     104        pj_sock_close(fd); 
     105 
     106        *addr = a.sin_addr; 
     107    } 
     108 
     109    return status; 
     110} 
     111 
     112 
  • pjproject/branches/symbian/pjlib/src/pj/sock_bsd.c

    r788 r1192  
    633633    PJ_ASSERT_RETURN(newsock != NULL, PJ_EINVAL); 
    634634 
    635     hello 
    636  
    637635#if defined(PJ_SOCKADDR_HAS_LEN) && PJ_SOCKADDR_HAS_LEN!=0 
    638636    if (addr) { 
  • pjproject/branches/symbian/pjsip/src/pjsip/sip_transaction.c

    r789 r1192  
    126126static const pj_time_val t1_timer_val = { PJSIP_T1_TIMEOUT/1000,  
    127127                                          PJSIP_T1_TIMEOUT%1000 }; 
     128static const pj_time_val t2_timer_val = { PJSIP_T2_TIMEOUT/1000,  
     129                                          PJSIP_T2_TIMEOUT%1000 }; 
    128130static const pj_time_val t4_timer_val = { PJSIP_T4_TIMEOUT/1000,  
    129131                                          PJSIP_T4_TIMEOUT%1000 }; 
     
    17041706    pj_assert((tsx->transport_flag & TSX_HAS_PENDING_TRANSPORT) == 0); 
    17051707 
    1706     msec_time = (1 << (tsx->retransmit_count)) * PJSIP_T1_TIMEOUT; 
     1708    pj_assert(tsx->status_code < 200); 
     1709 
     1710    if (tsx->status_code >= 100) 
     1711        msec_time = PJSIP_T2_TIMEOUT; 
     1712    else 
     1713        msec_time = (1 << (tsx->retransmit_count)) * PJSIP_T1_TIMEOUT; 
    17071714 
    17081715    if (tsx->role == PJSIP_ROLE_UAC) { 
     
    18791886    } else if (event->type == PJSIP_EVENT_RX_MSG) { 
    18801887        pjsip_msg *msg; 
    1881         //int code; 
     1888        int code; 
    18821889 
    18831890        /* Get message instance */ 
    18841891        msg = event->body.rx_msg.rdata->msg_info.msg; 
    18851892 
    1886         /* Better be a response message. */ 
    1887         if (msg->type != PJSIP_RESPONSE_MSG) 
    1888             return PJSIP_ENOTRESPONSEMSG; 
    1889  
    1890         /* Cancel retransmission timer A. */ 
    1891         if (tsx->retransmit_timer._timer_id != -1) { 
    1892             pjsip_endpt_cancel_timer(tsx->endpt, &tsx->retransmit_timer); 
    1893             tsx->retransmit_timer._timer_id = -1; 
    1894         } 
     1893        code = msg->line.status.code; 
     1894 
     1895        /* If the response is final, cancel both retransmission and timeout 
     1896         * timer. 
     1897         */ 
     1898        if (code >= 200) { 
     1899            if (tsx->retransmit_timer._timer_id != -1) { 
     1900                pjsip_endpt_cancel_timer(tsx->endpt, &tsx->retransmit_timer); 
     1901                tsx->retransmit_timer._timer_id = -1; 
     1902            } 
     1903 
     1904            if (tsx->timeout_timer._timer_id != -1) { 
     1905                pjsip_endpt_cancel_timer(tsx->endpt, &tsx->timeout_timer); 
     1906                tsx->timeout_timer._timer_id = -1; 
     1907            } 
     1908 
     1909        } else { 
     1910            /* Cancel retransmit timer (for non-INVITE transaction, the 
     1911             * retransmit timer will be rescheduled at T2. 
     1912             */ 
     1913            if (tsx->retransmit_timer._timer_id != -1) { 
     1914                pjsip_endpt_cancel_timer(tsx->endpt, &tsx->retransmit_timer); 
     1915                tsx->retransmit_timer._timer_id = -1; 
     1916            } 
     1917 
     1918            /* For provisional response, only cancel retransmit when this 
     1919             * is an INVITE transaction. For non-INVITE, section 17.1.2.1 
     1920             * of RFC 3261 says that: 
     1921             *  - retransmit timer is set to T2 
     1922             *  - timeout timer F is not deleted. 
     1923             */ 
     1924            if (tsx->method.id == PJSIP_INVITE_METHOD) { 
     1925 
     1926                /* Cancel timeout timer */ 
     1927                pjsip_endpt_cancel_timer(tsx->endpt, &tsx->timeout_timer); 
     1928 
     1929            } else { 
     1930                if (!tsx->is_reliable) { 
     1931                    pjsip_endpt_schedule_timer(tsx->endpt,  
     1932                                               &tsx->retransmit_timer, 
     1933                                               &t2_timer_val); 
     1934                } 
     1935            } 
     1936        } 
     1937  
    18951938        tsx->transport_flag &= ~(TSX_HAS_PENDING_RESCHED); 
    1896  
    1897  
    1898         /* Cancel timer B (transaction timeout) */ 
    1899         pjsip_endpt_cancel_timer(tsx->endpt, &tsx->timeout_timer); 
    19001939 
    19011940        /* Discard retransmission message if it is not INVITE. 
     
    22222261        tsx->status_code = msg->line.status.code; 
    22232262    } else { 
    2224         tsx->status_code = PJSIP_SC_TSX_TIMEOUT; 
     2263        if (event->body.timer.entry == &tsx->retransmit_timer) { 
     2264            /* Retransmit message. */ 
     2265            pj_status_t status; 
     2266 
     2267            status = tsx_retransmit( tsx, 1 ); 
     2268             
     2269            return status; 
     2270 
     2271        } else { 
     2272            tsx->status_code = PJSIP_SC_TSX_TIMEOUT; 
     2273        } 
    22252274    } 
    22262275 
     
    22662315        } 
    22672316 
     2317    } else if (event->type == PJSIP_EVENT_TIMER && 
     2318               event->body.timer.entry == &tsx->timeout_timer) { 
     2319 
     2320        /* Inform TU. */ 
     2321        tsx_set_state( tsx, PJSIP_TSX_STATE_TERMINATED,  
     2322                       PJSIP_EVENT_TIMER, &tsx->timeout_timer); 
     2323 
     2324 
    22682325    } else if (tsx->status_code >= 300 && tsx->status_code <= 699) { 
    22692326 
  • pjproject/branches/symbian/pjsip/src/pjsua-lib/pjsua_core.c

    r452 r1192  
    494494 
    495495    /* Init caching pool. */ 
    496     pj_caching_pool_init(&pjsua.cp, &pj_pool_factory_default_policy, 0); 
     496    pj_caching_pool_init(&pjsua.cp, pj_pool_factory_get_default_policy(), 0); 
    497497 
    498498    /* Create memory pool for application. */ 
Note: See TracChangeset for help on using the changeset viewer.