Changeset 671 for pjproject/trunk/pjsip/src/pjsip/sip_dialog.c
- Timestamp:
- Aug 10, 2006 9:44:26 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/src/pjsip/sip_dialog.c
r635 r671 81 81 pj_list_init(&dlg->inv_hdr); 82 82 83 status = pj_mutex_create_recursive(pool, "dlg%p", &dlg->mutex );83 status = pj_mutex_create_recursive(pool, "dlg%p", &dlg->mutex_); 84 84 if (status != PJ_SUCCESS) 85 85 goto on_error; … … 90 90 91 91 on_error: 92 if (dlg->mutex )93 pj_mutex_destroy(dlg->mutex );92 if (dlg->mutex_) 93 pj_mutex_destroy(dlg->mutex_); 94 94 pjsip_endpt_release_pool(endpt, pool); 95 95 return status; … … 98 98 static void destroy_dialog( pjsip_dialog *dlg ) 99 99 { 100 if (dlg->mutex) 101 pj_mutex_destroy(dlg->mutex); 100 if (dlg->mutex_) { 101 pj_mutex_destroy(dlg->mutex_); 102 dlg->mutex_ = NULL; 103 } 102 104 pjsip_endpt_release_pool(dlg->endpt, dlg->pool); 103 105 } … … 607 609 608 610 /* Destroy this dialog. */ 609 pj_mutex_destroy(dlg->mutex); 610 pjsip_endpt_release_pool(dlg->endpt, dlg->pool); 611 destroy_dialog(dlg); 611 612 612 613 return PJ_SUCCESS; … … 639 640 PJ_ASSERT_RETURN(dlg, PJ_EINVAL); 640 641 641 pj _mutex_lock(dlg->mutex);642 pjsip_dlg_inc_lock(dlg); 642 643 643 644 /* Clear route set. */ … … 645 646 646 647 if (!route_set) { 647 pj _mutex_unlock(dlg->mutex);648 pjsip_dlg_dec_lock(dlg); 648 649 return PJ_SUCCESS; 649 650 } … … 659 660 } 660 661 661 pj_mutex_unlock(dlg->mutex); 662 662 pjsip_dlg_dec_lock(dlg); 663 663 return PJ_SUCCESS; 664 664 } … … 673 673 PJ_ASSERT_RETURN(dlg && mod, PJ_EINVAL); 674 674 675 pj _mutex_lock(dlg->mutex);675 pjsip_dlg_inc_lock(dlg); 676 676 ++dlg->sess_count; 677 pj _mutex_unlock(dlg->mutex);677 pjsip_dlg_dec_lock(dlg); 678 678 679 679 PJ_LOG(5,(dlg->obj_name, "Session count inc to %d by %.*s", … … 685 685 /* 686 686 * Lock dialog and increment session counter temporarily 687 * to prevent it from being deleted. 687 * to prevent it from being deleted. In addition, it must lock 688 * the user agent's dialog table first, to prevent deadlock. 688 689 */ 689 690 PJ_DEF(void) pjsip_dlg_inc_lock(pjsip_dialog *dlg) 690 691 { 691 pj_mutex_lock(dlg->mutex); 692 pjsip_ua_lock_dlg_table(); 693 694 pj_mutex_lock(dlg->mutex_); 692 695 dlg->sess_count++; 696 697 pjsip_ua_unlock_dlg_table(); 693 698 } 694 699 … … 700 705 PJ_DEF(void) pjsip_dlg_dec_lock(pjsip_dialog *dlg) 701 706 { 707 pjsip_ua_lock_dlg_table(); 708 702 709 pj_assert(dlg->sess_count > 0); 703 710 --dlg->sess_count; 704 711 705 712 if (dlg->sess_count==0 && dlg->tsx_count==0) { 706 pj_mutex_unlock(dlg->mutex );707 pj_mutex_lock(dlg->mutex );713 pj_mutex_unlock(dlg->mutex_); 714 pj_mutex_lock(dlg->mutex_); 708 715 unregister_and_destroy_dialog(dlg); 709 716 } else { 710 pj_mutex_unlock(dlg->mutex); 711 } 717 pj_mutex_unlock(dlg->mutex_); 718 } 719 720 pjsip_ua_unlock_dlg_table(); 712 721 } 713 722 … … 725 734 dlg->sess_count-1, (int)mod->name.slen, mod->name.ptr)); 726 735 727 pj_mutex_lock(dlg->mutex); 736 pjsip_dlg_inc_lock(dlg); 737 --dlg->sess_count; 728 738 pjsip_dlg_dec_lock(dlg); 729 739 … … 749 759 (int)mod->name.slen, mod->name.ptr, mod_data)); 750 760 751 pj _mutex_lock(dlg->mutex);761 pjsip_dlg_inc_lock(dlg); 752 762 753 763 /* Usages are sorted on priority, lowest number first. … … 758 768 if (dlg->usage[index] == mod) { 759 769 pj_assert(!"This module is already registered"); 760 pj _mutex_unlock(dlg->mutex);770 pjsip_dlg_dec_lock(dlg); 761 771 return PJSIP_ETYPEEXISTS; 762 772 } … … 778 788 ++dlg->usage_cnt; 779 789 780 pj _mutex_unlock(dlg->mutex);790 pjsip_dlg_dec_lock(dlg); 781 791 782 792 return PJ_SUCCESS; … … 897 907 898 908 /* Lock dialog. */ 899 pj _mutex_lock(dlg->mutex);909 pjsip_dlg_inc_lock(dlg); 900 910 901 911 /* Use outgoing CSeq and increment it by one. */ … … 922 932 923 933 /* Unlock dialog. */ 924 pj _mutex_unlock(dlg->mutex);934 pjsip_dlg_dec_lock(dlg); 925 935 926 936 *p_tdata = tdata; … … 1114 1124 1115 1125 /* Lock the dialog. */ 1116 pj _mutex_lock(dlg->mutex);1126 pjsip_dlg_inc_lock(dlg); 1117 1127 1118 1128 dlg_beautify_response(dlg, st_code, tdata); 1119 1129 1120 1130 /* Unlock the dialog. */ 1121 pj _mutex_unlock(dlg->mutex);1131 pjsip_dlg_dec_lock(dlg); 1122 1132 1123 1133 /* Done. */
Note: See TracChangeset
for help on using the changeset viewer.