Ignore:
Timestamp:
Mar 6, 2015 6:09:22 AM (9 years ago)
Author:
ming
Message:

Fixed #1821: Remove unnecessary locking in pjsip transaction and add new API to create a group lock with handler in a single atomic instruction

File:
1 edited

Legend:

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

    r4964 r4992  
    10081008    if (grp_lock) { 
    10091009        tsx->grp_lock = grp_lock; 
     1010         
     1011        pj_grp_lock_add_ref(tsx->grp_lock); 
     1012        pj_grp_lock_add_handler(tsx->grp_lock, tsx->pool, tsx, &tsx_on_destroy); 
    10101013    } else { 
    1011         status = pj_grp_lock_create(pool, NULL, &tsx->grp_lock); 
     1014        status = pj_grp_lock_create_w_handler(pool, NULL, tsx, &tsx_on_destroy, 
     1015                                              &tsx->grp_lock); 
    10121016        if (status != PJ_SUCCESS) { 
    10131017            pjsip_endpt_release_pool(mod_tsx_layer.endpt, pool); 
    10141018            return status; 
    10151019        } 
    1016     } 
    1017  
    1018     pj_grp_lock_add_ref(tsx->grp_lock); 
    1019     pj_grp_lock_add_handler(tsx->grp_lock, tsx->pool, tsx, &tsx_on_destroy); 
     1020         
     1021        pj_grp_lock_add_ref(tsx->grp_lock); 
     1022    } 
    10201023 
    10211024    status = pj_mutex_create_simple(pool, tsx->obj_name, &tsx->mutex_b); 
     
    13091312 
    13101313 
    1311     /* Lock transaction. */ 
    1312     pj_grp_lock_acquire(tsx->grp_lock); 
     1314    /* Lock transaction. 
     1315     * We don't need to lock the group lock if none was supplied, while the 
     1316     * newly created group lock has not been exposed. 
     1317     */ 
     1318    if (grp_lock) 
     1319        pj_grp_lock_acquire(tsx->grp_lock); 
    13131320 
    13141321    /* Role is UAC. */ 
     
    13761383    status = pjsip_get_request_dest(tdata, &dst_info); 
    13771384    if (status != PJ_SUCCESS) { 
    1378         pj_grp_lock_release(tsx->grp_lock); 
     1385        if (grp_lock) 
     1386            pj_grp_lock_release(tsx->grp_lock); 
    13791387        tsx_shutdown(tsx); 
    13801388        return status; 
     
    13881396        pj_assert(!"Bug in branch_param generator (i.e. not unique)"); 
    13891397        */ 
    1390         pj_grp_lock_release(tsx->grp_lock); 
     1398        if (grp_lock) 
     1399            pj_grp_lock_release(tsx->grp_lock); 
    13911400        tsx_shutdown(tsx); 
    13921401        return status; 
     
    13951404 
    13961405    /* Unlock transaction and return. */ 
    1397     pj_grp_lock_release(tsx->grp_lock); 
     1406    if (grp_lock) 
     1407        pj_grp_lock_release(tsx->grp_lock); 
    13981408 
    13991409    pj_log_push_indent(); 
Note: See TracChangeset for help on using the changeset viewer.