/* Library cleanup function.  Not reentrant! Remoes GMS handle database*/
ClRcT clGmsLibFinalize(void)
{
    ClRcT rc = CL_OK;
    ClEoExecutionObjT *eo = NULL;

    if (lib_initialized == CL_TRUE)
    {
#if 0   // Let it leak if we are quitting.  If we are not quitting, we'll reuse it on reinitialization.     
        rc = clHandleDatabaseDestroy(gmsHandleDb);
        if (rc != CL_OK)
        {
            goto error_exit;
        }
#endif
        
        rc = clEoMyEoObjectGet(&eo);
        if (rc != CL_OK)
        {
           clLogError(GEN,NA, "clEoMyEoObjectGet Failed with RC - 0x%x\n",rc);
        }

        clGmsClientClientTableDeregistrer(eo);
        clGmsClientTableDeregister(eo);

        rc = clGmsClientRmdTableUnInstall(eo);
        if (rc != CL_OK)
        {
            clLogError(GEN,NA, "clEoClientUninstall Failed with RC - 0x%x\n",rc);
        }

        lib_initialized = CL_FALSE;
    }
    
    return rc;
}
ClRcT clLogClientUninstall(void)
{
    ClEoExecutionObjT* pEoObj = NULL;
    ClRcT rc = CL_OK;

    rc = clEoMyEoObjectGet(&pEoObj);
    if (CL_OK != rc)
    {
        return rc;
    }
    rc = clOsalTaskKeyDelete(LogidlSyncKey);
    if (CL_OK != rc)
    {
        return rc;
    }
    rc = clHandleDatabaseDestroy(LogidlDatabaseHdl);
    if (CL_OK != rc)
    {
        return rc;
    }

    clEoClientUninstallTables(pEoObj,CL_EO_SERVER_SYM_MOD(gAspFuncTable,Log));

    return rc;
}
ClRcT
clLogSvrEoDataInit(ClLogSvrEoDataT        *pSvrEoEntry,
                   ClLogSvrCommonEoDataT  *pSvrCommonEoEntry)
{
    ClRcT               rc = CL_OK;

    CL_LOG_DEBUG_TRACE(("Enter"));

    pSvrEoEntry->hSvrStreamTable = CL_HANDLE_INVALID_VALUE;
    pSvrEoEntry->nextDsId        = CL_LOG_DSID_START;

    rc = clOsalMutexInit_L(&pSvrEoEntry->svrStreamTableLock);
    if( CL_OK != rc )
    {
        CL_LOG_DEBUG_ERROR(("clOsalMutexCreate(): rc[0x %x]", rc));
        return rc;
    }

    rc = clBitmapCreate(&pSvrEoEntry->hDsIdMap, pSvrCommonEoEntry->maxStreams);
    if( CL_OK != rc )
    {
        CL_LOG_DEBUG_ERROR(("clBitmapCreate(): rc[0x %x]", rc));
        CL_LOG_CLEANUP(clOsalMutexDestroy_L(&pSvrEoEntry->svrStreamTableLock),
                       CL_OK);
        return rc;
    }
    rc = clHandleDatabaseCreate(NULL, &pSvrEoEntry->hFlusherDB); 
    if( CL_OK != rc )
    {
        CL_LOG_DEBUG_ERROR(("clHandleDatabaseCreate(): rc[0x %x]", rc));
        CL_LOG_CLEANUP(clBitmapDestroy(pSvrEoEntry->hDsIdMap), CL_OK);
        CL_LOG_CLEANUP(clOsalMutexDestroy_L(&pSvrEoEntry->svrStreamTableLock),
                       CL_OK);
        return rc;
    }

    rc = clLogConfigDataGet(NULL, NULL, NULL, &pSvrEoEntry->maxFlushLimit);
    if( CL_OK != rc )
    {
        CL_LOG_DEBUG_ERROR(("clLogConfigDataGet(): rc[0x %x]", rc));
        CL_LOG_CLEANUP(clHandleDatabaseDestroy(pSvrEoEntry->hFlusherDB), CL_OK);
        CL_LOG_CLEANUP(clBitmapDestroy(pSvrEoEntry->hDsIdMap), CL_OK);
        CL_LOG_CLEANUP(clOsalMutexDestroy_L(&pSvrEoEntry->svrStreamTableLock),
                       CL_OK);
        return rc;
    }
    pSvrEoEntry->hCpm           = CL_HANDLE_INVALID_VALUE;    
    pSvrEoEntry->logCompId      = 0;
    pSvrEoEntry->gmsInit        = CL_FALSE; 
    pSvrEoEntry->evtInit        = CL_FALSE; 
    pSvrEoEntry->ckptInit       = CL_FALSE; 
    pSvrEoEntry->logInit        = CL_FALSE;
    pSvrEoEntry->hTimer         = CL_FALSE;

    CL_LOG_DEBUG_TRACE(("Exit"));
    return rc;
}
ClRcT   clDispatchLibFinalize(void)
{
    ClRcT   rc = CL_OK;

    CHECK_LIB_INIT;

    rc = clHandleDatabaseDestroy(databaseHandle);
    if (rc != CL_OK)
    {
        CL_DEBUG_PRINT(CL_DEBUG_ERROR,
                ("clHandleDatabaseDestroy failed with rc 0x%x\n",rc));
    }
    databaseHandle = CL_HANDLE_INVALID_VALUE;
    return rc;
}
ClRcT clMsgQueueFinalize(void)
{
    ClRcT rc;
    
    rc = clOsalMutexDestroy(&gClQueueDbLock);
    if(rc != CL_OK)
        clLogError("QUE", "FIN", "Failed to destroy queue db mutex. error code [0x%x].", rc);
    
    rc = clOsalMutexDestroy(&gClLocalQsLock);
    if(rc != CL_OK)
        clLogError("QUE", "FIN", "Failed to destroy the local queues' mutex. error code [0x%x].", rc);

    rc = clHandleDatabaseDestroy(gClMsgQDatabase);
    if(rc != CL_OK)
        clLogError("QUE", "FIN", "Failed to delete the Queue Handle database. error code [0x%x].", rc);
    
    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;
}
ClRcT clDebugLibFinalize(void)
{
    ClEoExecutionObjT  *pEoObj    = NULL; 
    ClDebugObjT        *pDebugObj = NULL;
    ClRcT              rc         = CL_OK;

    rc = clEoMyEoObjectGet(&pEoObj);
    if (CL_OK != rc)
    {
        return rc;
    }

    rc = clEoPrivateDataGet( pEoObj, CL_EO_DEBUG_OBJECT_COOKIE_ID,
                             (void**) &pDebugObj);
    if (CL_OK != rc)
    {
        return rc;
    }

    clEoDebugDeregister();

    if( CL_OK != (rc = clHandleDatabaseDestroy(pDebugObj->hDebugFnDB))) 
    {
        CL_DEBUG_PRINT(CL_DEBUG_ERROR, ("clHandleDatabaseDestroy(): "
                       "rc[0x %x]", rc));
    }
    
    clDebugClientTableDeregister(pEoObj);

    if( CL_OK != (rc = clEoClientUninstallTables(pEoObj, CL_EO_SERVER_SYM_MOD(gAspFuncTable, DEBUGCli))) )
    {
        CL_DEBUG_PRINT(CL_DEBUG_ERROR, ("clEoClientUninstall(): rc[0x %x]",
                    rc));
    }

    clHeapFree(pDebugObj);

    return rc;
}
void clGmsServerTerminate(SaInvocationT invocation, const SaNameT *compName)
{

    ClRcT   rc = CL_OK;

    gmsGlobalInfo.opState = CL_GMS_STATE_SHUTING_DOWN;

    clLog(CRITICAL,GEN,NA, "Got termination request for component [%.*s]. Started Shutting Down...", compName->length,compName->value);
    
    rc = clEoClientUninstallTables (gmsGlobalInfo.gmsEoObject, CL_EO_SERVER_SYM_MOD(gAspFuncTable, GMS));
    if (rc != CL_OK)
    {
        clLog(ERROR,GEN,NA, "clEoClientUninstall failed with rc = 0x%x", rc);
    }
    /*
     * Unregister with AMF and respond to AMF saying whether the
     * termination was successful or not.
     */
    

    rc = clDebugDeregister(gGmsDebugReg);
    if (rc != CL_OK)
    {
        clLog(ERROR,GEN,NA, "clDebugDeregister failed with rc = 0x%x", rc);
    }

    /* Close the leader election algorithm dl if open */
#ifndef VXWORKS_BUILD 
    if (pluginHandle != NULL)
    {
        dlclose(pluginHandle);
    }
#endif

    if(gClTotemRunning)
    {
        /* We need to invoke openais finalize function instead of signal
         * handler here */
        totempg_finalize();

        /* Waiting for 10ms before invoking exit() */
        usleep(10000);
    }
    clLog(CRITICAL,GEN,NA,
          "GMS server exiting");

    rc = clHandleDatabaseDestroy(contextHandleDatabase);
    if (rc != CL_OK)
    {
        clLog(ERROR,GEN,NA,
                "contextHandleDatabase destroy failed with Rc = 0x%x",rc);
    }
    rc = saAmfComponentUnregister(amfHandle, compName, NULL);
    
    if(rc != SA_AIS_OK) 
    {
        clLog(ERROR,GEN,NA,
              "saAmfComponentUnregister failed with rc = 0x%x", rc);     
    }

    rc = saAmfFinalize(amfHandle);

    if (rc != SA_AIS_OK)
    {
        clLog(ERROR,GEN,NA,
              "saAmfFinalize failed with rc = 0x%x", rc);
    }
    /* Ok tell SAFplus that we handled it properly */
    rc = saAmfResponse(amfHandle, invocation, SA_AIS_OK);
    
    if (rc != SA_AIS_OK)
    {
        clLog(ERROR,GEN,NA,
              "clCpmResponse failed with rc = 0x%x", rc);
    }
    unblockNow = CL_TRUE;
}
Example #9
0
/*
 * Called with the msg finalize lock held.
 */
