Changeset 2843 for pjproject/trunk
- Timestamp:
- Jul 22, 2009 11:12:35 AM (15 years ago)
- Location:
- pjproject/trunk/pjlib
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjlib/include/pj/config.h
r2427 r2843 327 327 # define PJ_DEBUG 0 328 328 # endif 329 #endif 330 331 /** 332 * Enable this macro to activate logging to mutex/semaphore related events. 333 * This is useful to troubleshoot concurrency problems such as deadlocks. 334 * In addition, you should also add PJ_LOG_HAS_THREAD_ID flag to the 335 * log decoration to assist the troubleshooting. 336 * 337 * Default: 0 338 */ 339 #ifndef PJ_DEBUG_MUTEX 340 # define PJ_DEBUG_MUTEX 0 329 341 #endif 330 342 -
pjproject/trunk/pjlib/include/pj/os.h
r2560 r2843 676 676 * @return Non-zero if yes. 677 677 */ 678 #if defined(PJ_DEBUG) && PJ_DEBUG != 0 679 PJ_DECL(pj_bool_t) pj_mutex_is_locked(pj_mutex_t *mutex); 680 #else 681 # define pj_mutex_is_locked(mutex) 1 682 #endif 678 PJ_DECL(pj_bool_t) pj_mutex_is_locked(pj_mutex_t *mutex); 683 679 684 680 /** -
pjproject/trunk/pjlib/src/pj/os_core_win32.c
r2394 r2843 39 39 #endif 40 40 41 /* Activate mutex related logging if PJ_DEBUG_MUTEX is set, otherwise 42 * use default level 6 logging. 43 */ 44 #if defined(PJ_DEBUG_MUTEX) && PJ_DEBUG_MUTEX 45 # undef PJ_DEBUG 46 # define PJ_DEBUG 1 47 # define LOG_MUTEX(expr) PJ_LOG(5,expr) 48 #else 49 # define LOG_MUTEX(expr) PJ_LOG(6,expr) 50 #endif 51 41 52 #define THIS_FILE "os_core_win32.c" 42 53 … … 905 916 PJ_ASSERT_RETURN(mutex, PJ_EINVAL); 906 917 907 PJ_LOG(6,(mutex->obj_name, "Mutex: thread %s is waiting",918 LOG_MUTEX((mutex->obj_name, "Mutex: thread %s is waiting", 908 919 pj_thread_this()->obj_name)); 909 920 … … 918 929 919 930 #endif 920 PJ_LOG(6,(mutex->obj_name,931 LOG_MUTEX((mutex->obj_name, 921 932 (status==PJ_SUCCESS ? "Mutex acquired by thread %s" : "FAILED by %s"), 922 933 pj_thread_this()->obj_name)); … … 949 960 #endif 950 961 951 PJ_LOG(6,(mutex->obj_name, "Mutex released by thread %s",962 LOG_MUTEX((mutex->obj_name, "Mutex released by thread %s", 952 963 pj_thread_this()->obj_name)); 953 964 … … 972 983 PJ_ASSERT_RETURN(mutex, PJ_EINVAL); 973 984 974 PJ_LOG(6,(mutex->obj_name, "Mutex: thread %s is trying",985 LOG_MUTEX((mutex->obj_name, "Mutex: thread %s is trying", 975 986 pj_thread_this()->obj_name)); 976 987 … … 982 993 #endif 983 994 if (status==PJ_SUCCESS) { 984 PJ_LOG(6,(mutex->obj_name, "Mutex acquired by thread %s",995 LOG_MUTEX((mutex->obj_name, "Mutex acquired by thread %s", 985 996 pj_thread_this()->obj_name)); 986 997 … … 990 1001 #endif 991 1002 } else { 992 PJ_LOG(6,(mutex->obj_name, "Mutex: thread %s's trylock() failed",1003 LOG_MUTEX((mutex->obj_name, "Mutex: thread %s's trylock() failed", 993 1004 pj_thread_this()->obj_name)); 994 1005 } … … 1005 1016 PJ_ASSERT_RETURN(mutex, PJ_EINVAL); 1006 1017 1007 PJ_LOG(6,(mutex->obj_name, "Mutex destroyed"));1018 LOG_MUTEX((mutex->obj_name, "Mutex destroyed")); 1008 1019 1009 1020 #if PJ_WIN32_WINNT >= 0x0400 … … 1016 1027 } 1017 1028 1029 /* 1030 * pj_mutex_is_locked() 1031 */ 1032 PJ_DEF(pj_bool_t) pj_mutex_is_locked(pj_mutex_t *mutex) 1033 { 1018 1034 #if PJ_DEBUG 1019 /*1020 * pj_mutex_is_locked()1021 */1022 PJ_DEF(pj_bool_t) pj_mutex_is_locked(pj_mutex_t *mutex)1023 {1024 1035 return mutex->owner == pj_thread_this(); 1025 } 1026 #endif 1036 #else 1037 pj_assert(!"PJ_DEBUG is not set!"); 1038 return 1; 1039 #endif 1040 } 1027 1041 1028 1042 /////////////////////////////////////////////////////////////////////////////// … … 1083 1097 } 1084 1098 1085 PJ_LOG(6,(sem->obj_name, "Semaphore created"));1099 LOG_MUTEX((sem->obj_name, "Semaphore created")); 1086 1100 1087 1101 *sem_ptr = sem; … … 1096 1110 PJ_ASSERT_RETURN(sem, PJ_EINVAL); 1097 1111 1098 PJ_LOG(6,(sem->obj_name, "Semaphore: thread %s is waiting",1112 LOG_MUTEX((sem->obj_name, "Semaphore: thread %s is waiting", 1099 1113 pj_thread_this()->obj_name)); 1100 1114 1101 1115 result = WaitForSingleObject(sem->hSemaphore, timeout); 1102 1116 if (result == WAIT_OBJECT_0) { 1103 PJ_LOG(6,(sem->obj_name, "Semaphore acquired by thread %s",1117 LOG_MUTEX((sem->obj_name, "Semaphore acquired by thread %s", 1104 1118 pj_thread_this()->obj_name)); 1105 1119 } else { 1106 PJ_LOG(6,(sem->obj_name, "Semaphore: thread %s FAILED to acquire",1120 LOG_MUTEX((sem->obj_name, "Semaphore: thread %s FAILED to acquire", 1107 1121 pj_thread_this()->obj_name)); 1108 1122 } … … 1146 1160 PJ_ASSERT_RETURN(sem, PJ_EINVAL); 1147 1161 1148 PJ_LOG(6,(sem->obj_name, "Semaphore released by thread %s",1162 LOG_MUTEX((sem->obj_name, "Semaphore released by thread %s", 1149 1163 pj_thread_this()->obj_name)); 1150 1164 … … 1163 1177 PJ_ASSERT_RETURN(sem, PJ_EINVAL); 1164 1178 1165 PJ_LOG(6,(sem->obj_name, "Semaphore destroyed by thread %s",1179 LOG_MUTEX((sem->obj_name, "Semaphore destroyed by thread %s", 1166 1180 pj_thread_this()->obj_name)); 1167 1181
Note: See TracChangeset
for help on using the changeset viewer.