Changeset 729 for pjproject/trunk/pjsip/src/pjsip/sip_ua_layer.c
- Timestamp:
- Sep 19, 2006 1:37:53 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/src/pjsip/sip_ua_layer.c
r673 r729 210 210 211 211 212 /**213 * Lock the dialog's hash table. This function is normally called by214 * dialog code only.215 *216 * @return PJ_SUCCESS on success or the appropriate error code.217 */218 PJ_DEF(pj_status_t) pjsip_ua_lock_dlg_table(void)219 {220 return pj_mutex_lock(mod_ua.mutex);221 }222 223 224 /**225 * Unlock the dialog's hash table. This function is normally called by226 * dialog code only.227 *228 * @return PJ_SUCCESS on success or the appropriate error code.229 */230 PJ_DEF(pj_status_t) pjsip_ua_unlock_dlg_table(void)231 {232 return pj_mutex_unlock(mod_ua.mutex);233 }234 235 236 212 /* 237 213 * Get the endpoint where this UA is currently registered. … … 500 476 pj_str_t *from_tag; 501 477 pjsip_dialog *dlg; 478 pj_status_t status; 502 479 503 480 /* Optimized path: bail out early if request is not CANCEL and it doesn't … … 509 486 return PJ_FALSE; 510 487 } 488 489 retry_on_deadlock: 511 490 512 491 /* Lock user agent before looking up the dialog hash table. */ … … 586 565 rdata->endpt_info.mod_data[mod_ua.mod.id] = dlg; 587 566 588 /* Lock the dialog */567 /* Try to lock the dialog */ 589 568 PJ_LOG(6,(dlg->obj_name, "UA layer acquiring dialog lock for request")); 590 pjsip_dlg_inc_lock(dlg); 569 status = pjsip_dlg_try_inc_lock(dlg); 570 if (status != PJ_SUCCESS) { 571 /* Failed to acquire dialog mutex immediately, this could be 572 * because of deadlock. Release UA mutex, yield, and retry 573 * the whole thing once again. 574 */ 575 pj_mutex_unlock(mod_ua.mutex); 576 pj_thread_sleep(0); 577 goto retry_on_deadlock; 578 } 579 580 /* Done with processing in UA layer, release lock */ 581 pj_mutex_unlock(mod_ua.mutex); 591 582 592 583 /* Pass to dialog. */ … … 596 587 pjsip_dlg_dec_lock(dlg); 597 588 598 /* Done processing in the UA */599 pj_mutex_unlock(mod_ua.mutex);600 601 589 /* Report as handled. */ 602 590 return PJ_TRUE; … … 610 598 pjsip_transaction *tsx; 611 599 struct dlg_set *dlg_set; 612 pjsip_dialog *dlg = NULL; 600 pjsip_dialog *dlg; 601 pj_status_t status; 613 602 614 603 /* … … 621 610 * the response is a forked response. 622 611 */ 612 613 retry_on_deadlock: 614 615 dlg = NULL; 623 616 624 617 /* Lock user agent dlg table before we're doing anything. */ … … 783 776 rdata->endpt_info.mod_data[mod_ua.mod.id] = dlg; 784 777 785 /* A cquire lock to the dialog. */778 /* Attempt to acquire lock to the dialog. */ 786 779 PJ_LOG(6,(dlg->obj_name, "UA layer acquiring dialog lock for response")); 787 pjsip_dlg_inc_lock(dlg); 780 status = pjsip_dlg_try_inc_lock(dlg); 781 if (status != PJ_SUCCESS) { 782 /* Failed to acquire dialog mutex. This could indicate a deadlock 783 * situation, and for safety, try to avoid deadlock by releasing 784 * UA mutex, yield, and retry the whole processing once again. 785 */ 786 pj_mutex_unlock(mod_ua.mutex); 787 pj_thread_sleep(0); 788 goto retry_on_deadlock; 789 } 790 791 /* We're done with processing in the UA layer, we can release the mutex */ 792 pj_mutex_unlock(mod_ua.mutex); 788 793 789 794 /* Pass the response to the dialog. */ … … 792 797 /* Unlock the dialog. This may destroy the dialog. */ 793 798 pjsip_dlg_dec_lock(dlg); 794 795 /* Unlock dialog hash table. */796 pj_mutex_unlock(mod_ua.mutex);797 799 798 800 /* Done. */
Note: See TracChangeset
for help on using the changeset viewer.