e72cf0100e06d6fadb7282d4e7eb2c592f320951
galt
  Mon Jul 4 13:08:35 2011 -0700
Adding parallel-fetch loading of remote bigDataUrl tracks using pthreads
diff --git src/lib/errCatch.c src/lib/errCatch.c
index 0aea588..a5e0211 100644
--- src/lib/errCatch.c
+++ src/lib/errCatch.c
@@ -35,42 +35,45 @@
 
 void errCatchFree(struct errCatch **pErrCatch)
 /* Free up resources associated with errCatch */
 {
 struct errCatch *errCatch = *pErrCatch;
 if (errCatch != NULL)
     {
     dyStringFree(&errCatch->message);
     freez(pErrCatch);
     }
 }
 
 static struct errCatch **getStack()
 /* Return a pointer to the errCatch object stack for the current pthread. */
 {
+static pthread_mutex_t getStackMutex = PTHREAD_MUTEX_INITIALIZER;
+pthread_mutex_lock( &getStackMutex );
 static struct hash *perThreadStacks = 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 (perThreadStacks == NULL)
     perThreadStacks = hashNew(0);
 struct hashEl *hel = hashLookup(perThreadStacks, key);
 if (hel == NULL)
     hel = hashAdd(perThreadStacks, key, NULL);
+pthread_mutex_unlock( &getStackMutex );
 return (struct errCatch **)(&hel->val);
 }
 
 static void errCatchAbortHandler()
 /* semiAbort */
 {
 struct errCatch **pErrCatchStack = getStack(), *errCatchStack = *pErrCatchStack;
 errCatchStack->gotError = TRUE;
 longjmp(errCatchStack->jmpBuf, -1);
 }
 
 static void errCatchWarnHandler(char *format, va_list args)
 /* Write an error to top of errCatchStack. */
 {
 struct errCatch **pErrCatchStack = getStack(), *errCatchStack = *pErrCatchStack;
@@ -83,31 +86,31 @@
 {
 pushAbortHandler(errCatchAbortHandler);
 pushWarnHandler(errCatchWarnHandler);
 struct errCatch **pErrCatchStack = getStack();
 slAddHead(pErrCatchStack, errCatch);
 return TRUE;
 }
 
 void errCatchEnd(struct errCatch *errCatch)
 /* Restore error handlers and pop self off of catching stack. */
 {
 popWarnHandler();
 popAbortHandler();
 struct errCatch **pErrCatchStack = getStack(), *errCatchStack = *pErrCatchStack;
 if (errCatch != errCatchStack)
-   errAbort("Mismatch betweene errCatch and errCatchStack");
+   errAbort("Mismatch between errCatch and errCatchStack");
 *pErrCatchStack = errCatch->next;
 }
 
 boolean errCatchFinish(struct errCatch **pErrCatch)
 /* Finish up error catching.  Report error if there is a
  * problem and return FALSE.  If no problem return TRUE.
  * This handles errCatchEnd and errCatchFree. */
 {
 struct errCatch *errCatch = *pErrCatch;
 boolean ok = TRUE;
 if (errCatch != NULL)
     {
     errCatchEnd(errCatch);
     if (errCatch->gotError)
 	{