Ignore:
Timestamp:
Jan 7, 2006 6:44:25 PM (18 years ago)
Author:
bennylp
Message:

Added test functions for UAC transaction

File:
1 edited

Legend:

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

    r107 r109  
    3030#include <pj/guid.h> 
    3131#include <pj/log.h> 
     32 
     33#define THIS_FILE   "sip_transaction.c" 
    3234 
    3335/***************************************************************************** 
     
    102104    TSX_HAS_PENDING_SEND        = 4, 
    103105    TSX_HAS_PENDING_DESTROY     = 8, 
     106    TSX_HAS_RESOLVED_SERVER     = 16, 
    104107}; 
    105108 
     
    413416    PJ_ASSERT_RETURN(mod_tsx_layer.endpt==NULL, PJ_EINVALIDOP); 
    414417 
     418    PJ_LOG(5,(THIS_FILE, "Initializing transaction layer module")); 
    415419 
    416420    /* Initialize TLS ID for transaction lock. */ 
     
    462466    } 
    463467 
     468    PJ_LOG(4,(THIS_FILE, "Transaction layer module initialized")); 
     469 
    464470    return PJ_SUCCESS; 
    465471} 
     
    581587    pj_hash_iterator_t it_buf, *it; 
    582588 
     589    PJ_LOG(4,(THIS_FILE, "Stopping transaction layer module")); 
     590 
    583591    pj_mutex_lock(mod_tsx_layer.mutex); 
    584592 
     
    587595    while (it) { 
    588596        pjsip_transaction *tsx = pj_hash_this(mod_tsx_layer.htable, it); 
     597        pj_hash_iterator_t *next = pj_hash_next(mod_tsx_layer.htable, it); 
    589598        if (tsx) 
    590599            tsx_destroy(tsx); 
    591         it = pj_hash_next(mod_tsx_layer.htable, it); 
     600        it = next; 
    592601    } 
    593602 
     
    611620    mod_tsx_layer.endpt = NULL; 
    612621 
     622    PJ_LOG(4,(THIS_FILE, "Transaction layer module destroyed")); 
     623 
    613624    return PJ_SUCCESS; 
    614625} 
     
    628639    /* Find transaction. */ 
    629640    pj_mutex_lock( mod_tsx_layer.mutex ); 
     641 
    630642    tsx = pj_hash_get( mod_tsx_layer.htable, key.ptr, key.slen ); 
     643 
    631644    if (tsx == NULL || tsx->state == PJSIP_TSX_STATE_TERMINATED) { 
    632645        /* Transaction not found. 
     
    667680    /* Find transaction. */ 
    668681    pj_mutex_lock( mod_tsx_layer.mutex ); 
     682 
    669683    tsx = pj_hash_get( mod_tsx_layer.htable, key.ptr, key.slen ); 
     684 
    670685    if (tsx == NULL || tsx->state == PJSIP_TSX_STATE_TERMINATED) { 
    671686        /* Transaction not found. 
     
    791806static void tsx_destroy( pjsip_transaction *tsx ) 
    792807{ 
     808    struct tsx_lock_data *lck; 
     809 
     810    /* Decrement transport reference counter. */ 
     811    if (tsx->transport) { 
     812        pjsip_transport_dec_ref( tsx->transport ); 
     813        tsx->transport = NULL; 
     814    } 
     815    /* Free last transmitted message. */ 
     816    if (tsx->last_tx) { 
     817        pjsip_tx_data_dec_ref( tsx->last_tx ); 
     818        tsx->last_tx = NULL; 
     819    } 
     820    /* Cancel timeout timer. */ 
     821    if (tsx->timeout_timer._timer_id != -1) { 
     822        pjsip_endpt_cancel_timer(tsx->endpt, &tsx->timeout_timer); 
     823        tsx->timeout_timer._timer_id = -1; 
     824    } 
     825    /* Cancel retransmission timer. */ 
     826    if (tsx->retransmit_timer._timer_id != -1) { 
     827        pjsip_endpt_cancel_timer(tsx->endpt, &tsx->retransmit_timer); 
     828        tsx->retransmit_timer._timer_id = -1; 
     829    } 
     830 
     831    /* Clear some pending flags. */ 
     832    tsx->transport_flag &= ~(TSX_HAS_PENDING_RESCHED | TSX_HAS_PENDING_SEND); 
     833 
     834    /* Refuse to destroy transaction if it has pending resolving. */ 
     835    if (tsx->transport_flag & TSX_HAS_PENDING_TRANSPORT) { 
     836        tsx->transport_flag |= TSX_HAS_PENDING_DESTROY; 
     837        PJ_LOG(5,(tsx->obj_name, "Will destroy later because transport is " 
     838                                 "in progress")); 
     839        return; 
     840    } 
     841 
     842    /* Clear TLS, so that mutex will not be unlocked */ 
     843    lck = pj_thread_local_get(pjsip_tsx_lock_tls_id); 
     844    while (lck) { 
     845        if (lck->tsx == tsx) { 
     846            lck->is_alive = 0; 
     847        } 
     848        lck = lck->prev; 
     849    } 
     850 
    793851    pj_mutex_destroy(tsx->mutex); 
     852 
     853    PJ_LOG(5,(tsx->obj_name, "Transaction destroyed!")); 
     854 
    794855    pjsip_endpt_release_pool(tsx->endpt, tsx->pool); 
    795856} 
     
    807868    PJ_UNUSED_ARG(theap); 
    808869 
    809     PJ_LOG(5,(tsx->obj_name, "got timer event (%s timer)",  
     870    PJ_LOG(6,(tsx->obj_name, "%s timer event",  
    810871             (entry->id==TSX_TIMER_RETRANSMISSION ? "Retransmit":"Timeout"))); 
    811872 
     
    832893                           void *event_src ) 
    833894{ 
    834     PJ_LOG(4, (tsx->obj_name, "STATE %s-->%s, cause = %s", 
     895    PJ_LOG(5, (tsx->obj_name, "State changed from %s to %s, event=%s", 
    835896               state_str[tsx->state], state_str[state],  
    836897               pjsip_event_str(event_src_type))); 
     
    860921        pj_time_val timeout = {0, 0}; 
    861922 
    862         /* Decrement transport reference counter. */ 
    863         if (tsx->transport) { 
    864             pjsip_transport_dec_ref( tsx->transport ); 
    865             tsx->transport = NULL; 
    866         } 
    867         /* Free last transmitted message. */ 
    868         if (tsx->last_tx) { 
    869             pjsip_tx_data_dec_ref( tsx->last_tx ); 
    870             tsx->last_tx = NULL; 
    871         } 
    872         /* Cancel timeout timer. */ 
    873         if (tsx->timeout_timer._timer_id != -1) { 
    874             pjsip_endpt_cancel_timer(tsx->endpt, &tsx->timeout_timer); 
    875             tsx->timeout_timer._timer_id = -1; 
    876         } 
    877         /* Cancel retransmission timer. */ 
    878         if (tsx->retransmit_timer._timer_id != -1) { 
    879             pjsip_endpt_cancel_timer(tsx->endpt, &tsx->retransmit_timer); 
    880             tsx->retransmit_timer._timer_id = -1; 
    881         } 
    882  
    883923        /* Reschedule timeout timer to destroy this transaction. */ 
    884924        if (tsx->transport_flag & TSX_HAS_PENDING_TRANSPORT) { 
    885925            tsx->transport_flag |= TSX_HAS_PENDING_DESTROY; 
    886926        } else { 
     927            /* Cancel timeout timer. */ 
     928            if (tsx->timeout_timer._timer_id != -1) { 
     929                pjsip_endpt_cancel_timer(tsx->endpt, &tsx->timeout_timer); 
     930                tsx->timeout_timer._timer_id = -1; 
     931            } 
     932 
    887933            pjsip_endpt_schedule_timer( tsx->endpt, &tsx->timeout_timer,  
    888934                                        &timeout); 
     
    891937 
    892938    } else if (state == PJSIP_TSX_STATE_DESTROYED) { 
    893  
    894         /* Clear TLS, so that mutex will not be unlocked */ 
    895         struct tsx_lock_data *lck = pj_thread_local_get(pjsip_tsx_lock_tls_id); 
    896         while (lck) { 
    897             if (lck->tsx == tsx) { 
    898                 lck->is_alive = 0; 
    899             } 
    900             lck = lck->prev; 
    901         } 
    902939 
    903940        /* Unregister transaction. */ 
     
    921958    pjsip_cseq_hdr *cseq; 
    922959    pjsip_via_hdr *via; 
     960    pjsip_host_info dst_info; 
    923961    struct tsx_lock_data lck; 
    924962    pj_status_t status; 
     
    9991037    pjsip_tx_data_add_ref(tsx->last_tx); 
    10001038 
     1039    /* Determine whether reliable transport should be used initially. 
     1040     * This will be updated whenever transport has changed. 
     1041     */ 
     1042    status = pjsip_get_request_addr(tdata, &dst_info); 
     1043    if (status != PJ_SUCCESS) { 
     1044        tsx_destroy(tsx); 
     1045        return status; 
     1046    } 
     1047    tsx->is_reliable = (dst_info.flag & PJSIP_TRANSPORT_RELIABLE); 
    10011048 
    10021049    /* Register transaction to hash table. */ 
     
    10061053    /* Unlock transaction and return. */ 
    10071054    unlock_tsx(tsx, &lck); 
     1055 
     1056    PJ_LOG(5,(tsx->obj_name, "Transaction created for %s", 
     1057              pjsip_tx_data_get_info(tdata))); 
    10081058 
    10091059    *p_tsx = tsx; 
     
    11131163    unlock_tsx(tsx, &lck); 
    11141164 
     1165 
     1166    PJ_LOG(5,(tsx->obj_name, "Transaction created for %s", 
     1167              pjsip_rx_data_get_info(rdata))); 
     1168 
     1169 
    11151170    *p_tsx = tsx; 
    11161171    return PJ_SUCCESS; 
     
    11271182    PJ_ASSERT_RETURN(tsx != NULL, PJ_EINVAL); 
    11281183    PJ_ASSERT_RETURN(code >= 200, PJ_EINVAL); 
     1184 
     1185    if (tsx->state == PJSIP_TSX_STATE_TERMINATED) 
     1186        return PJ_SUCCESS; 
    11291187 
    11301188    lock_tsx(tsx, &lck); 
     
    11521210    PJ_ASSERT_RETURN(tdata != NULL, PJ_EINVALIDOP); 
    11531211 
    1154     PJ_LOG(5,(tsx->obj_name, "Request to transmit msg on state %s (tdata=%p)", 
    1155                              state_str[tsx->state], tdata)); 
     1212    PJ_LOG(5,(tsx->obj_name, "Sending %s in state %s", 
     1213                             pjsip_tx_data_get_info(tdata), 
     1214                             state_str[tsx->state])); 
    11561215 
    11571216    PJSIP_EVENT_INIT_TX_MSG(event, tsx, tdata); 
     
    11621221    unlock_tsx(tsx, &lck); 
    11631222 
     1223    /* Will always decrement tdata reference counter 
     1224     * (consistent with other send functions. 
     1225     */ 
     1226    pjsip_tx_data_dec_ref(tdata); 
     1227 
    11641228    return status; 
    11651229} 
     
    11761240    pj_status_t status; 
    11771241 
    1178     PJ_LOG(5,(tsx->obj_name, "Incoming msg on state %s (rdata=%p)",  
    1179               state_str[tsx->state], rdata)); 
     1242    PJ_LOG(5,(tsx->obj_name, "Incoming %s in state %s",  
     1243              pjsip_rx_data_get_info(rdata), state_str[tsx->state])); 
    11801244 
    11811245    /* Put the transaction in the rdata's mod_data. */ 
     
    12061270 
    12071271        if (tsx->transport != send_state->cur_transport) { 
     1272            /* Update transport. */ 
    12081273            if (tsx->transport) { 
    12091274                pjsip_transport_dec_ref(tsx->transport); 
     
    12121277            tsx->transport = send_state->cur_transport; 
    12131278            pjsip_transport_add_ref(tsx->transport); 
     1279 
     1280            /* Update remote address. */ 
     1281            tsx->addr_len = send_state->addr.entry[send_state->cur_addr].addr_len; 
     1282            pj_memcpy(&tsx->addr,  
     1283                      &send_state->addr.entry[send_state->cur_addr].addr, 
     1284                      tsx->addr_len); 
     1285 
     1286            /* Update is_reliable flag. */ 
     1287            tsx->is_reliable = PJSIP_TRANSPORT_IS_RELIABLE(tsx->transport); 
    12141288        } 
    12151289 
    12161290        /* Clear pending transport flag. */ 
    12171291        tsx->transport_flag &= ~(TSX_HAS_PENDING_TRANSPORT); 
     1292 
     1293        /* Mark that we have resolved the addresses. */ 
     1294        tsx->transport_flag |= TSX_HAS_RESOLVED_SERVER; 
    12181295 
    12191296        /* Pending destroy? */ 
     
    12341311        if (tsx->transport_flag & TSX_HAS_PENDING_RESCHED) { 
    12351312            tsx->transport_flag &= ~(TSX_HAS_PENDING_RESCHED); 
    1236             tsx_resched_retransmission(tsx); 
     1313 
     1314            /* Only update when transport turns out to be unreliable. */ 
     1315            if (!tsx->is_reliable) { 
     1316                tsx_resched_retransmission(tsx); 
     1317            } 
    12371318        } 
    12381319 
     
    12521333 
    12531334        if (!*cont) { 
    1254             PJ_LOG(4,(tsx->obj_name, "Failed to send message! status=%d", 
    1255                       -sent)); 
     1335            char errmsg[PJSIP_ERR_MSG_SIZE]; 
     1336 
     1337            PJ_LOG(4,(tsx->obj_name,  
     1338                      "Failed to send %s! err=%d (%s)", 
     1339                      pjsip_tx_data_get_info(send_state->tdata), -sent, 
     1340                      pjsip_strerror(-sent, errmsg, sizeof(errmsg)).ptr)); 
    12561341 
    12571342            /* Clear pending transport flag. */ 
    12581343            tsx->transport_flag &= ~(TSX_HAS_PENDING_TRANSPORT); 
    12591344 
    1260             /* Terminate transaction. */ 
     1345            /* Mark that we have resolved the addresses. */ 
     1346            tsx->transport_flag |= TSX_HAS_RESOLVED_SERVER; 
     1347 
     1348            /* Terminate transaction, if it's not already terminated. */ 
    12611349            tsx->status_code = PJSIP_SC_TSX_TRANSPORT_ERROR; 
    1262             tsx_set_state( tsx, PJSIP_TSX_STATE_TERMINATED,  
    1263                            PJSIP_EVENT_TRANSPORT_ERROR, send_state->tdata ); 
     1350            if (tsx->state != PJSIP_TSX_STATE_TERMINATED && 
     1351                tsx->state != PJSIP_TSX_STATE_DESTROYED) 
     1352            { 
     1353                tsx_set_state( tsx, PJSIP_TSX_STATE_TERMINATED,  
     1354                               PJSIP_EVENT_TRANSPORT_ERROR, send_state->tdata); 
     1355            } 
     1356 
     1357        } else { 
     1358            char errmsg[PJSIP_ERR_MSG_SIZE]; 
     1359 
     1360            PJ_LOG(4,(tsx->obj_name,  
     1361                      "Temporary failure in sending %s, " 
     1362                      "will try next server. Err=%d (%s)", 
     1363                      pjsip_tx_data_get_info(send_state->tdata), -sent, 
     1364                      pjsip_strerror(-sent, errmsg, sizeof(errmsg)).ptr)); 
    12641365        } 
    12651366    } 
     
    12761377        pjsip_transaction *tsx = token; 
    12771378        struct tsx_lock_data lck; 
    1278  
    1279         PJ_LOG(4,(tsx->obj_name, "Failed to send message! status=%d", 
    1280                   -sent)); 
     1379        char errmsg[PJSIP_ERR_MSG_SIZE]; 
     1380 
     1381        PJ_LOG(4,(tsx->obj_name, "Transport failed to send %s! Err=%d (%s)", 
     1382                  pjsip_tx_data_get_info(tdata), -sent, 
     1383                  pjsip_strerror(-sent, errmsg, sizeof(errmsg)).ptr)); 
    12811384 
    12821385        lock_tsx(tsx, &lck); 
     
    13011404                                 pjsip_tx_data *tdata) 
    13021405{ 
    1303     pj_status_t status = PJ_EBUG; 
     1406    pj_status_t status = PJ_SUCCESS; 
    13041407 
    13051408    PJ_ASSERT_RETURN(tsx && tdata, PJ_EINVAL); 
     
    13111414    } 
    13121415 
     1416    /* If we have the transport, send the message using that transport. 
     1417     * Otherwise perform full transport resolution. 
     1418     */ 
     1419    if (tsx->transport) { 
     1420        status = pjsip_transport_send( tsx->transport, tdata, &tsx->addr, 
     1421                                       tsx->addr_len, tsx,  
     1422                                       &transport_callback); 
     1423        if (status == PJ_EPENDING) 
     1424            status = PJ_SUCCESS; 
     1425 
     1426        if (status != PJ_SUCCESS) { 
     1427            char errmsg[PJSIP_ERR_MSG_SIZE]; 
     1428 
     1429            PJ_LOG(4,(tsx->obj_name,  
     1430                      "Error sending %s: Err=%d (%s)", 
     1431                      pjsip_tx_data_get_info(tdata), status,  
     1432                      pjsip_strerror(status, errmsg, sizeof(errmsg)).ptr)); 
     1433 
     1434            /* On error, release transport to force using full transport 
     1435             * resolution procedure. 
     1436             */ 
     1437            if (tsx->transport) { 
     1438                pjsip_transport_dec_ref(tsx->transport); 
     1439                tsx->transport = NULL; 
     1440            } 
     1441            tsx->addr_len = 0; 
     1442            tsx->res_addr.transport = NULL; 
     1443            tsx->res_addr.addr_len = 0; 
     1444        } else { 
     1445            return PJ_SUCCESS; 
     1446        } 
     1447    } 
     1448 
     1449    /* We are here because we don't have transport, or we failed to send 
     1450     * the message using existing transport. If we haven't resolved the 
     1451     * server before, then begin the long process of resolving the server 
     1452     * and send the message with possibly new server. 
     1453     */ 
     1454    pj_assert(status != PJ_SUCCESS || tsx->transport == NULL); 
     1455 
     1456    /* If we have resolved the server, we treat the error as permanent error. 
     1457     * Terminate transaction with transport error failure. 
     1458     */ 
     1459    if (tsx->transport_flag & TSX_HAS_RESOLVED_SERVER) { 
     1460         
     1461        char errmsg[PJSIP_ERR_MSG_SIZE]; 
     1462 
     1463        if (status == PJ_SUCCESS) { 
     1464            pj_assert(!"Unexpected status!"); 
     1465            status = PJ_EUNKNOWN; 
     1466        } 
     1467 
     1468        /* We have resolved the server!. 
     1469         * Treat this as permanent transport error. 
     1470         */ 
     1471        PJ_LOG(4,(tsx->obj_name,  
     1472                  "Transport error, terminating transaction. " 
     1473                  "Err=%d (%s)", 
     1474                  status,  
     1475                  pjsip_strerror(status, errmsg, sizeof(errmsg)).ptr)); 
     1476 
     1477        tsx->status_code = PJSIP_SC_TSX_TRANSPORT_ERROR; 
     1478        tsx_set_state( tsx, PJSIP_TSX_STATE_TERMINATED,  
     1479                       PJSIP_EVENT_TRANSPORT_ERROR, NULL ); 
     1480 
     1481        return status; 
     1482    } 
     1483 
     1484    /* Must add reference counter because the send request functions 
     1485     * decrement the reference counter. 
     1486     */ 
     1487    pjsip_tx_data_add_ref(tdata); 
     1488 
     1489    /* Begin resolving destination etc to send the message. */ 
    13131490    if (tdata->msg->type == PJSIP_REQUEST_MSG) { 
    1314         /* If we have the transport, send the message using that transport. 
    1315          * Otherwise perform full transport resolution. 
    1316          */ 
    1317         if (tsx->transport) { 
    1318             status = pjsip_transport_send( tsx->transport, tdata, &tsx->addr, 
    1319                                            tsx->addr_len, tsx,  
    1320                                            &transport_callback); 
    1321             if (status == PJ_EPENDING) 
    1322                 status = PJ_SUCCESS; 
    1323  
    1324             if (status != PJ_SUCCESS) { 
    1325                 /* On error, release transport to force using full transport 
    1326                  * resolution procedure. 
    1327                  */ 
    1328                 if (tsx->transport) { 
    1329                     pjsip_transport_dec_ref(tsx->transport); 
    1330                     tsx->transport = NULL; 
    1331                 } 
    1332                 tsx->addr_len = 0; 
    1333             } 
    1334         } 
     1491 
     1492        tsx->transport_flag |= TSX_HAS_PENDING_TRANSPORT; 
     1493        status = pjsip_endpt_send_request_stateless(tsx->endpt, tdata, tsx, 
     1494                                                    &send_msg_callback); 
     1495        if (status == PJ_EPENDING) 
     1496            status = PJ_SUCCESS; 
     1497        if (status != PJ_SUCCESS) 
     1498            pjsip_tx_data_dec_ref(tdata); 
    13351499         
    1336         if (!tsx->transport) { 
    1337             tsx->transport_flag |= TSX_HAS_PENDING_TRANSPORT; 
    1338             status = pjsip_endpt_send_request_stateless(tsx->endpt, tdata, tsx, 
    1339                                                         &send_msg_callback); 
    1340             if (status == PJ_EPENDING) 
    1341                 status = PJ_SUCCESS; 
    1342         } 
     1500        /* Check if transaction is terminated. */ 
     1501        if (status==PJ_SUCCESS && tsx->state == PJSIP_TSX_STATE_TERMINATED) 
     1502            status = PJSIP_ETSXDESTROYED; 
    13431503 
    13441504    } else { 
    1345         /* If we have the transport, send the message using that transport. 
    1346          * Otherwise perform full transport resolution. 
    1347          */ 
    1348         if (tsx->transport) { 
    1349             status = pjsip_transport_send( tsx->transport, tdata,  
    1350                                            &tsx->addr, tsx->addr_len, 
    1351                                            tsx, &transport_callback); 
    1352             if (status == PJ_EPENDING) 
    1353                 status = PJ_SUCCESS; 
    1354  
    1355             if (status != PJ_SUCCESS) { 
    1356                 if (tsx->transport) { 
    1357                     pjsip_transport_dec_ref(tsx->transport); 
    1358                     tsx->transport = NULL; 
    1359                 } 
    1360                 tsx->addr_len = 0; 
    1361                 tsx->res_addr.transport = NULL; 
    1362                 tsx->res_addr.addr_len = 0; 
    1363             } 
    1364  
    1365         }  
    1366  
    1367         if (!tsx->transport) { 
    1368             tsx->transport_flag |= TSX_HAS_PENDING_TRANSPORT; 
    1369             status = pjsip_endpt_send_response( tsx->endpt, &tsx->res_addr,  
    1370                                                 tdata, tsx,  
    1371                                                 &send_msg_callback); 
    1372             if (status == PJ_EPENDING) 
    1373                 status = PJ_SUCCESS; 
    1374         } 
    1375     } 
     1505 
     1506        tsx->transport_flag |= TSX_HAS_PENDING_TRANSPORT; 
     1507        status = pjsip_endpt_send_response( tsx->endpt, &tsx->res_addr,  
     1508                                            tdata, tsx,  
     1509                                            &send_msg_callback); 
     1510        if (status == PJ_EPENDING) 
     1511            status = PJ_SUCCESS; 
     1512        if (status != PJ_SUCCESS) 
     1513            pjsip_tx_data_dec_ref(tdata); 
     1514 
     1515        /* Check if transaction is terminated. */ 
     1516        if (status==PJ_SUCCESS && tsx->state == PJSIP_TSX_STATE_TERMINATED) 
     1517            status = PJSIP_ETSXDESTROYED; 
     1518 
     1519    } 
     1520 
    13761521 
    13771522    return status; 
     
    14091554    PJ_ASSERT_RETURN(tsx->last_tx!=NULL, PJ_EBUG); 
    14101555 
    1411     PJ_LOG(4,(tsx->obj_name, "retransmiting (tdata=%p, count=%d, restart?=%d)",  
    1412               tsx->last_tx, tsx->retransmit_count, resched)); 
     1556    PJ_LOG(5,(tsx->obj_name, "Retransmiting %s, count=%d, restart?=%d",  
     1557              pjsip_tx_data_get_info(tsx->last_tx),  
     1558              tsx->retransmit_count, resched)); 
    14131559 
    14141560    ++tsx->retransmit_count; 
     
    14521598        pjsip_tx_data *tdata; 
    14531599 
    1454         /* Must be transmit event. */ 
     1600        /* Must be transmit event.  
     1601         * You may got this assertion when using loop transport with delay  
     1602         * set to zero. That would cause on_rx_response() callback to be  
     1603         * called before tsx_send_msg() has completed. 
     1604         */ 
    14551605        PJ_ASSERT_RETURN(event->type == PJSIP_EVENT_TX_MSG, PJ_EBUG); 
    14561606 
     
    14831633         * transport is being used. 
    14841634         */ 
    1485         if (!PJSIP_TRANSPORT_IS_RELIABLE(tsx->transport))  { 
     1635        if (!tsx->is_reliable)  { 
    14861636            tsx->retransmit_count = 0; 
    14871637            if (tsx->transport_flag & TSX_HAS_PENDING_TRANSPORT) { 
     
    15281678 
    15291679        /* Cancel retransmission timer. */ 
    1530         if (PJSIP_TRANSPORT_IS_RELIABLE(tsx->transport)==0) { 
     1680        if (tsx->retransmit_timer._timer_id != -1) { 
    15311681            pjsip_endpt_cancel_timer(tsx->endpt, &tsx->retransmit_timer); 
    1532         } 
     1682            tsx->retransmit_timer._timer_id = -1; 
     1683        } 
     1684        tsx->transport_flag &= ~(TSX_HAS_PENDING_RESCHED); 
    15331685 
    15341686        /* Set status code */ 
     
    15541706 
    15551707        /* Cancel retransmission timer A. */ 
    1556         if (PJSIP_TRANSPORT_IS_RELIABLE(tsx->transport)==0) 
     1708        if (tsx->retransmit_timer._timer_id != -1) { 
    15571709            pjsip_endpt_cancel_timer(tsx->endpt, &tsx->retransmit_timer); 
     1710            tsx->retransmit_timer._timer_id = -1; 
     1711        } 
     1712        tsx->transport_flag &= ~(TSX_HAS_PENDING_RESCHED); 
     1713 
    15581714 
    15591715        /* Cancel timer B (transaction timeout) */ 
     
    17391895                 * reliable transport. 
    17401896                 */ 
    1741                 if (!PJSIP_TRANSPORT_IS_RELIABLE(tsx->transport)) { 
     1897                if (!tsx->is_reliable) { 
    17421898                    timeout = timeout_timer_val; 
    17431899                } else { 
     
    17701926             * timer G will be scheduled (retransmission). 
    17711927             */ 
    1772             if (!PJSIP_TRANSPORT_IS_RELIABLE(tsx->transport)) { 
     1928            if (!tsx->is_reliable) { 
    17731929                pjsip_cseq_hdr *cseq = pjsip_msg_find_hdr( msg, PJSIP_H_CSEQ, 
    17741930                                                           NULL); 
     
    18942050            /* For unreliable transport, start timer D (for INVITE) or  
    18952051             * timer K for non-INVITE. */ 
    1896             if (PJSIP_TRANSPORT_IS_RELIABLE(tsx->transport) == 0) { 
     2052            if (!tsx->is_reliable) { 
    18972053                if (tsx->method.id == PJSIP_INVITE_METHOD) { 
    18982054                    timeout = td_timer_val; 
     
    19402096 
    19412097        /* Start Timer D with TD/T4 timer if unreliable transport is used. */ 
    1942         if (!PJSIP_TRANSPORT_IS_RELIABLE(tsx->transport)) { 
     2098        if (!tsx->is_reliable) { 
    19432099            if (tsx->method.id == PJSIP_INVITE_METHOD) { 
    19442100                timeout = td_timer_val; 
     
    19932149 
    19942150            /* Cease retransmission. */ 
    1995             pjsip_endpt_cancel_timer( tsx->endpt, &tsx->retransmit_timer ); 
     2151            if (tsx->retransmit_timer._timer_id != -1) { 
     2152                pjsip_endpt_cancel_timer(tsx->endpt, &tsx->retransmit_timer); 
     2153                tsx->retransmit_timer._timer_id = -1; 
     2154            } 
     2155            tsx->transport_flag &= ~(TSX_HAS_PENDING_RESCHED); 
    19962156 
    19972157            /* Start timer I in T4 interval (transaction termination). */ 
Note: See TracChangeset for help on using the changeset viewer.