static int safMsgFinalize(ClBoolT *pLockStatus)
{
    ClRcT  rc = CL_OK;
    if(pLockStatus && !*pLockStatus) 
        return CL_MSG_RC(CL_ERR_INVALID_STATE);

    CL_MSG_INIT_CHECK(rc);
    if( rc != CL_OK)
    {
         return rc;
    }    
   
    gClMsgInit = CL_FALSE;

    if(pLockStatus)
    {
        *pLockStatus = CL_FALSE;
        clOsalMutexUnlock(&gClMsgFinalizeLock);
    }

    clMsgFinalizeBlocker();

    rc = clMsgFinalizeBlockFin();
    if(rc != CL_OK)
        clLogError("MSG", "INI", "Failed to cleanup the msg-finalize blocker. error code [0x%x].", rc);

    clMsgDebugCliDeregister();

    clMsgCommIdlFinalize();

    /* Finalize the IDL generated code. */
    rc = clMsgCltClientTableDeregister();
    if(rc != CL_OK)
        clLogError("MSG", "FIN", "Failed to deregister Client Table. error code [0x%x].", rc);

    rc = clMsgIdlClientTableDeregister();
    if(rc != CL_OK)
        clLogError("MSG", "FIN", "Failed to deregister Server Table. error code [0x%x].", rc);

    clMsgIdlClientUninstall();

    rc = clMsgCltSrvClientTableDeregister();
    if(rc != CL_OK)
        clLogError("MSG", "FIN", "Failed to deregister Client Server Table. error code [0x%x].", rc);

    clMsgCltSrvClientUninstall();

    /* Finalize cached ckpt for MSG queue & MSG queue group */
    rc = clMsgQCkptFinalize();
    if(rc != CL_OK)
        clLogError("MSG", "FIN", "clMsgQCkptFinalize(): error code [0x%x].", rc);

    /* Finalize database for maintaining queues. */
    clMsgReceiverDatabaseFin();

    rc = clMsgQueueFinalize();
    if(rc != CL_OK)
        clLogError("MSG", "FIN", "Failed to finalize queue databases. error code [0x%x].", rc);

    rc = clCpmNotificationCallbackUninstall(&gMsgNotificationHandle);
    if(rc != CL_OK)
        clLogError("MSG", "FIN", "Failed to uninstall the notification callback function. error code [0x%x].", rc);

    rc = clOsalMutexDestroy(&gClGroupDbLock);
    if(rc != CL_OK)
        clLogError("MSG", "FIN", "Failed to destroy the group db lock. error code [0x%x].", rc);

    rc = clHandleDatabaseDestroy(gMsgClientHandleDb);
    if(rc != CL_OK)
        clLogError("MSG", "FIN", "Failed to destroy the client handle database. error code [0x%x].", rc);

    return rc;
}
Example #10
0
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
SaAisErrorT
saClmFinalize (
        const SaClmHandleT clmHandle
        )
{
    ClRcT rc = CL_OK;
    ClHandleT   localHandle = CL_HANDLE_INVALID_VALUE;
    SaClmInstanceT      *clmInstance = NULL;
    
    SA_GMS_CHECK_INIT_COUNT();

    /* Handle checkout */
    localHandle = (ClHandleT)clmHandle;
    rc = clHandleCheckout(databaseHandle, localHandle, (void**)&clmInstance);
    if (rc != CL_OK)
    {
    return _aspErrToAisErr(rc);
}
    CL_ASSERT(clmInstance != NULL);
    
    /* Finalize with GMS */
    rc = clGmsFinalize(localHandle);
    if (rc != CL_OK)
    {
        clLogError("CLM","FIN",
                   "clGmsFinalize failed with rc 0x%x\n",rc);
    }

    /* Deregister with dispatch */
    rc = clDispatchDeregister(clmInstance->dispatchHandle);
    if (rc != CL_OK)
    {
        clLogError(GMS_LOG_AREA_CLM,GMS_LOG_CTX_CLM_FINALISE,
                   "clDispatchDeregister failed with rc 0x%x\n",rc);
    }

    /* Checkin the handle */
    if ((clHandleCheckin(databaseHandle, localHandle)) != CL_OK)
    {
        clLogError(GMS_LOG_AREA_CLM,GMS_LOG_CTX_CLM_FINALISE,
                    "clHandleCheckin failed");
    }

    /* Destroy the handle */
    if ((clHandleDestroy(databaseHandle, localHandle)) != CL_OK)
    {
        clLogError(GMS_LOG_AREA_CLM,GMS_LOG_CTX_CLM_FINALISE,
                   "clHandleDestroy failed");
    }

    SA_GMS_INIT_COUNT_DEC();
    if (isLastFinalize() == CL_TRUE)
    {
        rc = clHandleDatabaseDestroy(databaseHandle);
        if (rc != CL_OK)
        {
            clLogError(GMS_LOG_AREA_CLM,GMS_LOG_CTX_CLM_DB,
                       "clHandleDatabaseDestroy failed with rc 0x%x\n",rc);
        }
    }
    
    if(CL_OK != clASPFinalize())
    {
        clLogInfo("CLM", "FIN",
                  "ASP finalize failed, rc[0x%X]", rc);
        return SA_AIS_ERR_LIBRARY;
    }

    return _aspErrToAisErr(rc);
}
static ClRcT
clLogFileHdlrHandleCreate(ClLogHandleT       hLog,
                          ClBoolT            isDelete, 
                          ClUint32T          operatingLvl, 
                          ClLogClntFileKeyT  *pFileKey,
                          ClHandleT          *phFile)
{
    ClRcT                   rc            = CL_OK;
    ClBoolT                 entryAdd      = CL_FALSE;
    ClLogClntFileHdlrInfoT  *pData        = NULL;
    ClLogClntEoDataT        *pClntEoEntry = NULL;

    CL_LOG_DEBUG_TRACE(("Enter"));

    rc = clLogClntEoEntryGet(&pClntEoEntry);
    if( CL_OK != rc )
    {
        return rc;
    }

    rc = clHandleCreate(pClntEoEntry->hClntHandleDB, 
                        sizeof(ClLogClntFileHdlrInfoT), phFile);
    if( CL_OK != rc )
    {
        CL_LOG_DEBUG_ERROR(("clHandleCreate(); rc[0x %x]", rc));
        if( CL_TRUE == entryAdd )
        {
            CL_LOG_CLEANUP(clHandleDatabaseDestroy(pClntEoEntry->hClntHandleDB),
                           CL_OK);
        }
        return rc;
    }

    rc = clHandleCheckout(pClntEoEntry->hClntHandleDB, *phFile, 
                          (void **) &pData);
    if( CL_OK != rc )
    {
        CL_LOG_DEBUG_ERROR(("clHandleCheckout(): rc[0x %x]", rc));
        CL_LOG_CLEANUP(clHandleDestroy(pClntEoEntry->hClntHandleDB, *phFile),
                       CL_OK);
        if( CL_TRUE == entryAdd )
        {
            CL_LOG_CLEANUP(clHandleDatabaseDestroy(pClntEoEntry->hClntHandleDB),
                           CL_OK);
        }
        return rc;
    }
    pData->type         = CL_LOG_FILE_HANDLE;
    pData->isDelete     = isDelete;
    pData->startRead    = 0;
    pData->operatingLvl = operatingLvl;
    pData->hLog         = hLog;
    pData->pFileKey     = pFileKey; 

    rc = clHandleCheckin(pClntEoEntry->hClntHandleDB, *phFile);
    if( CL_OK != rc )
    {
        CL_LOG_DEBUG_ERROR(("clHandleCheckin(); rc[0x %x]", rc));
        CL_LOG_CLEANUP(clHandleDestroy(pClntEoEntry->hClntHandleDB, *phFile),
                       CL_OK);
        if( CL_TRUE == entryAdd )
        {
            CL_LOG_CLEANUP(clHandleDatabaseDestroy(pClntEoEntry->hClntHandleDB),
                           CL_OK);
        }
        return rc;
    }

    CL_LOG_DEBUG_TRACE(("Exit"));
    return rc;
}
ClRcT clDebugLibInitialize(void)
{
    ClEoExecutionObjT  *pEoObj     = NULL;
    ClDebugObjT        *pDebugObj  = NULL;
    ClRcT              rc          = CL_OK;
    ClNameT            compName    = {0};
    
    rc = clEoMyEoObjectGet(&pEoObj);
    if (CL_OK != rc)
    {
        return rc;
    }

    pDebugObj = clHeapCalloc(1, sizeof(ClDebugObjT));
    if (NULL == pDebugObj)
    {
        clLogWrite(CL_LOG_HANDLE_APP,CL_LOG_CRITICAL,CL_DEBUG_LIB_CLIENT,
                   CL_LOG_MESSAGE_0_MEMORY_ALLOCATION_FAILED);
        return CL_DEBUG_RC(CL_ERR_NO_MEMORY);
    }

    rc = clOsalTaskKeyCreate(&pDebugObj->debugTaskKey, NULL);
    if(rc != CL_OK)
    {
        CL_DEBUG_PRINT(CL_DEBUG_ERROR, ("Debug task key create returned with [%#x]\n", rc));
        clHeapFree(pDebugObj);
        return CL_DEBUG_RC(CL_GET_ERROR_CODE(rc));
    }

    rc = clHandleDatabaseCreate(NULL, &pDebugObj->hDebugFnDB);
    if( CL_OK != rc )
    {
        CL_DEBUG_PRINT(CL_DEBUG_ERROR, ("clHandleDatabaseCreate(): rc[0x %x]",
                rc));
        clHeapFree(pDebugObj);
        return CL_DEBUG_RC(CL_ERR_NO_MEMORY);
    }

    /* Getting the compName from CPM */
    rc = clCpmComponentNameGet(0, &compName);
    if( CL_OK != rc )
    {
        CL_DEBUG_PRINT(CL_DEBUG_ERROR, ("clCpmComponentNameGet(): rc[0x %x]",
                    rc));
        clLogWrite(CL_LOG_HANDLE_APP,CL_LOG_WARNING,CL_DEBUG_LIB_CLIENT,
                   CL_LOG_MESSAGE_1_INVALID_PARAMETER, 
                   "CompNameGet is not proper");
        return rc;
    }

    pDebugObj->numFunc       = 0;
    /* Assining the compName */
    memset(pDebugObj->compName, '\0', CL_DEBUG_COMP_NAME_LEN);
    if( compName.length < CL_DEBUG_COMP_NAME_LEN )
    {
        memcpy(pDebugObj->compName, compName.value, compName.length);
        pDebugObj->compName[compName.length] = '\0';
    }
    else
    {
        clLogWrite(CL_LOG_HANDLE_APP,CL_LOG_WARNING,CL_DEBUG_LIB_CLIENT,
                   CL_LOG_MESSAGE_1_INVALID_PARAMETER,"CompName is Invalid");
        return CL_DEBUG_RC(CL_ERR_INVALID_PARAMETER);
    }

    /* Assigning compPrompt to DEFAULT */
    memset(pDebugObj->compPrompt, '\0', CL_DEBUG_COMP_PROMPT_LEN);
    strcpy(pDebugObj->compPrompt, "DEFAULT");

    rc = clEoClientInstallTablesWithCookie( pEoObj, 
                                            CL_EO_SERVER_SYM_MOD(gAspFuncTable, DEBUGCli),
                                            pDebugObj);
    if (CL_OK != rc)
    {
        CL_DEBUG_PRINT(CL_DEBUG_ERROR, ("clEoClientInstall(): rc[0x %x]", rc));
        clHandleDatabaseDestroy(pDebugObj->hDebugFnDB);
        clHeapFree(pDebugObj);
        return rc;
    }
    rc = clDebugClientTableRegister(pEoObj);
    if(CL_OK != rc)
    {
        clEoClientUninstallTables(pEoObj, 
                                  CL_EO_SERVER_SYM_MOD(gAspFuncTable, DEBUGCli));
        clHandleDatabaseDestroy(pDebugObj->hDebugFnDB);
        clHeapFree(pDebugObj);
        return rc;
    }

    rc = clEoPrivateDataSet(pEoObj, CL_EO_DEBUG_OBJECT_COOKIE_ID, pDebugObj);
    if (CL_OK != rc)
    {
        CL_DEBUG_PRINT(CL_DEBUG_ERROR, ("clEoPrivateDataSet(): rc[0x %x]", rc));
        clEoClientUninstallTables(pEoObj, 
                                  CL_EO_SERVER_SYM_MOD(gAspFuncTable, DEBUGCli));
        clHandleDatabaseDestroy(pDebugObj->hDebugFnDB);
        clHeapFree(pDebugObj);
        return rc;
    }
    
    clEoDebugRegister();

    return rc;
}
Example #14
0
ClRcT clRmdObjClose(ClRmdObjHandleT p)
{
#if 0 // Don't know why safplus_amf process hang at clOsalMutexLock(pRmdObject->semaForRecvHashTable)
    ClRcT retCode = CL_OK;
    ClRmdObjT *pRmdObject = NULL;

    CL_FUNC_ENTER();

    pRmdObject = (ClRmdObjT *) p;

    if (NULL == pRmdObject)
    {
        RMD_DBG1((" RMD  Invalid rmd handle in objclose\n"));
        CL_FUNC_EXIT();
        return ((CL_RMD_RC(CL_ERR_INVALID_PARAMETER)));
    }

    /*
     * Avoid deleting the mutexes so its still valid in case any context is abusing the terminate
     * and initiating or not quitting the rmd sends.
     */

    retCode = clOsalMutexDelete(pRmdObject->semaForRecvHashTable);

    if (CL_OK != retCode)
    {
        RMD_DBG1((" RMD Recv mutex delete failed\n"));
    }
    
    retCode = clOsalMutexDelete(pRmdObject->semaForSendHashTable);

    if (CL_OK != retCode)
    {
        RMD_DBG1((" RMD Send mutex delete failed\n"));
    }

    clOsalMutexLock(pRmdObject->semaForRecvHashTable);
    retCode = clCntDelete(pRmdObject->rcvRecContainerHandle);
    if (CL_OK != retCode)
    {
        RMD_DBG1((" RMD rcv hash table destroy failed\n"));
    }
    pRmdObject->rcvRecContainerHandle = 0;
    clOsalMutexUnlock(pRmdObject->semaForRecvHashTable);

    clOsalMutexLock(pRmdObject->semaForSendHashTable);
    retCode = clCntDelete(pRmdObject->sndRecContainerHandle);
    if (CL_OK != retCode)
    {
        RMD_DBG1((" RMD snd hash table destroy failed\n"));

    }
    pRmdObject->sndRecContainerHandle = 0;
    clOsalMutexUnlock(pRmdObject->semaForSendHashTable);

    retCode = clHandleDatabaseDestroy(pRmdObject->responseCntxtDbHdl);
    if (CL_OK != retCode)
    {
        RMD_DBG1((" RMD snd hash table destroy failed\n"));

    }
    pRmdObject->responseCntxtDbHdl = 0;

    /*
     * Don't release the rmd context to respect abusers or initiators of rmd send outside
     * terminate callback contexts.
     */
    clHeapFree(pRmdObject);
#endif

    CL_FUNC_EXIT();
    return (CL_OK);
}