From 6cd22d4efe6d45c907ec3a7707f64851f838f1f3 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Fri, 14 May 2010 16:49:32 -0500 Subject: [PATCH] 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. --- src/libCom/osi/os/WIN32/osdThread.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/libCom/osi/os/WIN32/osdThread.c b/src/libCom/osi/os/WIN32/osdThread.c index 50002b4e9..887a31170 100644 --- a/src/libCom/osi/os/WIN32/osdThread.c +++ b/src/libCom/osi/os/WIN32/osdThread.c @@ -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 (stackSizeClassepicsThreadStackBig) { - errlogPrintf("epicsThreadGetStackSize illegal argument (too large)"); + fprintf ( stderr, + "epicsThreadGetStackSize illegal argument (too large)"); return stackSizeTable[epicsThreadStackBig]; }