diff options
author | Mark Spencer <markster@digium.com> | 2003-08-13 22:12:54 +0000 |
---|---|---|
committer | Mark Spencer <markster@digium.com> | 2003-08-13 22:12:54 +0000 |
commit | 933f70cf5d16cc3b6c4ea248ff5f91e03d66b418 (patch) | |
tree | dc6abb2c41c9909645275c3a48d4252c30544407 | |
parent | 67fb880dfb1464d6658dca0cf97ac62305842016 (diff) |
Add crash option
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@1317 65c4cc65-6c06-0410-ace0-fbb531ad65f3
-rwxr-xr-x | include/asterisk/lock.h | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/include/asterisk/lock.h b/include/asterisk/lock.h index 092672cae..9459042fc 100755 --- a/include/asterisk/lock.h +++ b/include/asterisk/lock.h @@ -17,8 +17,10 @@ #include <pthread.h> #ifdef DEBUG_THREADS +#ifdef THREAD_CRASH +#define DO_THREAD_CRASH do { *((int *)(0)) = 1; } while(0) +#endif -#define TRIES 50 #include <errno.h> #include <string.h> @@ -93,6 +95,9 @@ static inline int __ast_pthread_mutex_lock(char *filename, int lineno, char *fun } else { fprintf(stderr, "%s line %d (%s): Error obtaining mutex: %s\n", filename, lineno, func, strerror(errno)); +#ifdef THREAD_CRASH + DO_THREAD_CRASH; +#endif } return res; } @@ -121,9 +126,13 @@ static inline int __ast_pthread_mutex_unlock(char *filename, int lineno, char *f t->func = NULL; t->thread = 0; res = pthread_mutex_unlock(&t->mutex); - if (res) + if (res) { fprintf(stderr, "%s line %d (%s): Error releasing mutex: %s\n", filename, lineno, func, strerror(res)); +#ifdef THREAD_CRASH + DO_THREAD_CRASH; +#endif + } return res; } |