mirror of
				https://github.com/asterisk/asterisk.git
				synced 2025-10-29 15:36:13 +00:00 
			
		
		
		
	Add crash option
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@1317 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
		| @@ -17,8 +17,10 @@ | |||||||
| #include <pthread.h> | #include <pthread.h> | ||||||
|  |  | ||||||
| #ifdef DEBUG_THREADS | #ifdef DEBUG_THREADS | ||||||
|  | #ifdef THREAD_CRASH | ||||||
|  | #define DO_THREAD_CRASH do { *((int *)(0)) = 1; } while(0) | ||||||
|  | #endif | ||||||
|  |  | ||||||
| #define TRIES 50 |  | ||||||
|  |  | ||||||
| #include <errno.h> | #include <errno.h> | ||||||
| #include <string.h> | #include <string.h> | ||||||
| @@ -93,6 +95,9 @@ static inline int __ast_pthread_mutex_lock(char *filename, int lineno, char *fun | |||||||
| 	} else { | 	} else { | ||||||
| 		fprintf(stderr, "%s line %d (%s): Error obtaining mutex: %s\n", | 		fprintf(stderr, "%s line %d (%s): Error obtaining mutex: %s\n", | ||||||
| 			filename, lineno, func, strerror(errno)); | 			filename, lineno, func, strerror(errno)); | ||||||
|  | #ifdef THREAD_CRASH | ||||||
|  | 		DO_THREAD_CRASH; | ||||||
|  | #endif | ||||||
| 	} | 	} | ||||||
| 	return res; | 	return res; | ||||||
| } | } | ||||||
| @@ -121,9 +126,13 @@ static inline int __ast_pthread_mutex_unlock(char *filename, int lineno, char *f | |||||||
| 	t->func = NULL; | 	t->func = NULL; | ||||||
| 	t->thread = 0; | 	t->thread = 0; | ||||||
| 	res = pthread_mutex_unlock(&t->mutex); | 	res = pthread_mutex_unlock(&t->mutex); | ||||||
| 	if (res)  | 	if (res) { | ||||||
| 		fprintf(stderr, "%s line %d (%s): Error releasing mutex: %s\n",  | 		fprintf(stderr, "%s line %d (%s): Error releasing mutex: %s\n",  | ||||||
| 				filename, lineno, func, strerror(res)); | 				filename, lineno, func, strerror(res)); | ||||||
|  | #ifdef THREAD_CRASH | ||||||
|  | 		DO_THREAD_CRASH; | ||||||
|  | #endif | ||||||
|  | 	} | ||||||
| 	return res; | 	return res; | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user