avoid recursive locking in once only function

This commit is contained in:
Jeff Hill
2002-12-12 20:52:56 +00:00
parent 3e1af8ce08
commit 06aa996962
+6 -1
View File
@@ -328,7 +328,12 @@ void epicsThreadOnceOsd(epicsThreadOnceId *id, void (*func)(void *), void *arg)
}
if (*id == 0) { /* 0 => first call */
*id = -1; /* -1 => func() active */
func(arg);
/* avoid recursive locking */
status = pthread_mutex_unlock(&onceLock);
checkStatusQuit(status,"pthread_mutex_unlock","epicsThreadOnceOsd");
func(arg);
status = pthread_mutex_lock(&onceLock);
checkStatusQuit(status,"pthread_mutex_lock","epicsThreadOnceOsd");
*id = +1; /* +1 => func() done (see epicsThreadOnce() macro defn) */
}
status = pthread_mutex_unlock(&onceLock);