Changeset 5573
- Timestamp:
- Mar 29, 2017 2:40:48 AM (8 years ago)
- Location:
- pjproject/trunk/pjsip
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/include/pjsip/sip_transaction.h
r4420 r5573 180 180 * is created by calling #pjsip_tsx_create_key() from an incoming message. 181 181 * 182 * IMPORTANT: To prevent deadlock, application should use 183 * #pjsip_tsx_layer_find_tsx2() instead which only adds a reference to 184 * the transaction instead of locking it. 185 * 182 186 * @param key The key string to find the transaction. 183 187 * @param lock If non-zero, transaction will be locked before the … … 190 194 PJ_DECL(pjsip_transaction*) pjsip_tsx_layer_find_tsx( const pj_str_t *key, 191 195 pj_bool_t lock ); 196 197 /** 198 * Find a transaction with the specified key. The transaction key normally 199 * is created by calling #pjsip_tsx_create_key() from an incoming message. 200 * 201 * @param key The key string to find the transaction. 202 * @param add_ref If non-zero, transaction's reference will be added 203 * by one before the function returns, to make sure that 204 * it's not deleted by other threads. 205 * 206 * @return The matching transaction instance, or NULL if transaction 207 * can not be found. 208 */ 209 PJ_DECL(pjsip_transaction*) pjsip_tsx_layer_find_tsx2( const pj_str_t *key, 210 pj_bool_t add_ref ); 192 211 193 212 /** -
pjproject/trunk/pjsip/src/pjsip-ua/sip_inv.c
r5435 r5573 3276 3276 pjsip_tsx_create_key(rdata->tp_info.pool, &key, PJSIP_ROLE_UAS, 3277 3277 pjsip_get_invite_method(), rdata); 3278 invite_tsx = pjsip_tsx_layer_find_tsx (&key, PJ_TRUE);3278 invite_tsx = pjsip_tsx_layer_find_tsx2(&key, PJ_TRUE); 3279 3279 3280 3280 if (invite_tsx == NULL) { … … 3325 3325 3326 3326 if (invite_tsx) 3327 pj_grp_lock_ release(invite_tsx->grp_lock);3327 pj_grp_lock_dec_ref(invite_tsx->grp_lock); 3328 3328 } 3329 3329 -
pjproject/trunk/pjsip/src/pjsip/sip_transaction.c
r5572 r5573 642 642 * Find a transaction. 643 643 */ 644 PJ_DEF(pjsip_transaction*) pjsip_tsx_layer_find_tsx( const pj_str_t *key,645 pj_bool_t lock)644 static pjsip_transaction* find_tsx( const pj_str_t *key, pj_bool_t lock, 645 pj_bool_t add_ref ) 646 646 { 647 647 pjsip_transaction *tsx; … … 655 655 /* Prevent the transaction to get deleted before we have chance to lock it. 656 656 */ 657 if (tsx && lock)657 if (tsx) 658 658 pj_grp_lock_add_ref(tsx->grp_lock); 659 659 … … 667 667 PJ_RACE_ME(5); 668 668 669 if (tsx && lock) { 670 pj_grp_lock_acquire(tsx->grp_lock); 671 pj_grp_lock_dec_ref(tsx->grp_lock); 669 if (tsx) { 670 if (lock) 671 pj_grp_lock_acquire(tsx->grp_lock); 672 673 if (!add_ref) 674 pj_grp_lock_dec_ref(tsx->grp_lock); 672 675 } 673 676 674 677 return tsx; 678 } 679 680 681 PJ_DEF(pjsip_transaction*) pjsip_tsx_layer_find_tsx( const pj_str_t *key, 682 pj_bool_t lock ) 683 { 684 return find_tsx(key, lock, PJ_FALSE); 685 } 686 687 688 PJ_DEF(pjsip_transaction*) pjsip_tsx_layer_find_tsx2( const pj_str_t *key, 689 pj_bool_t add_ref ) 690 { 691 return find_tsx(key, PJ_FALSE, add_ref); 675 692 } 676 693 -
pjproject/trunk/pjsip/src/pjsip/sip_ua_layer.c
r5456 r5573 552 552 553 553 /* Lookup the INVITE transaction */ 554 tsx = pjsip_tsx_layer_find_tsx (&key, PJ_TRUE);554 tsx = pjsip_tsx_layer_find_tsx2(&key, PJ_TRUE); 555 555 556 556 /* We should find the dialog attached to the INVITE transaction */ 557 557 if (tsx) { 558 558 dlg = (pjsip_dialog*) tsx->mod_data[mod_ua.mod.id]; 559 pj_grp_lock_ release(tsx->grp_lock);559 pj_grp_lock_dec_ref(tsx->grp_lock); 560 560 561 561 /* Dlg may be NULL on some extreme condition
Note: See TracChangeset
for help on using the changeset viewer.