Changeset 2646


Ignore:
Timestamp:
Apr 26, 2009 11:02:04 AM (16 years ago)
Author:
bennylp
Message:

Fixed ticket #503: Handle the case when CANCEL is responded with 200/OK but 487 is not sent

  • added new API pjsip_tsx_set_timeout()
  • set 64*T1 timeout after CANCEL is initiated
  • also added SIPp scenario to simulate the UAS
Location:
pjproject/trunk
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip/include/pjsip/sip_transaction.h

    r2394 r2646  
    312312                                           const pjsip_rx_data *rdata ); 
    313313 
    314  
    315314/** 
    316315 * Force terminate transaction. 
     
    331330 * the transaction is cancelled before any provisional response has been 
    332331 * received. 
     332 * 
     333 * @param tsx       The transaction. 
     334 * 
     335 * @return          PJ_SUCCESS or the appropriate error code. 
    333336 */ 
    334337PJ_DECL(pj_status_t) pjsip_tsx_stop_retransmit(pjsip_transaction *tsx); 
     338 
     339 
     340/** 
     341 * Start a timer to terminate transaction after the specified time 
     342 * has elapsed. This function is only valid for INVITE transaction, 
     343 * and only before final response is received for the INVITE transaction. 
     344 * It is normally called after the UAC has sent CANCEL for this 
     345 * INVITE transaction.  
     346 * 
     347 * The purpose of this function is to terminate the transaction if UAS  
     348 * does not send final response to this INVITE transaction even after  
     349 * it sends 200/OK to CANCEL (for example when the UAS complies to RFC 
     350 * 2543). 
     351 * 
     352 * Once this timer is set, the transaction will be terminated either when 
     353 * a final response is received or the timer expires. 
     354 * 
     355 * @param tsx       The transaction. 
     356 * @param millisec  Timeout value in milliseconds. 
     357 * 
     358 * @return          PJ_SUCCESS or the appropriate error code. 
     359 */ 
     360PJ_DECL(pj_status_t) pjsip_tsx_set_timeout(pjsip_transaction *tsx, 
     361                                           unsigned millisec); 
    335362 
    336363 
  • pjproject/trunk/pjsip/src/pjsip-ua/sip_inv.c

    r2643 r2646  
    18871887                                               inv->invite_tsx->last_tx, 
    18881888                                               &tdata); 
     1889            if (status != PJ_SUCCESS) 
     1890                return status; 
     1891 
     1892            /* Set timeout for the INVITE transaction, in case UAS is not 
     1893             * able to respond the INVITE with 487 final response. The  
     1894             * timeout value is 64*T1. 
     1895             */ 
     1896            pjsip_tsx_set_timeout(inv->invite_tsx, 64 * pjsip_cfg()->tsx.t1); 
    18891897 
    18901898        } else { 
  • pjproject/trunk/pjsip/src/pjsip/sip_transaction.c

    r2442 r2646  
    15041504 
    15051505/* 
     1506 * Start a timer to terminate transaction after the specified time 
     1507 * has elapsed.  
     1508 */ 
     1509PJ_DEF(pj_status_t) pjsip_tsx_set_timeout( pjsip_transaction *tsx, 
     1510                                           unsigned millisec) 
     1511{ 
     1512    struct tsx_lock_data lck; 
     1513    pj_time_val timeout; 
     1514 
     1515    PJ_ASSERT_RETURN(tsx != NULL, PJ_EINVAL); 
     1516    PJ_ASSERT_RETURN(tsx->role == PJSIP_ROLE_UAC && 
     1517                     tsx->method.id == PJSIP_INVITE_METHOD, 
     1518                     PJ_EINVALIDOP); 
     1519 
     1520    lock_tsx(tsx, &lck); 
     1521 
     1522    /* Transaction must not have got final response */ 
     1523    PJ_ASSERT_ON_FAIL(tsx->status_code < 200, 
     1524                    { unlock_tsx(tsx, &lck); return PJ_EINVALIDOP; }); 
     1525 
     1526    if (tsx->timeout_timer.id != 0) { 
     1527        pjsip_endpt_cancel_timer(tsx->endpt, &tsx->timeout_timer); 
     1528        tsx->timeout_timer.id = 0; 
     1529    } 
     1530 
     1531    timeout.sec = 0; 
     1532    timeout.msec = millisec; 
     1533    pj_time_val_normalize(&timeout); 
     1534 
     1535    tsx->timeout_timer.id = TIMER_ACTIVE; 
     1536    pjsip_endpt_schedule_timer(tsx->endpt, &tsx->timeout_timer, 
     1537                               &timeout); 
     1538 
     1539 
     1540    unlock_tsx(tsx, &lck); 
     1541 
     1542    return PJ_SUCCESS; 
     1543} 
     1544 
     1545 
     1546/* 
    15061547 * This function is called by TU to send a message. 
    15071548 */ 
Note: See TracChangeset for help on using the changeset viewer.