Changeset 11265 for trunk/psLib/src/sys/psError.c
- Timestamp:
- Jan 24, 2007, 12:14:48 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/sys/psError.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/sys/psError.c
r9730 r11265 11 11 * @author Eric Van Alst, MHPCC 12 12 * 13 * @version $Revision: 1.4 1$ $Name: not supported by cvs2svn $14 * @date $Date: 200 6-10-24 22:52:56$13 * @version $Revision: 1.42 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2007-01-24 22:14:48 $ 15 15 * 16 16 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii 17 17 */ 18 19 #ifdef HAVE_CONFIG_H 20 # include "config.h" 21 #endif 18 22 19 23 #include <stdarg.h> … … 55 59 if (psArrayLength(errorStack) < MAX_ERROR_STACK_SIZE) { 56 60 // make the psErr persistent 57 p _psMemSetPersistent(err, true);58 p _psMemSetPersistent(err->msg, true);59 p _psMemSetPersistent(err->name, true);61 psMemSetPersistent(err, true); 62 psMemSetPersistent(err->msg, true); 63 psMemSetPersistent(err->name, true); 60 64 61 65 psArrayAdd(errorStack, 0, err); … … 85 89 // allocate the error stack 86 90 errorStack = psArrayAllocEmpty(MAX_ERROR_STACK_SIZE); 87 p _psMemSetPersistent(errorStack, true);88 p _psMemSetPersistent(errorStack->data, true);91 psMemSetPersistent(errorStack, true); 92 psMemSetPersistent(errorStack->data, true); 89 93 // store this threads error stack 90 94 // note that pthread_setspecifc() does not take a pointer as the first … … 93 97 psAbort(__func__, "pthread_setspecific() failed"); 94 98 } 99 } 100 101 return errorStack; 102 } 103 104 // This function serves the same purpose of psErrorStackGet() accept it does 105 // not alloc the error stack if it DOES NOT already exist. Unlike 106 // psErrorStackGet(), this function is NOT guarenteed to return a valid pointer 107 // and it's return status must be checked. 108 static psArray *psErrorStackGetNoAlloc(void) 109 { 110 // check to see if the error stack key has been initialized 111 pthread_mutex_lock(&lockErrorStack); 112 if (errorStackKeyInitialized == false) { 113 return NULL; 114 } 115 pthread_mutex_unlock(&lockErrorStack); 116 117 // check to see if the error stack for this thread has been allocated 118 psArray *errorStack = NULL; 119 if ((errorStack = pthread_getspecific(errorStack_key)) == NULL) { 120 return NULL; 95 121 } 96 122 … … 237 263 psErr *err = errorStack->data[i]; 238 264 239 p _psMemSetPersistent(err, false);240 p _psMemSetPersistent(err->msg, false);241 p _psMemSetPersistent(err->name, false);265 psMemSetPersistent(err, false); 266 psMemSetPersistent(err->msg, false); 267 psMemSetPersistent(err->name, false); 242 268 } 243 269 … … 260 286 } 261 287 288 // This function does not allocate any memory so it is safe to call from inside 289 // of psMemory.c. Do not allocate memory in function (or call any functions 290 // that do) without first removing it's use from psMemory.c. 262 291 void psErrorStackPrintV(FILE *fd, const char *format, va_list va) 263 292 { 264 psArray *errorStack = psErrorStackGet(); 293 psArray *errorStack = psErrorStackGetNoAlloc(); 294 // do nothing if the error stack has not been allocated 295 if (!errorStack) { 296 return; 297 } 265 298 266 299 vfprintf(fd, format, va);
Note:
See TracChangeset
for help on using the changeset viewer.
