ClRcT clJobQueueInit(ClJobQueueT* hdl, ClUint32T maxJobs, ClUint32T maxTasks) { ClRcT rc; hdl->flags = 0; hdl->queue = 0; hdl->pool = 0; rc = clOsalMutexInit(&hdl->mutex); if (rc != CL_OK) goto error; rc = clQueueCreate(maxJobs, deleteCallback, deleteCallback, &hdl->queue); if (rc != CL_OK) goto error; rc = clTaskPoolCreate(&hdl->pool, maxTasks, clJobQueuePreIdle, hdl); if (rc != CL_OK) goto error; hdl->flags |= CreatedQueue | CreatedPool | Running; return CL_OK; error: clOsalMutexDestroy(&hdl->mutex); if (hdl->pool) clTaskPoolDelete(hdl->pool); if (hdl->queue) clQueueDelete(&hdl->queue); hdl->queue = 0; hdl->pool = 0; return rc; }
ClRcT clMsgQueueInitialize(void) { ClRcT rc, retCode; rc = clHandleDatabaseCreate(NULL, &gClMsgQDatabase); if(rc != CL_OK) { clLogError("QUE", "INI", "Failed to create a Queue Handle database. error code [0x%x].", rc); goto error_out; } rc = clOsalMutexInit(&gClLocalQsLock); if(rc != CL_OK) { clLogError("QUE", "INI", "Failed to initialize the \"all local queues' lock\". error code [0x%x].", rc); goto error_out_1; } rc = clOsalMutexInit(&gClQueueDbLock); if(rc != CL_OK) { clLogError("QUE", "INI", "Failed to initialize queue db mutex. error code [0x%x].", rc); goto error_out_2; } goto out; error_out_2: retCode = clOsalMutexDestroy(&gClLocalQsLock); if(retCode != CL_OK) clLogError("QUE", "INI", "Failed to destroy the local queues' mutex. error code [0x%x].", retCode); error_out_1: retCode = clHandleDatabaseDestroy(gClMsgQDatabase); if(retCode != CL_OK) clLogError("QUE", "INI", "Failed to delete the Queue Handle database. error code [0x%x].", retCode); error_out: out: return rc; }
static ClRcT clAmsListHeadInit(ClAmsListHeadT *pList) { ClRcT rc; clOsalMutexInit(&pList->mutex); rc = clOsalCondInit(&pList->cond); if(rc != CL_OK) { clLogError("AMS", "INIT", "Failed to create a condtional variable. error code [0x%x].", rc); clOsalMutexDestroy(&pList->mutex); return rc; } pList->numElements = 0; CL_LIST_HEAD_INIT(&pList->list); return CL_OK; }
void clPyGlueInit(char* appModule,void (*init_extensions[])(void),int argc, char**argv) { char buf[1024]; ClRcT rc; Py_Initialize(); PySys_SetArgv(argc, argv); PyEval_InitThreads(); if (init_extensions) { int i = 0; for(i=0; init_extensions[i]!=NULL; i++) (*init_extensions[i])(); } thrdState = PyThreadState_Get(); rc = clOsalMutexInit(&pyMutex); CL_ASSERT(rc==CL_OK); rc = clOsalCondInit(&event); CL_ASSERT(rc==CL_OK); rc = clOsalMutexLock(&pyMutex); CL_ASSERT(rc==CL_OK); PyThreadState_Swap(thrdState); PyRun_SimpleString("import os, os.path, sys\n"); snprintf(buf,1024,"sys.path.append(os.path.realpath('%s'))\n",CL_APP_BINDIR); clprintf(CL_LOG_SEV_INFO, buf); PyRun_SimpleString(buf); //PyRun_SimpleString("sys.path.append(os.path.realpath('../../bin'))\n"); snprintf(buf,1024,"from %s import *\n",appModule); clprintf(CL_LOG_SEV_INFO, buf); PyRun_SimpleString(buf); PyThreadState_Swap(NULL); PyEval_ReleaseLock(); rc=clOsalMutexUnlock(&pyMutex); CL_ASSERT(rc==CL_OK); }
ClRcT clEoClientCallbackDbInitialize(void) { ClRcT rc; gpCallbackDb.pDb = (ClEoCallbackRecT **)clHeapAllocate(sizeof(ClEoCallbackRecT*) * CL_EO_COMPONENTS); if(gpCallbackDb.pDb == NULL) { /* Print Error here */ return CL_EO_RC( CL_ERR_NO_MEMORY); } memset(gpCallbackDb.pDb, 0, sizeof(ClEoCallbackRecT *) * CL_EO_COMPONENTS); gpCallbackDb.numRecs = CL_EO_COMPONENTS; rc = clOsalMutexInit(&gpCallbackDb.lock); CL_ASSERT(rc == CL_OK); return CL_OK; }
static void clEoQueueStatsUpdate(ClEoQueueStatsT *pStats) { ClUint8T proto = pStats->proto; ClUint8T priority = pStats->priority; ClEoQueueStatsT *pStatsGlobal = NULL; /* * Cant do this in eoProtoInit as its invoked * before osal init. */ if( gClEoQueueStatsMutexInitialized == CL_FALSE ) { ClRcT rc = CL_OK; gClEoQueueStatsMutexInitialized = CL_TRUE; rc = clOsalMutexInit(&gClEoQueueStatsMutex); CL_ASSERT(rc == CL_OK); } CL_EO_QUEUE_LOCK(&gClEoQueueStatsMutex); pStatsGlobal = &gClEoQueueStats[priority][proto]; pStatsGlobal->used = CL_TRUE; pStatsGlobal->totalQueueSize += pStats->totalQueueSize; ++pStatsGlobal->count; if(!pStatsGlobal->minQueueSize) pStatsGlobal->minQueueSize = pStats->totalQueueSize; else if(pStats->totalQueueSize < pStatsGlobal->minQueueSize) pStatsGlobal->minQueueSize = pStats->totalQueueSize; if(!pStatsGlobal->maxQueueSize) pStatsGlobal->maxQueueSize = pStats->totalQueueSize; else if(pStats->totalQueueSize > pStatsGlobal->maxQueueSize) pStatsGlobal->maxQueueSize = pStats->totalQueueSize; pStatsGlobal->totalTime += pStats->totalTime; if(!pStatsGlobal->minTime) pStatsGlobal->minTime = pStats->totalTime; else if(pStats->totalTime < pStatsGlobal->minTime) pStatsGlobal->minTime = pStats->totalTime; if(!pStatsGlobal->maxTime) pStatsGlobal->maxTime = pStats->totalTime; else if(pStats->totalTime > pStatsGlobal->maxTime) pStatsGlobal->maxTime = pStats->totalTime; CL_EO_QUEUE_UNLOCK(&gClEoQueueStatsMutex); memset(pStats, 0, sizeof(*pStats)); }
/* * Setup the priority map */ ClRcT clEoQueueInitialize(void) { ClInt32T minPriority = sched_get_priority_min(CL_EO_SCHED_POLICY); ClInt32T maxPriority = sched_get_priority_max(CL_EO_SCHED_POLICY); ClInt32T priority=maxPriority; ClInt32T decr = 10; ClRcT rc = CL_OK; register ClInt32T i; if(minPriority < 0 ) { CL_DEBUG_PRINT(CL_DEBUG_ERROR,("Error getting minPriority\n")); minPriority = 0; } if(maxPriority < 0 ) { CL_DEBUG_PRINT(CL_DEBUG_ERROR,("Error getting maxPriority\n")); maxPriority = 0; } if(!priority) decr = 0; for(i = CL_IOC_HIGH_PRIORITY; i <= CL_IOC_LOW_PRIORITY; ++i) { gClEoThreadPriorityMap[i] = CL_MAX(priority, 0); priority -= decr; } gClEoThreadPriorityMap[CL_IOC_DEFAULT_PRIORITY] = CL_MAX(priority, 0); for(i = CL_IOC_RESERVED_PRIORITY ; i < CL_IOC_MAX_PRIORITIES ; ++i) gClEoThreadPriorityMap[i] = CL_MAX(priority, 0); rc = clOsalMutexInit(&gClEoQueueMutex); CL_ASSERT(rc == CL_OK); #if defined (EO_QUEUE_STATS) signal(SIGUSR2, sigusr2_handler); #endif return rc; }
ClRcT clMemPartInitialize(ClMemPartHandleT *pMemPartHandle, ClUint32T memPartSize) { ClCharT *pool = NULL; ClInt32T i; ClRcT rc = CL_OK; ClMemPartT *pMemPart = NULL; if(!pMemPartHandle) return CL_ERR_INVALID_PARAMETER; if(!memPartSize) memPartSize = CL_MEM_PART_SIZE; pMemPart = calloc(1, sizeof(*pMemPart)); CL_ASSERT(pMemPart != NULL); rc= clOsalMutexInit(&pMemPart->mutex); CL_ASSERT(rc == CL_OK); for(i = 0; i < CL_MEM_PART_EXPANSION_SLOTS; ++i) pMemPart->partitions[i] = NULL; pMemPart->index = 0; pool = malloc(memPartSize); if(!pool) { CL_DEBUG_PRINT(CL_DEBUG_ERROR, ("CALLOC failed for size [%d] while trying to create MEM partition\n", memPartSize)); return CL_ERR_NO_MEMORY; } pMemPart->partId = memPartCreate(pool, memPartSize); if(!pMemPart->partId) { free(pool); CL_DEBUG_PRINT(CL_DEBUG_ERROR, ("memPartCreate for size [%d] failed\n", memPartSize)); return CL_ERR_NO_MEMORY; } pMemPart->partitions[pMemPart->index++] = pool; *pMemPartHandle = (ClMemPartHandleT)pMemPart; return CL_OK; }
ClRcT clMsgFinalizeBlockInit(void) { ClRcT rc; ClRcT retCode; rc = clOsalCondCreate(&gFinBlockCond); if(rc != CL_OK) { clLogError("FIN", "BLOCK", "Failed to create a condtional variable. error code [0x%x].", rc); goto error_out; } rc = clOsalMutexInit(&gFinBlockMutex); if(rc != CL_OK) { clLogError("FIN", "BLOCK", "Failed to create a mutex. error code [0x%x].", rc); goto error_out_1; } rc = clMsgEventInitTimerStart(); if(rc != CL_OK) { clLogError("FIN", "BLOCK", "Failed to start event initialize timer. error code [0x%x].", rc); goto error_out_2; } goto out; error_out_2: retCode = clOsalMutexDestroy(&gFinBlockMutex); if(retCode != CL_OK) clLogError("MSG", "BLOCK", "Failed to destroy mutex. error code [0x%x].", retCode); error_out_1: retCode = clOsalCondDelete(gFinBlockCond); if(retCode != CL_OK) clLogError("MSG", "BLOCK", "Failed to delete a conditional variable. error code [0x%x].", retCode); error_out: out: return rc; }
/******************************************************************************* Feature API: alarmClockCkptInitialize *******************************************************************************/ SaAisErrorT alarmClockCkptInitialize (void) { SaAisErrorT ret_code = SA_AIS_OK; if (ckpt_svc_hdl == 0) { ret_code = saCkptInitialize(&ckpt_svc_hdl, NULL, &ckpt_version); if (ret_code != SA_AIS_OK) { alarmClockLogWrite(CL_LOG_SEV_ERROR, "alarmClockCkptInitialize(pid=%d): Failed %x\n", getpid(), ret_code); } } sessionInit(); ClRcT rc = clOsalMutexInit(&alarmClockCkptMutex); CL_ASSERT(rc == CL_OK); ioVecs = clHeapCalloc(MAX_NUM_IOVECS, sizeof(*ioVecs)); CL_ASSERT(ioVecs != NULL); return ret_code; }
static ClRcT initializeAmf(void) { ClRcT rc = CL_OK; ClRcT retCode; ClIocPhysicalAddressT notificationForComp = { CL_IOC_BROADCAST_ADDRESS, 0}; clLogCompName = (ClCharT*) "MSG"; /* Override generated eo name with a short name for our server */ clAppConfigure(&clEoConfig,clEoBasicLibs,clEoClientLibs); clMsgRegisterWithCpm(); if(gClMsgInit == CL_TRUE) { rc = CL_MSG_RC(CL_ERR_INITIALIZED); clLogError("MSG", "INI", "The Message Service is already initialized. error code [0x%x].", rc); goto error_out; } gLocalAddress = clIocLocalAddressGet(); gLocalPortId = CL_IOC_MSG_PORT; /* Initializing a database to maintain client information */ rc = clHandleDatabaseCreate((void (*)(void*))NULL, &gMsgClientHandleDb); if(rc != CL_OK) { clLogError("MSG", "INI", "Failed to initialize the handle database. error code [0x%x].", rc); goto error_out; } /* Initializing IDL for server to server and server to client communication. */ rc = clMsgCommIdlInitialize(); if(rc != CL_OK) { clLogError("MSG", "INI", "Failed to initialize the IDL. error code [0x%x].", rc); goto error_out_2; } /* Initializing a database for maintaining queues. */ rc = clMsgQueueInitialize(); if(rc != CL_OK) { clLogError("MSG", "INI", "Failed to initialize the queue databases. error code [0x%x].", rc); goto error_out_3; } rc = clMsgReceiverDatabaseInit(); if(rc != CL_OK) { clLogError("MSG", "INI", "Failed to initialize \"receiver database\". error code [0x%x].", rc); goto error_out_4; } rc = clOsalMutexInit(&gClMsgFinalizeLock); CL_ASSERT(rc == CL_OK); rc = clOsalCondInit(&gClMsgFinalizeCond); CL_ASSERT(rc == CL_OK); /* Initializing the Group-Information */ rc = clOsalMutexInit(&gClGroupDbLock); CL_ASSERT(rc == CL_OK); rc = clCpmNotificationCallbackInstall(notificationForComp, &clMsgNotificationReceiveCallback, NULL, &gMsgNotificationHandle); if(rc != CL_OK) { clLogError("MSG", "INI", "Failed to install the notification callback function. error code [0x%x].", rc); goto error_out_5; } /* Initializing the IDL generated code. */ rc = clMsgIdlClientInstall(); if(rc != CL_OK) { clLogError("MSG", "INI", "Failed to install Server Table. error code [0x%x].", rc); goto error_out_6; } rc = clMsgIdlClientTableRegister(CL_IOC_MSG_PORT); if(rc != CL_OK) { clLogError("MSG", "INI", "Failed to register Server Table. error code [0x%x].", rc); goto error_out_7; } rc = clMsgCltClientTableRegister(CL_IOC_MSG_PORT); if(rc != CL_OK) { clLogError("MSG", "INI", "Failed to register Client Table. error code [0x%x].", rc); goto error_out_8; } rc = clMsgCltSrvClientInstall(); if(rc != CL_OK) { clLogError("MSG", "INI", "Failed to install Client Server Table. error code [0x%x].", rc); goto error_out_9; } rc = clMsgCltSrvClientTableRegister(CL_IOC_MSG_PORT); if(rc != CL_OK) { clLogError("MSG", "INI", "Failed to register Client Server Table. error code [0x%x].", rc); goto error_out_10; } rc = clMsgFinalizeBlockInit(); if(rc != CL_OK) { clLogError("MSG", "INI", "Failed to initialize the msg-finalize blocker. error code [0x%x].", rc); goto error_out_11; } clMsgDebugCliRegister(); rc = clOsalTaskCreateDetached("MsgCkptInitAsync", CL_OSAL_SCHED_OTHER, CL_OSAL_THREAD_PRI_NOT_APPLICABLE, 0, clMsgCachedCkptInitAsync, NULL); CL_ASSERT(rc == CL_OK); goto out; error_out_11: retCode = clMsgCltSrvClientTableDeregister(); if(retCode != CL_OK) clLogError("MSG", "INI", "Failed to deregister Client Table. error code [0x%x].", retCode); error_out_10: retCode = clMsgCltSrvClientUninstall(); if(retCode != CL_OK) clLogError("MSG", "INI", "Failed to destroy the just opened handle database. error code [0x%x].", retCode); error_out_9: retCode = clMsgCltClientTableDeregister(); if(retCode != CL_OK) clLogError("MSG", "INI", "Failed to deregister Client Table. error code [0x%x].", retCode); error_out_8: retCode = clMsgIdlClientTableDeregister(); if(retCode != CL_OK) clLogError("MSG", "INI", "Failed to deregister Server Table. error code [0x%x].", retCode); error_out_7: retCode = clMsgIdlClientUninstall(); if(retCode != CL_OK) clLogError("MSG", "INI", "Failed to destroy the just opened handle database. error code [0x%x].", retCode); error_out_6: retCode = clCpmNotificationCallbackUninstall(&gMsgNotificationHandle); if(retCode != CL_OK) clLogError("MSG", "INI", "Failed to uninstall the notification callback function. error code [0x%x].", retCode); error_out_5: retCode = clOsalMutexDestroy(&gClGroupDbLock); if(retCode != CL_OK) clLogError("MSG", "INI", "Failed to destroy the group db mutex. error code [0x%x].", retCode); retCode = clOsalCondDestroy(&gClMsgFinalizeCond); if(retCode != CL_OK) clLogError("MSG", "INI", "Failed to destroy the finalization condition. error code [0x%x].", retCode); retCode = clOsalMutexDestroy(&gClMsgFinalizeLock); if(retCode != CL_OK) clLogError("MSG", "INI", "Failed to destroy the finalization mutex. error code [0x%x].", retCode); clMsgReceiverDatabaseFin(); error_out_4: retCode = clMsgQueueFinalize(); if(retCode != CL_OK) clLogError("MSG", "INI", "Failed to finalize the queue databases. error code [0x%x].", retCode); error_out_3: clMsgCommIdlFinalize(); error_out_2: retCode = clHandleDatabaseDestroy(gMsgClientHandleDb); if(retCode != CL_OK) clLogError("MSG", "INI", "Failed to destroy the handle database. error code [0x%x].", retCode); error_out: out: return rc; }//end of intializeAmf
ClRcT clAmsMgmtOIInitialize(ClAmsMgmtHandleT *pHandle, ClRcT (*pClAmsMgmtOIConfigAttributesGet) (ClAmsEntityConfigT*, ClCorAttributeValueListPtrT pAttrList), ClRcT (*pClAmsMgmtOIExtendedConfigAttributesGet) (ClAmsMgmtOIExtendedClassTypeT type, ClAmsMgmtOIExtendedEntityConfigT *pConfig, ClCorClassTypeT *pClassType, ClCorAttributeValueListT *pAttrList)) { ClRcT rc = CL_OK; ClAmsMgmtHandleT handle = 0; ClAmsEntityBufferT buffer[CL_AMS_ENTITY_TYPE_MAX+2] = {{0}}; ClVersionT version = {'B', 0x1, 0x1}; ClCorTxnSessionIdT txnSession = 0; ClUint32T i; ClCorAddrT appAddress = {0}; SaNameT chassisInstance = {0}; ClUint32T chassisId = 0; if(!pClAmsMgmtOIConfigAttributesGet) return CL_AMS_RC(CL_ERR_INVALID_PARAMETER); rc = clOsalMutexInit(&gClAmsMgmtOICacheMutex); CL_ASSERT(rc == CL_OK); rc = clEoMyEoIocPortGet(&appAddress.portId); if(rc != CL_OK) return rc; appAddress.nodeAddress = clIocLocalAddressGet(); rc = clAmsMgmtInitialize(&handle, NULL, &version); if(rc != CL_OK) { return rc; } snprintf(chassisInstance.value, sizeof(chassisInstance.value), "%s:%d", "\\Chassis", chassisId); chassisInstance.length = strlen(chassisInstance.value); rc = clCorMoIdNameToMoIdGet(&chassisInstance, &gClChassisMoid); if(rc != CL_OK) { clLogError("AMF", "MGMT", "COR moid get for [%s] returned [%#x]", chassisInstance.value, rc); goto out_free; } rc = clAmsMgmtGetSGList(handle, &buffer[CL_AMS_ENTITY_TYPE_SG]); if(rc != CL_OK) { clLogError("AMF", "MGMT", "Get SG list returned [%#x]", rc); goto out_free; } rc = clAmsMgmtGetSIList(handle, &buffer[CL_AMS_ENTITY_TYPE_SI]); if(rc != CL_OK) { clLogError("AMF", "MGMT", "Get SI list returned [%#x]", rc); goto out_free; } rc = clAmsMgmtGetCSIList(handle, &buffer[CL_AMS_ENTITY_TYPE_CSI]); if(rc != CL_OK) { clLogError("AMF", "MGMT", "Get CSI list returned [%#x]", rc); goto out_free; } rc = clAmsMgmtGetNodeList(handle, &buffer[CL_AMS_ENTITY_TYPE_NODE]); if(rc != CL_OK) { clLogError("AMF", "MGMT", "Get NODE list returned [%#x]", rc); goto out_free; } rc = clAmsMgmtGetSUList(handle, &buffer[CL_AMS_ENTITY_TYPE_SU]); if(rc != CL_OK) { clLogError("AMF", "MGMT", "Get SU list returned [%#x]", rc); goto out_free; } rc = clAmsMgmtGetCompList(handle, &buffer[CL_AMS_ENTITY_TYPE_COMP]); if(rc != CL_OK) { clLogError("AMF", "MGMT", "Get COMP list returned [%#x]", rc); goto out_free; } /* * Now fetch the moid for each of the entities and build the cache. */ for(i = 0; i <= CL_AMS_ENTITY_TYPE_MAX; ++i) { ClAmsEntityBufferT *pBuffer = &buffer[i]; ClUint32T j; if(!pBuffer->count || !pBuffer->entity) continue; gClAmsMgmtOIIndexTable[i] = pBuffer->count; for(j = 0; j < pBuffer->count; ++j) { ClCorMOIdT moid = {{{0}}}; rc = clAmsMgmtOIMoIdGet(handle, pBuffer->entity+j, &moid); if(rc != CL_OK) { continue; } clAmsMgmtOICacheAdd(clCorMoIdToInstanceGet(&moid), pBuffer->entity+j); /* * Required for instances exceeding the pre-configured limit. */ rc = clCorOIRegister(&moid, &appAddress); if(rc != CL_OK) { continue; } rc = clCorPrimaryOISet(&moid, &appAddress); if(rc != CL_OK) { /* * Ignore as it could be already set by the active. */ continue; } clAmsMgmtOIConfigAttributeSet(handle, &txnSession, &moid, pBuffer->entity+j, pClAmsMgmtOIConfigAttributesGet); clAmsMgmtOIExtendedConfigAttributeSet(handle, &txnSession, pBuffer->entity+j, pClAmsMgmtOIExtendedConfigAttributesGet); } } rc = clCorTxnSessionCommit(txnSession); if(rc != CL_OK) { clLogError("AMF", "MGMT", "AMF OI config commit returned [%#x]", rc); } else { clLogNotice("AMF", "MGMT", "Entity cache successfully initialized"); gClAmsMgmtOIInitialized = CL_TRUE; } out_free: for(i = 0; i <= CL_AMS_ENTITY_TYPE_MAX; ++i) { if(buffer[i].entity) clHeapFree(buffer[i].entity); if(rc != CL_OK) clAmsMgmtOICacheDestroy(i); } if(rc != CL_OK) { for(i = 0; i < CL_AMS_MGMT_OI_EXTENDED_CLASS_MAX; ++i) clAmsMgmtOIExtendedCacheDestroy(i); } if(rc == CL_OK && pHandle) *pHandle = handle; else clAmsMgmtFinalize(handle); return rc; }
ClRcT clEoQueueCreate(ClEoQueueHandleT *pHandle, ClIocPriorityT priority, ClThreadPoolModeT mode, ClInt32T maxThreads, ClInt32T threadPriority, ClEoJobCallBackT pJobHandler, ClPtrT pUserData ) { ClEoQueueT *pQueue =NULL; ClThreadPoolHandleT threadPool=0; ClRcT rc = CL_EO_RC(CL_ERR_INVALID_PARAMETER); if(pHandle == NULL) { CL_DEBUG_PRINT(CL_DEBUG_ERROR,("Invalid parameter\n")); goto out; } if( priority >= CL_IOC_MAX_PRIORITIES ) { CL_DEBUG_PRINT(CL_DEBUG_ERROR,("Invalid priority %d\n",priority)); goto out; } rc = CL_EO_RC(CL_ERR_OP_NOT_PERMITTED); CL_EO_QUEUE_LOCK(&gClEoQueueMutex); if(gpClEoQueues[priority]) { CL_EO_QUEUE_UNLOCK(&gClEoQueueMutex); CL_DEBUG_PRINT(CL_DEBUG_ERROR,("Queue with priority:%d already active\n",priority)); goto out; } CL_EO_QUEUE_UNLOCK(&gClEoQueueMutex); if(!threadPriority) { threadPriority = gClEoThreadPriorityMap[priority]; } rc = CL_EO_RC(CL_ERR_NO_MEMORY); #if 0 pQueue = clHeapCalloc(1,sizeof(*pQueue)); if(pQueue == NULL) { CL_DEBUG_PRINT(CL_DEBUG_ERROR,("Error allocating memory\n")); goto out; } #endif CL_JOB_LIST_INIT(&pQueue->queue); rc = clOsalMutexInit(&pQueue->mutex); CL_ASSERT(rc == CL_OK); rc = clOsalCondInit(&pQueue->cond); CL_ASSERT(rc == CL_OK); if(pJobHandler == NULL) { /*Default handler for jobs*/ pJobHandler = clEoJobHandler; } #if 0 /* GAS */ rc = clThreadPoolCreate(&threadPool,(ClEoQueueHandleT)pQueue, mode,maxThreads,threadPriority,pJobHandler, pUserData); #endif rc = clJobQueueInit(&gEoJobQueue, 0, maxThreads); if(rc != CL_OK) { CL_DEBUG_PRINT(CL_DEBUG_ERROR,("Error in thread pool create.rc=0x%x\n",rc)); goto out_free; } #if 0 pQueue->pThreadPool = (ClThreadPoolT*)threadPool; pQueue->priority = priority; CL_EO_QUEUE_LOCK(&gClEoQueueMutex); if(gpClEoQueues[priority]) { /*Someone beat us. So back out*/ CL_EO_QUEUE_UNLOCK(&gClEoQueueMutex); rc = CL_EO_RC(CL_ERR_OP_NOT_PERMITTED); clThreadPoolDelete((ClThreadPoolHandleT) threadPool); goto out_free; } pQueue->state = CL_EO_QUEUE_STATE_ACTIVE; gpClEoQueues[priority] = pQueue; CL_EO_QUEUE_UNLOCK(&gClEoQueueMutex); *pHandle = (ClEoQueueHandleT)pQueue; #endif rc = CL_OK; goto out; out_free: #if 0 clOsalMutexDestroy(&pQueue->mutex); clOsalCondDestroy(&pQueue->cond); clHeapFree(pQueue); #endif out: return rc; }