Changeset 376


Ignore:
Timestamp:
Apr 4, 2006 11:06:34 AM (18 years ago)
Author:
bennylp
Message:

Changed pjsip_dlg_send_request() API to NOT return transaction as it is not safe against race condition

Location:
pjproject/trunk/pjsip
Files:
5 edited

Legend:

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

    r283 r376  
    409409 * @param dlg               The dialog. 
    410410 * @param tdata             The request message to be sent. 
    411  * @param p_tsx             Optional argument to receive the transaction  
    412  *                          instance used to send the request. 
     411 * @param mod_data_id       Optional module data index to put an optional data 
     412 *                          into the transaction. If no module data is to be 
     413 *                          attached, this value should be -1. 
     414 * @param mod_data          Optional module data to be attached to the  
     415 *                          transaction at mod_data_id index. 
    413416 * 
    414417 * @return                  PJ_SUCCESS on success. 
     
    416419PJ_DECL(pj_status_t) pjsip_dlg_send_request (   pjsip_dialog *dlg, 
    417420                                                pjsip_tx_data *tdata, 
    418                                                 pjsip_transaction **p_tsx ); 
     421                                                int mod_data_id, 
     422                                                void *mod_data); 
    419423 
    420424 
  • pjproject/trunk/pjsip/src/pjsip-simple/evsub.c

    r315 r376  
    11491149 
    11501150    /* Send the request. */ 
    1151     status = pjsip_dlg_send_request(sub->dlg, tdata, NULL); 
     1151    status = pjsip_dlg_send_request(sub->dlg, tdata, -1, NULL); 
    11521152    if (status != PJ_SUCCESS) 
    11531153        goto on_return; 
     
    14831483                                               tsx->last_tx, &tdata); 
    14841484            if (status == PJ_SUCCESS)  
    1485                 status = pjsip_dlg_send_request(sub->dlg, tdata, NULL); 
     1485                status = pjsip_dlg_send_request(sub->dlg, tdata, -1, NULL); 
    14861486             
    14871487            if (status != PJ_SUCCESS) { 
     
    18701870                                                tsx->last_tx, &tdata); 
    18711871            if (status == PJ_SUCCESS) 
    1872                 status = pjsip_dlg_send_request( sub->dlg, tdata, NULL ); 
     1872                status = pjsip_dlg_send_request( sub->dlg, tdata, -1, NULL ); 
    18731873 
    18741874            if (status != PJ_SUCCESS) { 
  • pjproject/trunk/pjsip/src/pjsip-ua/sip_inv.c

    r324 r376  
    177177    } 
    178178 
    179     status = pjsip_dlg_send_request(inv->dlg, tdata, NULL); 
     179    status = pjsip_dlg_send_request(inv->dlg, tdata, -1, NULL); 
    180180    if (status != PJ_SUCCESS) { 
    181181        /* Better luck next time */ 
     
    15811581 
    15821582    if (tdata->msg->type == PJSIP_REQUEST_MSG) { 
    1583         pjsip_transaction *tsx; 
    15841583        struct tsx_inv_data *tsx_inv_data; 
    15851584 
    1586         status = pjsip_dlg_send_request(inv->dlg, tdata, &tsx); 
     1585        pjsip_dlg_inc_lock(inv->dlg); 
     1586 
     1587        tsx_inv_data = pj_pool_zalloc(inv->pool, sizeof(struct tsx_inv_data)); 
     1588        tsx_inv_data->inv = inv; 
     1589 
     1590        pjsip_dlg_dec_lock(inv->dlg); 
     1591 
     1592        status = pjsip_dlg_send_request(inv->dlg, tdata, mod_inv.mod.id,  
     1593                                        tsx_inv_data); 
    15871594        if (status != PJ_SUCCESS) 
    15881595            return status; 
    1589  
    1590         tsx_inv_data = pj_pool_zalloc(tsx->pool, sizeof(struct tsx_inv_data)); 
    1591         tsx_inv_data->inv = inv; 
    1592  
    1593         tsx->mod_data[mod_inv.mod.id] = tsx_inv_data; 
    15941596 
    15951597    } else { 
  • pjproject/trunk/pjsip/src/pjsip/sip_dialog.c

    r315 r376  
    932932PJ_DEF(pj_status_t) pjsip_dlg_send_request( pjsip_dialog *dlg, 
    933933                                            pjsip_tx_data *tdata, 
    934                                             pjsip_transaction **p_tsx ) 
     934                                            int mod_data_id, 
     935                                            void *mod_data) 
    935936{ 
    936937    pjsip_transaction *tsx; 
     
    979980        tsx->mod_data[dlg->ua->id] = dlg; 
    980981 
     982        /* Copy optional caller's mod_data, if present */ 
     983        if (mod_data_id >= 0 && mod_data_id < PJSIP_MAX_MODULE) 
     984            tsx->mod_data[mod_data_id] = mod_data; 
     985 
    981986        /* Increment transaction counter. */ 
    982987        ++dlg->tsx_count; 
     
    989994        } 
    990995 
    991         if (p_tsx) 
    992             *p_tsx = tsx; 
    993  
    994996    } else { 
    995997        status = pjsip_endpt_send_request_stateless(dlg->endpt, tdata,  
     
    9981000            goto on_error; 
    9991001 
    1000         if (p_tsx) 
    1001             *p_tsx = NULL; 
    10021002    } 
    10031003 
     
    10141014    pjsip_tx_data_dec_ref( tdata ); 
    10151015 
    1016     if (p_tsx) 
    1017         *p_tsx = NULL; 
    10181016    return status; 
    10191017} 
  • pjproject/trunk/pjsip/src/pjsua-lib/pjsua_call.c

    r368 r376  
    13311331 
    13321332    /* Send the request. */ 
    1333     status = pjsip_dlg_send_request( call->inv->dlg, tdata, NULL); 
     1333    status = pjsip_dlg_send_request( call->inv->dlg, tdata, -1, NULL); 
    13341334    if (status != PJ_SUCCESS) { 
    13351335        pjsua_perror(THIS_FILE, "Unable to send MESSAGE request", status); 
     
    13741374 
    13751375    /* Send the request. */ 
    1376     status = pjsip_dlg_send_request( call->inv->dlg, tdata, NULL); 
     1376    status = pjsip_dlg_send_request( call->inv->dlg, tdata, -1, NULL); 
    13771377    if (status != PJ_SUCCESS) { 
    13781378        pjsua_perror(THIS_FILE, "Unable to send MESSAGE request", status); 
Note: See TracChangeset for help on using the changeset viewer.