use threadOnce
This commit is contained in:
+18
-9
@@ -111,26 +111,35 @@ static void asSpcAsCallback(struct dbCommon *precord)
|
||||
{
|
||||
asChangeGroup((ASMEMBERPVT *)&precord->asp,precord->asg);
|
||||
}
|
||||
|
||||
static void asInitCommonOnce(void *arg)
|
||||
{
|
||||
int *firstTime = (int *)arg;
|
||||
*firstTime = FALSE;
|
||||
}
|
||||
|
||||
static long asInitCommon(void)
|
||||
{
|
||||
long status;
|
||||
int asWasActive = asActive;
|
||||
int wasFirstTime = firstTime;
|
||||
static threadOnceId asInitCommonOnceFlag = OSITHREAD_ONCE_INIT;
|
||||
|
||||
if(firstTime) {
|
||||
firstTime = FALSE;
|
||||
if(!pacf) return(0); /*access security will NEVER be turned on*/
|
||||
|
||||
threadOnce(&asInitCommonOnceFlag,asInitCommonOnce,(void *)&firstTime);
|
||||
if(wasFirstTime) {
|
||||
if(!pacf) return(0); /*access security will NEVER be turned on*/
|
||||
} else {
|
||||
if(!asActive) {
|
||||
if(!asActive) {
|
||||
printf("Access security is NOT enabled."
|
||||
" Was asSetFilename specified before iocInit?\n");
|
||||
return(S_asLib_asNotActive);
|
||||
}
|
||||
if(pacf) {
|
||||
asCaStop();
|
||||
} else { /*Just leave everything as is */
|
||||
return(S_asLib_badConfig);
|
||||
}
|
||||
if(pacf) {
|
||||
asCaStop();
|
||||
} else { /*Just leave everything as is */
|
||||
return(S_asLib_badConfig);
|
||||
}
|
||||
}
|
||||
status = asInitFile(pacf,psubstitutions);
|
||||
if(asActive) {
|
||||
|
||||
@@ -25,6 +25,7 @@ of this distribution.
|
||||
#include <string.h>
|
||||
|
||||
#include "dbDefs.h"
|
||||
#include "osiThread.h"
|
||||
#include "ellLib.h"
|
||||
#include "cantProceed.h"
|
||||
#include "osiSem.h"
|
||||
@@ -48,7 +49,6 @@ epicsShareDef ASBASE volatile *pasbase=NULL;
|
||||
static ASBASE *pasbasenew=NULL;
|
||||
epicsShareDef int asActive = FALSE;
|
||||
|
||||
static int asLockInit=TRUE;
|
||||
static void *freeListPvt = NULL;
|
||||
|
||||
|
||||
@@ -85,6 +85,10 @@ static long asAsgRuleCalc(ASGRULE *pasgrule,char *calc);
|
||||
the old memberList is moved from old to new.
|
||||
the old structures are freed.
|
||||
*/
|
||||
static void asInitializeOnce(void *arg)
|
||||
{
|
||||
asLock = semMutexMustCreate();
|
||||
}
|
||||
long epicsShareAPI asInitialize(ASINPUTFUNCPTR inputfunction)
|
||||
{
|
||||
ASG *pasg;
|
||||
@@ -95,11 +99,9 @@ long epicsShareAPI asInitialize(ASINPUTFUNCPTR inputfunction)
|
||||
UAGNAME *puagname;
|
||||
HAG *phag;
|
||||
HAGNAME *phagname;
|
||||
static threadOnceId asInitializeOnceFlag = OSITHREAD_ONCE_INIT;
|
||||
|
||||
if(asLockInit) {
|
||||
asLock = semMutexMustCreate();
|
||||
asLockInit = FALSE;
|
||||
}
|
||||
threadOnce(&asInitializeOnceFlag,asInitializeOnce,(void *)0);
|
||||
LOCK;
|
||||
pasbasenew = asCalloc(1,sizeof(ASBASE));
|
||||
if(!freeListPvt) freeListInitPvt(&freeListPvt,sizeof(ASGCLIENT),20);
|
||||
|
||||
Reference in New Issue
Block a user