d8f6adcd23385fd99907a319f05449efca679c80 galt Wed Jul 6 10:17:01 2011 -0700 fix errAbortInProgress diff --git src/lib/errabort.c src/lib/errabort.c index 64ca2b3..d478576 100644 --- src/lib/errabort.c +++ src/lib/errabort.c @@ -25,31 +25,30 @@ #include "dystring.h" #include "errabort.h" static char const rcsid[] = "$Id: errabort.c,v 1.16 2010/01/12 18:16:27 markd Exp $"; #define maxWarnHandlers 20 #define maxAbortHandlers 12 struct perThreadAbortVars /* per thread variables for abort and warn */ { boolean debugPushPopErr; // generate stack dump on push/pop error boolean errAbortInProgress; /* Flag to indicate that an error abort is in progress. * Needed so that a warn handler can tell if it's really * being called because of a warning or an error. */ - // TODO probably have to create a global accessor function for setting errAbortInProgress. WarnHandler warnArray[maxWarnHandlers]; int warnIx; AbortHandler abortArray[maxAbortHandlers]; int abortIx; }; static struct perThreadAbortVars *getThreadVars(); // forward declaration static void defaultVaWarn(char *format, va_list args) /* Default error message handler. */ { if (format != NULL) { fflush(stdout); vfprintf(stderr, format, args); fprintf(stderr, "\n"); @@ -262,30 +261,40 @@ } void pushSilentWarnHandler() /* Set warning handler to be quiet. Do a popWarnHandler to restore. */ { pushWarnHandler(silentVaWarn); } void errAbortDebugnPushPopErr() /* generate stack dump if there is a error in the push/pop functions */ { struct perThreadAbortVars *ptav = getThreadVars(); ptav->debugPushPopErr = TRUE; } +boolean isErrAbortInProgress() +/* Flag to indicate that an error abort is in progress. + * Needed so that a warn handler can tell if it's really + * being called because of a warning or an error. */ +{ +struct perThreadAbortVars *ptav = getThreadVars(); +return ptav->errAbortInProgress; +} + + static struct perThreadAbortVars *getThreadVars() /* Return a pointer to the perThreadAbortVars for the current pthread. */ { static pthread_mutex_t ptavMutex = PTHREAD_MUTEX_INITIALIZER; pthread_mutex_lock( &ptavMutex ); static struct hash *perThreadVars = NULL; pthread_t pid = pthread_self(); // can be a pointer or a number // A true integer has function would be nicer, but this will do. // Don't safef, theoretically that could abort. char key[64]; snprintf(key, sizeof(key), "%lld", ptrToLL(pid)); key[ArraySize(key)-1] = '\0'; if (perThreadVars == NULL) perThreadVars = hashNew(0); struct hashEl *hel = hashLookup(perThreadVars, key);