Skip to content
Snippets Groups Projects
Commit 933f70cf authored by Mark Spencer's avatar Mark Spencer
Browse files

Add crash option

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@1317 65c4cc65-6c06-0410-ace0-fbb531ad65f3
parent 67fb880d
No related branches found
No related tags found
No related merge requests found
...@@ -17,8 +17,10 @@ ...@@ -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 ...@@ -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 ...@@ -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;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment