#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>
} 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;
}
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;
}