epicsThreadOnceOsd() must unlock mutex before calling func().
Required so callbackInit() can wait for its threads to start.
This commit is contained in:
@@ -478,9 +478,11 @@ void epicsThreadOnceOsd(epicsThreadOnceId *id, void(*func)(void *), void *arg)
|
||||
if (!initialized) epicsThreadInit();
|
||||
epicsMutexMustLock(onceMutex);
|
||||
if (*id == 0) {
|
||||
*id = -1;
|
||||
func(arg);
|
||||
*id = 1;
|
||||
*id = -1;
|
||||
epicsMutexUnlock(onceMutex);
|
||||
func(arg);
|
||||
epicsMutexMustLock(onceMutex);
|
||||
*id = 1;
|
||||
} else
|
||||
assert(*id > 0 /* func() called epicsThreadOnce() with same id */);
|
||||
epicsMutexUnlock(onceMutex);
|
||||
|
||||
@@ -1004,7 +1004,9 @@ epicsShareFunc void epicsShareAPI epicsThreadOnceOsd (
|
||||
|
||||
if ( *id == 0 ) {
|
||||
*id = -1;
|
||||
LeaveCriticalSection ( & pGbl->mutex );
|
||||
( *func ) ( arg );
|
||||
EnterCriticalSection ( & pGbl->mutex );
|
||||
*id = 1;
|
||||
} else
|
||||
assert(*id > 0 /* func() called epicsThreadOnce() with same id */);
|
||||
|
||||
@@ -116,7 +116,9 @@ void epicsThreadOnceOsd(epicsThreadOnceId *id, void (*func)(void *), void *arg)
|
||||
assert(semTake(epicsThreadOnceMutex,WAIT_FOREVER)==OK);
|
||||
if (*id == 0) { /* 0 => first call */
|
||||
*id = -1; /* -1 => func() active */
|
||||
semGive(epicsThreadOnceMutex);
|
||||
func(arg);
|
||||
assert(semTake(epicsThreadOnceMutex,WAIT_FOREVER)==OK);
|
||||
*id = +1; /* +1 => func() done */
|
||||
} else
|
||||
assert(*id > 0 /* func() called epicsThreadOnce() with same id */);
|
||||
|
||||
Reference in New Issue
Block a user