Don't call errlogPrintf() in epicsThreadGetOsiPriorityValue()
This is a partial fix of a WIN32-only problem Mark Rivers reported. A WIN32 thread created by a manufacturer's library is used to call one of his callback routines, which tries to use an epics facility that has an epicsThreadOnce(). The new version of epicsThreadOnce() uses epicsThreadGetIdSelf() to detect recursive initialization; the thread doesn't have an epicsThreadId yet, so epicsThreadImplicitCreate() is asked to make one. It calls epicsThreadGetOsiPriorityValue(), but osdPriority is 15 which is not known by that code, so it reports an error by calling errlogPrintf(). That checks epicsThreadIsOkToBlock() which calls epicsThreadOnce() but that needs our epicsThreadId... This doesn't solve the issue of the unknown osdPriority value 15 (priorityClass = 32), but it allows the IOC to continue working with just a warning message at init time. It also points out that calling epicsThreadGetIdSelf() every time we check an epicsThreadOnce() is probably not good for performance.
This commit is contained in:
@@ -34,7 +34,6 @@
|
||||
#include "shareLib.h"
|
||||
#include "epicsThread.h"
|
||||
#include "cantProceed.h"
|
||||
#include "errlog.h"
|
||||
#include "epicsAssert.h"
|
||||
#include "ellLib.h"
|
||||
#include "epicsExit.h"
|
||||
@@ -373,10 +372,10 @@ static unsigned epicsThreadGetOsiPriorityValue ( int osdPriority )
|
||||
}
|
||||
|
||||
if ( magnitude >= stateCount ) {
|
||||
errlogPrintf (
|
||||
fprintf ( stderr,
|
||||
"Unrecognized WIN32 thread priority level %d.\n",
|
||||
osdPriority );
|
||||
errlogPrintf (
|
||||
fprintf ( stderr,
|
||||
"Mapping to EPICS thread priority level epicsThreadPriorityMin.\n" );
|
||||
return epicsThreadPriorityMin;
|
||||
}
|
||||
@@ -452,12 +451,14 @@ epicsShareFunc unsigned int epicsShareAPI epicsThreadGetStackSize ( epicsThreadS
|
||||
static const unsigned stackSizeTable[epicsThreadStackBig+1] = {4000, 6000, 11000};
|
||||
|
||||
if (stackSizeClass<epicsThreadStackSmall) {
|
||||
errlogPrintf("epicsThreadGetStackSize illegal argument (too small)");
|
||||
fprintf ( stderr,
|
||||
"epicsThreadGetStackSize illegal argument (too small)");
|
||||
return stackSizeTable[epicsThreadStackBig];
|
||||
}
|
||||
|
||||
if (stackSizeClass>epicsThreadStackBig) {
|
||||
errlogPrintf("epicsThreadGetStackSize illegal argument (too large)");
|
||||
fprintf ( stderr,
|
||||
"epicsThreadGetStackSize illegal argument (too large)");
|
||||
return stackSizeTable[epicsThreadStackBig];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user