in LCM/dsc/engine/ConfigurationManager/LocalConfigurationManager.c [363:539]
MI_EXTERN_C PAL_Uint32 THREAD_API Invoke_GetConfiguration_Internal(void *param)
{
MI_Result miResult = MI_RESULT_OK;
MI_Instance *cimErrorDetails = NULL;
MI_InstanceA outInstances = {0};
MI_Value val;
MI_Uint32 bufferIndex = 0;
MSFT_DSCLocalConfigurationManager_GetConfiguration outputObject;
MI_Uint8A dataValue = {0};
//Declarations for measuring time
MI_Real64 duration;
ptrdiff_t start, finish;
Context_Invoke_Basic *args = (Context_Invoke_Basic*)param;
if( args == NULL )
{
return 0;
}
if( (args->dataExist && args->data.data == NULL) || args->methodName == NULL)
{
MI_Context_PostResult(args->context, MI_RESULT_INVALID_PARAMETER);
return 0;
}
miResult = InitHandler(args->methodName, &cimErrorDetails);
if (miResult != MI_RESULT_OK)
{
MI_PostCimError(args->context, cimErrorDetails);
MI_Instance_Delete(cimErrorDetails);
ResetJobId();
if (args->dataExist)
{
PAL_Free(args->data.data);
}
PAL_Free(args);
return 0;
}
miResult = TryBeginLcmOperation(args->methodName, &cimErrorDetails);
if (miResult != MI_RESULT_OK)
{
MI_PostCimError(args->context, cimErrorDetails);
MI_Instance_Delete(cimErrorDetails);
ResetJobId();
if (args->dataExist)
{
PAL_Free(args->data.data);
}
PAL_Free(args);
return 0;
}
// If the configuration file has not been passed in the parameters
if (!args->dataExist)
{
// If the current and pending configuration files do not exist, output a corresponding error message and return
if (File_ExistT(GetCurrentConfigFileName())== -1)
{
if (File_ExistT(GetPendingConfigFileName()) == -1)
{
GetCimMIError(MI_RESULT_FAILED, &cimErrorDetails, ID_LCMHELPER_CURRENT_NOTFOUND);
goto ExitWithError;
}
else
{
// Read file contents from the pending configuration file into dataValue
miResult = ReadFileContent(GetPendingConfigFileName(), &dataValue.data, &dataValue.size, &cimErrorDetails);
}
}
else
{
// Read file contents from the current configuration file into dataValue
miResult = ReadFileContent(GetCurrentConfigFileName(), &dataValue.data, &dataValue.size, &cimErrorDetails);
}
if (miResult != MI_RESULT_OK)
{
goto ExitWithError;
}
}
else
{
// If a configuration file name is passed in the parameters, read from the passed configuration file.
GetRealBufferIndex((MI_ConstUint8A*)&(args->data.data), &bufferIndex);
dataValue.data = (MI_Uint8*)(args->data.data + bufferIndex);
dataValue.size = args->data.size - bufferIndex;
}
miResult = MSFT_DSCLocalConfigurationManager_GetConfiguration_Construct(&outputObject, args->context);
if (miResult != MI_RESULT_OK)
{
GetCimMIError(miResult, &cimErrorDetails, ID_LCMHELPER_CONSTRUCTGET_FAILED);
goto ExitWithError;
}
start=CPU_GetTimeStamp();
SetLCMStatusBusy();
miResult = CallGetConfiguration(dataValue.data,
dataValue.size, &outInstances,
args->context, &cimErrorDetails);
if (miResult != MI_RESULT_OK)
{
MSFT_DSCLocalConfigurationManager_GetConfiguration_Destruct(&outputObject);
goto ExitWithError;
}
val.instancea.data = outInstances.data;
val.instancea.size = outInstances.size;
miResult = MI_Instance_SetElement(&outputObject.__instance, MI_T("configurations"), &val, MI_INSTANCEA, 0);
CleanUpInstanceCache(&outInstances);
if (miResult != MI_RESULT_OK)
{
GetCimMIError(miResult, &cimErrorDetails, ID_LCMHELPER_SETGET_FAILED);
MSFT_DSCLocalConfigurationManager_GetConfiguration_Destruct(&outputObject);
goto ExitWithError;
}
miResult = MSFT_DSCLocalConfigurationManager_GetConfiguration_Set_MIReturn(&outputObject, 0);
if (miResult != MI_RESULT_OK)
{
GetCimMIError(miResult, &cimErrorDetails, ID_LCMHELPER_SETGET_FAILED);
MSFT_DSCLocalConfigurationManager_GetConfiguration_Destruct(&outputObject);
goto ExitWithError;
}
miResult = MSFT_DSCLocalConfigurationManager_GetConfiguration_Post(&outputObject, args->context);
MSFT_DSCLocalConfigurationManager_GetConfiguration_Destruct(&outputObject);
if (miResult != MI_RESULT_OK)
{
GetCimMIError(miResult, &cimErrorDetails, ID_LCMHELPER_POSTGET_FAILED);
goto ExitWithError;
}
// Stop the clock and measure time taken for this operation
finish=CPU_GetTimeStamp();
duration = (MI_Real64)(finish- start) / TIME_PER_SECONND;
LCM_WriteMessage_Internal_TimeTaken(args->context,EMPTY_STRING, ID_LCM_TIMEMESSAGE, ID_OUTPUT_ITEM_GET,(const MI_Real64)duration, MI_WRITEMESSAGE_CHANNEL_VERBOSE);
EndLcmOperation();
SetLCMStatusReady();
MI_Context_PostResult(args->context, MI_RESULT_OK);
//Debug Log
DSC_EventWriteMethodEnd(__WFUNCTION__);
if (!args->dataExist)
{
DSC_free(dataValue.data);
}
ResetJobId();
if (args->dataExist)
{
PAL_Free(args->data.data);
}
PAL_Free(args);
return 0;
ExitWithError:
ResetJobId();
EndLcmOperation();
SetLCMStatusReady();
MI_PostCimError(args->context, cimErrorDetails);
MI_Instance_Delete(cimErrorDetails);
if (!args->dataExist)
{
DSC_free(dataValue.data);
}
if (args->dataExist)
{
PAL_Free(args->data.data);
}
PAL_Free(args);
return 0;
}