version 1.32, 2006/10/24 20:42:59
|
version 1.32.6.9, 2008/02/20 11:28:02
|
|
|
//============================================================================== | //============================================================================== |
// | // |
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
|
// NOCHKSRC |
| |
#include "CMPI_Version.h" | #include "CMPI_Version.h" |
| |
|
|
broker.hdl =0; | broker.hdl =0; |
broker.provider = this; | broker.provider = this; |
if (mv) miVector=*mv; | if (mv) miVector=*mv; |
noUnload=false; |
unloadStatus = CMPI_RC_DO_NOT_UNLOAD; |
Time::gettimeofday(&_idleTime); |
|
} |
|
|
|
CMPIProvider::CMPIProvider(CMPIProvider *pr) |
|
: _status(UNINITIALIZED), _module(pr->_module), _cimom_handle(0), _name(pr->_name), |
|
_no_unload(0), _rm(0), _threadWatchList(), _cleanedThreads() |
|
{ |
|
_current_operations = 1; |
|
_currentSubscriptions = 0; |
|
miVector=pr->miVector; |
|
broker.hdl =0; |
|
broker.provider = this; |
|
_cimom_handle=new CIMOMHandle(); |
|
noUnload=pr->noUnload; |
|
Time::gettimeofday(&_idleTime); | Time::gettimeofday(&_idleTime); |
} | } |
| |
CMPIProvider::~CMPIProvider(void) | CMPIProvider::~CMPIProvider(void) |
{ | { |
delete (CIMOMHandle*)broker.hdl; |
|
PEGASUS_ASSERT ( _threadWatchList.size () == 0 ); |
|
PEGASUS_ASSERT ( _cleanedThreads.size () == 0 ); |
|
} | } |
| |
CMPIProvider::Status CMPIProvider::getStatus(void) | CMPIProvider::Status CMPIProvider::getStatus(void) |
|
|
const char *generic, | const char *generic, |
const char *spec) | const char *spec) |
{ | { |
|
if (error.size() > 0) |
|
{ |
|
error.append(", "); |
|
} |
if (miVector.genericMode) | if (miVector.genericMode) |
error.append(generic); | error.append(generic); |
else | else |
|
|
error.append(realProviderName); | error.append(realProviderName); |
error.append(spec); | error.append(spec); |
} | } |
error.append(", "); |
|
} | } |
| |
void CMPIProvider::initialize(CIMOMHandle & cimom, | void CMPIProvider::initialize(CIMOMHandle & cimom, |
|
|
String & name, | String & name, |
CMPI_Broker & broker) | CMPI_Broker & broker) |
{ | { |
broker.hdl=new CIMOMHandle(cimom); |
broker.hdl=& cimom; |
broker.bft=CMPI_Broker_Ftab; | broker.bft=CMPI_Broker_Ftab; |
broker.eft=CMPI_BrokerEnc_Ftab; | broker.eft=CMPI_BrokerEnc_Ftab; |
broker.xft=CMPI_BrokerExt_Ftab; | broker.xft=CMPI_BrokerExt_Ftab; |
broker.mft=NULL; // CMPI memory services not supported | broker.mft=NULL; // CMPI memory services not supported |
{ |
|
WriteLock writeLock (broker.rwsemClassCache); |
|
| |
broker.clsCache=new ClassCache(); |
broker.clsCache.reset(new ClassCache()); |
} |
|
broker.name=name; | broker.name=name; |
| |
const OperationContext opc; | const OperationContext opc; |
CMPI_ContextOnStack eCtx(opc); | CMPI_ContextOnStack eCtx(opc); |
CMPI_ThreadContext thr(&broker,&eCtx); | CMPI_ThreadContext thr(&broker,&eCtx); |
CMPIStatus rc = {CMPI_RC_OK, NULL}; |
CMPIStatus rcInst = {CMPI_RC_OK, NULL}; |
String error = String::EMPTY; |
CMPIStatus rcAssoc = {CMPI_RC_OK, NULL}; |
|
CMPIStatus rcMeth = {CMPI_RC_OK, NULL}; |
|
CMPIStatus rcProp = {CMPI_RC_OK, NULL}; |
|
CMPIStatus rcInd = {CMPI_RC_OK, NULL}; |
|
String error; |
String realProviderName(name); | String realProviderName(name); |
| |
if (miVector.genericMode) { | if (miVector.genericMode) { |
CString mName=realProviderName.getCString(); | CString mName=realProviderName.getCString(); |
|
|
if (miVector.miTypes & CMPI_MIType_Instance) | if (miVector.miTypes & CMPI_MIType_Instance) |
miVector.instMI=miVector.createGenInstMI(&broker,&eCtx,mName, &rc); |
{ |
|
miVector.instMI = |
|
miVector.createGenInstMI(&broker,&eCtx,mName, &rcInst); |
|
} |
if (miVector.miTypes & CMPI_MIType_Association) | if (miVector.miTypes & CMPI_MIType_Association) |
miVector.assocMI=miVector.createGenAssocMI(&broker,&eCtx,mName, &rc); |
{ |
|
miVector.assocMI = |
|
miVector.createGenAssocMI(&broker,&eCtx,mName, &rcAssoc); |
|
} |
if (miVector.miTypes & CMPI_MIType_Method) | if (miVector.miTypes & CMPI_MIType_Method) |
miVector.methMI=miVector.createGenMethMI(&broker,&eCtx,mName, &rc); |
{ |
|
miVector.methMI = |
|
miVector.createGenMethMI(&broker,&eCtx,mName, &rcMeth); |
|
} |
if (miVector.miTypes & CMPI_MIType_Property) | if (miVector.miTypes & CMPI_MIType_Property) |
miVector.propMI=miVector.createGenPropMI(&broker,&eCtx,mName, &rc); |
{ |
|
miVector.propMI = |
|
miVector.createGenPropMI(&broker,&eCtx,mName, &rcProp); |
|
} |
if (miVector.miTypes & CMPI_MIType_Indication) | if (miVector.miTypes & CMPI_MIType_Indication) |
miVector.indMI=miVector.createGenIndMI(&broker,&eCtx,mName, &rc); |
{ |
|
miVector.indMI = |
|
miVector.createGenIndMI(&broker,&eCtx,mName, &rcInd); |
|
} |
} | } |
else { | else { |
if (miVector.miTypes & CMPI_MIType_Instance) | if (miVector.miTypes & CMPI_MIType_Instance) |
miVector.instMI=miVector.createInstMI(&broker,&eCtx, &rc); |
miVector.instMI=miVector.createInstMI(&broker,&eCtx, &rcInst); |
if (miVector.miTypes & CMPI_MIType_Association) | if (miVector.miTypes & CMPI_MIType_Association) |
miVector.assocMI=miVector.createAssocMI(&broker,&eCtx, &rc); |
miVector.assocMI=miVector.createAssocMI(&broker,&eCtx, &rcAssoc); |
if (miVector.miTypes & CMPI_MIType_Method) | if (miVector.miTypes & CMPI_MIType_Method) |
miVector.methMI=miVector.createMethMI(&broker,&eCtx, &rc); |
miVector.methMI=miVector.createMethMI(&broker,&eCtx, &rcMeth); |
if (miVector.miTypes & CMPI_MIType_Property) | if (miVector.miTypes & CMPI_MIType_Property) |
miVector.propMI=miVector.createPropMI(&broker,&eCtx, &rc); |
miVector.propMI=miVector.createPropMI(&broker,&eCtx, &rcProp); |
if (miVector.miTypes & CMPI_MIType_Indication) | if (miVector.miTypes & CMPI_MIType_Indication) |
miVector.indMI=miVector.createIndMI(&broker,&eCtx, &rc); |
miVector.indMI=miVector.createIndMI(&broker,&eCtx, &rcInd); |
} | } |
| |
if (miVector.miTypes & CMPI_MIType_Instance) | if (miVector.miTypes & CMPI_MIType_Instance) |
if (miVector.instMI == NULL || rc.rc != CMPI_RC_OK) |
{ |
setError(miVector, error, realProviderName, _Generic_Create_InstanceMI, _Create_InstanceMI); |
if (miVector.instMI == NULL || rcInst.rc != CMPI_RC_OK) |
|
setError(miVector, error, realProviderName, |
|
_Generic_Create_InstanceMI, _Create_InstanceMI); |
|
} |
if (miVector.miTypes & CMPI_MIType_Association) | if (miVector.miTypes & CMPI_MIType_Association) |
if (miVector.assocMI == NULL || rc.rc != CMPI_RC_OK) |
{ |
setError(miVector, error, realProviderName, _Generic_Create_AssociationMI, _Create_AssociationMI); |
if (miVector.assocMI == NULL || rcAssoc.rc != CMPI_RC_OK) |
|
setError(miVector, error, realProviderName, |
|
_Generic_Create_AssociationMI, _Create_AssociationMI); |
|
} |
if (miVector.miTypes & CMPI_MIType_Method) | if (miVector.miTypes & CMPI_MIType_Method) |
if (miVector.methMI == NULL || rc.rc != CMPI_RC_OK) |
{ |
setError(miVector, error, realProviderName, _Generic_Create_MethodMI, _Create_MethodMI); |
if (miVector.methMI == NULL || rcMeth.rc != CMPI_RC_OK) |
|
setError(miVector, error, realProviderName, |
|
_Generic_Create_MethodMI, _Create_MethodMI); |
|
} |
if (miVector.miTypes & CMPI_MIType_Property) | if (miVector.miTypes & CMPI_MIType_Property) |
if (miVector.propMI == NULL || rc.rc != CMPI_RC_OK) |
{ |
setError(miVector, error, realProviderName, _Generic_Create_PropertyMI, _Create_PropertyMI); |
if (miVector.propMI == NULL || rcProp.rc != CMPI_RC_OK) |
|
setError(miVector, error, realProviderName, |
|
_Generic_Create_PropertyMI, _Create_PropertyMI); |
|
} |
if (miVector.miTypes & CMPI_MIType_Indication) | if (miVector.miTypes & CMPI_MIType_Indication) |
if (miVector.indMI == NULL || rc.rc != CMPI_RC_OK) |
{ |
setError(miVector, error, realProviderName, _Generic_Create_IndicationMI, _Create_IndicationMI); |
if (miVector.indMI == NULL || rcInd.rc != CMPI_RC_OK) |
|
setError(miVector, error, realProviderName, |
|
_Generic_Create_IndicationMI, _Create_IndicationMI); |
|
} |
| |
if (error.size() != 0) | if (error.size() != 0) |
{ | { |
delete (CIMOMHandle*)broker.hdl; |
throw Exception(MessageLoaderParms( |
broker.hdl =0; |
"ProviderManager.CMPI.CMPIProvider.CANNOT_INIT_API", |
throw Exception(MessageLoaderParms("ProviderManager.CMPI.CMPIProvider.CANNOT_INIT_API", |
|
"ProviderInitFailure: Error initializing $0 the following API(s): $1", | "ProviderInitFailure: Error initializing $0 the following API(s): $1", |
realProviderName, | realProviderName, |
error.subString(0, error.size()-2))); |
error)); |
} | } |
} | } |
| |
|
|
else | else |
compoundName=_location+":"+providername; | compoundName=_location+":"+providername; |
try { | try { |
// yield before a potentially lengthy operation. |
|
Threads::yield(); |
|
CMPIProvider::initialize(cimom,miVector,compoundName,broker); | CMPIProvider::initialize(cimom,miVector,compoundName,broker); |
if (miVector.miTypes & CMPI_MIType_Method) { | if (miVector.miTypes & CMPI_MIType_Method) { |
if (miVector.methMI->ft->miName==NULL) noUnload=true; |
if (miVector.methMI->ft->miName==NULL) |
|
{ |
|
unloadStatus = CMPI_RC_OK; |
|
} |
} | } |
} | } |
catch(...) { | catch(...) { |
|
|
| |
Status savedStatus=_status; | Status savedStatus=_status; |
| |
// yield before a potentially lengthy operation. |
|
Threads::yield(); |
|
try | try |
{ | { |
if (noUnload==false) { |
if (unloadStatus != CMPI_RC_OK) { |
// False means that the CIMServer is not shutting down. | // False means that the CIMServer is not shutting down. |
_terminate(false); | _terminate(false); |
if (noUnload==true) { |
if (unloadStatus != CMPI_RC_OK) { |
_status=savedStatus; | _status=savedStatus; |
return false; | return false; |
} | } |
|
|
CMPI_RC_DO_NOT_UNLOAD Operation successful - do not unload now. | CMPI_RC_DO_NOT_UNLOAD Operation successful - do not unload now. |
CMPI_RC_NEVER_UNLOAD Operation successful - never unload. | CMPI_RC_NEVER_UNLOAD Operation successful - never unload. |
*/ | */ |
|
unloadStatus = CMPI_RC_OK; |
if (miVector.miTypes & CMPI_MIType_Instance) { | if (miVector.miTypes & CMPI_MIType_Instance) { |
rc=miVector.instMI->ft->cleanup(miVector.instMI,&eCtx, terminating); | rc=miVector.instMI->ft->cleanup(miVector.instMI,&eCtx, terminating); |
if (rc.rc==CMPI_RC_ERR_NOT_SUPPORTED) noUnload=true; |
unloadStatus = rc.rc; |
if ((rc.rc == CMPI_RC_DO_NOT_UNLOAD) || (rc.rc==CMPI_RC_NEVER_UNLOAD)) noUnload =true; |
|
} | } |
if (miVector.miTypes & CMPI_MIType_Association) { | if (miVector.miTypes & CMPI_MIType_Association) { |
rc=miVector.assocMI->ft->cleanup(miVector.assocMI,&eCtx, terminating); | rc=miVector.assocMI->ft->cleanup(miVector.assocMI,&eCtx, terminating); |
if (rc.rc==CMPI_RC_ERR_NOT_SUPPORTED) noUnload=true; |
if (unloadStatus == CMPI_RC_OK) |
if ((rc.rc == CMPI_RC_DO_NOT_UNLOAD) || (rc.rc==CMPI_RC_NEVER_UNLOAD)) noUnload =true; |
{ |
|
unloadStatus = rc.rc; |
|
} |
} | } |
if (miVector.miTypes & CMPI_MIType_Method) { | if (miVector.miTypes & CMPI_MIType_Method) { |
rc=miVector.methMI->ft->cleanup(miVector.methMI,&eCtx, terminating); | rc=miVector.methMI->ft->cleanup(miVector.methMI,&eCtx, terminating); |
if (rc.rc==CMPI_RC_ERR_NOT_SUPPORTED) noUnload=true; |
if (unloadStatus == CMPI_RC_OK) |
if ((rc.rc == CMPI_RC_DO_NOT_UNLOAD) || (rc.rc==CMPI_RC_NEVER_UNLOAD)) noUnload =true; |
{ |
|
unloadStatus = rc.rc; |
|
} |
} | } |
if (miVector.miTypes & CMPI_MIType_Property) { | if (miVector.miTypes & CMPI_MIType_Property) { |
rc=miVector.propMI->ft->cleanup(miVector.propMI,&eCtx, terminating); | rc=miVector.propMI->ft->cleanup(miVector.propMI,&eCtx, terminating); |
if (rc.rc==CMPI_RC_ERR_NOT_SUPPORTED) noUnload=true; |
if (unloadStatus == CMPI_RC_OK) |
if ((rc.rc == CMPI_RC_DO_NOT_UNLOAD) || (rc.rc==CMPI_RC_NEVER_UNLOAD)) noUnload =true; |
{ |
|
unloadStatus = rc.rc; |
|
} |
} | } |
if (miVector.miTypes & CMPI_MIType_Indication) { | if (miVector.miTypes & CMPI_MIType_Indication) { |
rc=miVector.indMI->ft->cleanup(miVector.indMI,&eCtx, terminating); | rc=miVector.indMI->ft->cleanup(miVector.indMI,&eCtx, terminating); |
if (rc.rc==CMPI_RC_ERR_NOT_SUPPORTED) noUnload=true; |
if (unloadStatus == CMPI_RC_OK) |
if ((rc.rc == CMPI_RC_DO_NOT_UNLOAD) || (rc.rc==CMPI_RC_NEVER_UNLOAD)) noUnload =true; |
|
} |
|
|
|
if (noUnload == false) |
|
{ |
|
// Cleanup the class cache |
|
{ | { |
WriteLock writeLock (broker.rwsemClassCache); |
unloadStatus = rc.rc; |
|
|
if (broker.clsCache) { |
|
ClassCache::Iterator i=broker.clsCache->start(); |
|
for (; i; i++) { |
|
delete i.value(); |
|
} |
|
delete broker.clsCache; |
|
broker.clsCache=NULL; |
|
} | } |
} | } |
| |
|
if (unloadStatus == CMPI_RC_OK || terminating) |
|
{ |
|
|
// Check the thread list to make sure the thread has been de-allocated | // Check the thread list to make sure the thread has been de-allocated |
if (_threadWatchList.size() != 0) | if (_threadWatchList.size() != 0) |
{ | { |
Tracer::trace(TRC_PROVIDERMANAGER, Tracer::LEVEL2, |
PEG_TRACE((TRC_PROVIDERMANAGER, Tracer::LEVEL2, |
"There are %d provider threads in %s that have to be cleaned up.", | "There are %d provider threads in %s that have to be cleaned up.", |
_threadWatchList.size(), (const char *)getName().getCString()); |
_threadWatchList.size(), (const char *)getName().getCString())); |
| |
// Walk through the list and terminate the threads. After they are | // Walk through the list and terminate the threads. After they are |
// terminated, put them back on the watch list, call the cleanup function | // terminated, put them back on the watch list, call the cleanup function |
|
|
Status savedStatus=_status; | Status savedStatus=_status; |
if(_status == INITIALIZED) | if(_status == INITIALIZED) |
{ | { |
// yield before a potentially lengthy operation. |
|
Threads::yield(); |
|
try | try |
{ | { |
| |
_terminate(true); | _terminate(true); |
if (noUnload==true) { |
if (unloadStatus == CMPI_RC_OK) |
|
{ |
_status=savedStatus; | _status=savedStatus; |
return; | return; |
} | } |
|
|
Time::gettimeofday(&_idleTime); | Time::gettimeofday(&_idleTime); |
} | } |
| |
|
/* |
|
* This method returns "false" if there are any requests pending with |
|
* the provider or Provider has returned CMPI_RC_NEVER_UNLOAD in the last |
|
* cleanup() invocation cyle. |
|
*/ |
Boolean CMPIProvider::unload_ok(void) | Boolean CMPIProvider::unload_ok(void) |
{ | { |
if (noUnload==true) return false; |
if (unloadStatus == CMPI_RC_NEVER_UNLOAD) |
|
{ |
|
return false; |
|
} |
if(_no_unload.get() ) | if(_no_unload.get() ) |
return false; | return false; |
| |