version 1.47, 2007/06/15 17:35:48
|
version 1.48, 2007/07/25 07:16:01
|
|
|
Semaphore CMPILocalProviderManager::_pollingSem(0); | Semaphore CMPILocalProviderManager::_pollingSem(0); |
AtomicInt CMPILocalProviderManager::_stopPolling(0); | AtomicInt CMPILocalProviderManager::_stopPolling(0); |
Thread *CMPILocalProviderManager::_reaperThread = 0; | Thread *CMPILocalProviderManager::_reaperThread = 0; |
List<CMPILocalProviderManager::cleanupThreadRecord,Mutex> CMPILocalProviderManager::_finishedThreadList; |
List<CMPILocalProviderManager::cleanupThreadRecord,Mutex> |
|
CMPILocalProviderManager::_finishedThreadList; |
Mutex CMPILocalProviderManager::_reaperMutex; | Mutex CMPILocalProviderManager::_reaperMutex; |
| |
CMPILocalProviderManager::CMPILocalProviderManager (void): |
CMPILocalProviderManager::CMPILocalProviderManager (): |
_idle_timeout (IDLE_LIMIT) | _idle_timeout (IDLE_LIMIT) |
{ | { |
} | } |
| |
CMPILocalProviderManager::~CMPILocalProviderManager (void) |
CMPILocalProviderManager::~CMPILocalProviderManager () |
{ | { |
Uint32 ccode; | Uint32 ccode; |
| |
|
|
| |
} | } |
| |
Sint32 |
Sint32 CMPILocalProviderManager::_provider_ctrl ( |
CMPILocalProviderManager::_provider_ctrl (CTRL code, void *parm, void *ret) |
CTRL code, |
|
void *parm, |
|
void *ret) |
{ | { |
| |
static Uint32 quantum; | static Uint32 quantum; |
|
|
| |
switch (code) | switch (code) |
{ | { |
|
|
case GET_PROVIDER: | case GET_PROVIDER: |
{ | { |
|
|
PEG_TRACE_CSTRING (TRC_PROVIDERMANAGER, Tracer::LEVEL2, | PEG_TRACE_CSTRING (TRC_PROVIDERMANAGER, Tracer::LEVEL2, |
"_provider_ctrl::GET_PROVIDER"); | "_provider_ctrl::GET_PROVIDER"); |
| |
|
|
delete pr; | delete pr; |
| |
} | } |
else { |
else |
|
{ |
// No need to have a memory leak. | // No need to have a memory leak. |
_providers.remove(pr->_name); | _providers.remove(pr->_name); |
delete pr; | delete pr; |
|
|
| |
provider = i.value (); | provider = i.value (); |
PEGASUS_ASSERT (provider != 0); | PEGASUS_ASSERT (provider != 0); |
if (provider->getStatus () == CMPIProvider::UNINITIALIZED) |
if (provider->getStatus () == |
|
CMPIProvider::UNINITIALIZED) |
{ | { |
// Delete the skeleton. | // Delete the skeleton. |
delete provider; | delete provider; |
|
|
provider = i.value (); | provider = i.value (); |
PEGASUS_ASSERT (provider != 0); | PEGASUS_ASSERT (provider != 0); |
| |
if (provider->getStatus () == CMPIProvider::UNINITIALIZED) |
if (provider->getStatus () == |
|
CMPIProvider::UNINITIALIZED) |
{ | { |
continue; | continue; |
} | } |
|
|
| |
if (provider->_current_operations.get ()) | if (provider->_current_operations.get ()) |
{ | { |
PEG_TRACE_STRING (TRC_PROVIDERMANAGER, Tracer::LEVEL4, |
PEG_TRACE_STRING (TRC_PROVIDERMANAGER, |
|
Tracer::LEVEL4, |
"CMPIProvider has pending operations: " | "CMPIProvider has pending operations: " |
+ provider->getName ()); | + provider->getName ()); |
| |
continue; | continue; |
} | } |
| |
PEG_TRACE_STRING (TRC_PROVIDERMANAGER, Tracer::LEVEL4, |
PEG_TRACE_STRING (TRC_PROVIDERMANAGER, |
|
Tracer::LEVEL4, |
"Checking timeout data for CMPIProvider: " | "Checking timeout data for CMPIProvider: " |
+ provider->getName ()); | + provider->getName ()); |
struct timeval timeout = { 0, 0 }; | struct timeval timeout = { 0, 0 }; |
provider->get_idle_timer (&timeout); | provider->get_idle_timer (&timeout); |
| |
PEG_TRACE_CSTRING(TRC_PROVIDERMANAGER, Tracer::LEVEL4, |
PEG_TRACE_CSTRING(TRC_PROVIDERMANAGER, |
|
Tracer::LEVEL4, |
provider->unload_ok ()? | provider->unload_ok ()? |
" provider->unload_ok() returns: true" : | " provider->unload_ok() returns: true" : |
" provider->unload_ok() returns: false"); | " provider->unload_ok() returns: false"); |
|
|
unloadProviderArray[upaIndex] = provider; | unloadProviderArray[upaIndex] = provider; |
upaIndex++; | upaIndex++; |
} | } |
//else cout<<"--- NOT unloaded: "+ provider->getName()<<endl; |
//else cout<<"--- NOT unloaded: "+ |
|
// provider->getName()<<endl; |
} | } |
| |
// Now finally we unload all providers that we identified as |
// Now finally we unload all providers that we |
// candidates above. |
// identified as candidates above. |
for (Uint32 index = 0; index < upaIndex; index++) | for (Uint32 index = 0; index < upaIndex; index++) |
{ | { |
CMPIProvider *provider = unloadProviderArray[index]; |
CMPIProvider *provider = |
PEG_TRACE_STRING (TRC_PROVIDERMANAGER, Tracer::LEVEL4, |
unloadProviderArray[index]; |
|
PEG_TRACE_STRING (TRC_PROVIDERMANAGER, |
|
Tracer::LEVEL4, |
"Now trying to unload CMPIProvider " + | "Now trying to unload CMPIProvider " + |
provider->getName ()); | provider->getName ()); |
{ | { |
|
|
| |
if (provider->tryTerminate () == false) | if (provider->tryTerminate () == false) |
{ | { |
// provider not unloaded -- we are respecting this! |
// provider not unloaded -- we are |
PEG_TRACE_STRING (TRC_PROVIDERMANAGER, Tracer::LEVEL4, |
// respecting this! |
|
PEG_TRACE_STRING (TRC_PROVIDERMANAGER, |
|
Tracer::LEVEL4, |
"Provider refused to unload: " + | "Provider refused to unload: " + |
unloadProviderArray[index]->getName()); | unloadProviderArray[index]->getName()); |
continue; | continue; |
|
|
| |
// unload provider module | // unload provider module |
provider->_module->unloadModule (); | provider->_module->unloadModule (); |
Logger::put (Logger::STANDARD_LOG, System::CIMSERVER, |
Logger::put (Logger::STANDARD_LOG, |
|
System::CIMSERVER, |
Logger::TRACE, | Logger::TRACE, |
"CMPILocalProviderManager::_provider_crtl - Unload provider $0", |
"CMPILocalProviderManager::_provider_crtl" |
|
" - Unload provider $0", |
provider->getName ()); | provider->getName ()); |
| |
// Note: The deleting of the cimom handle is being |
// Note: The deleting of the cimom handle is |
// moved after the call to unloadModule() based on |
// being moved after the call to |
// a previous fix for bug 3669 and consistency with |
// unloadModule() based on a previous fix for |
// other provider managers. Do not move it back before |
// bug 3669 and consistency with other |
// the call to unloadModule(). |
// provider managers. Do not move it back |
PEG_TRACE_STRING (TRC_PROVIDERMANAGER, Tracer::LEVEL4, |
// before the call to unloadModule(). |
|
PEG_TRACE_STRING (TRC_PROVIDERMANAGER, |
|
Tracer::LEVEL4, |
"Destroying CMPIProvider's CIMOM Handle " | "Destroying CMPIProvider's CIMOM Handle " |
+ provider->getName()); | + provider->getName()); |
delete provider->_cimom_handle; | delete provider->_cimom_handle; |
|
|
| |
| |
/* | /* |
* The reaper function polls out the threads from the global list (_finishedThreadList), |
* The reaper function polls out the threads from the global list |
* joins them deletes them, and removes them from the CMPIProvider specific list. |
* (_finishedThreadList), joins them deletes them, and removes them from the |
|
* CMPIProvider specific list. |
*/ | */ |
ThreadReturnType PEGASUS_THREAD_CDECL CMPILocalProviderManager::_reaper(void *parm) |
ThreadReturnType PEGASUS_THREAD_CDECL CMPILocalProviderManager::_reaper( |
|
void *parm) |
{ | { |
Thread *myself = reinterpret_cast<Thread *>(parm); | Thread *myself = reinterpret_cast<Thread *>(parm); |
do { |
do |
|
{ |
_pollingSem.wait(); | _pollingSem.wait(); |
// All of the threads are finished working. We just need to reap 'em | // All of the threads are finished working. We just need to reap 'em |
cleanupThreadRecord *rec = 0; | cleanupThreadRecord *rec = 0; |
|
|
{ | { |
// Pull of the the threads from the global list. | // Pull of the the threads from the global list. |
rec = _finishedThreadList.remove_front(); | rec = _finishedThreadList.remove_front(); |
DDD(cerr << "Reaping the thread " << rec->thread << " from " << rec->provider->getName() << endl); |
DDD(cerr << "Reaping the thread " << rec->thread << " from " |
|
<< rec->provider->getName() << endl); |
rec->thread->join(); | rec->thread->join(); |
| |
// Remove the thread for the CMPIProvider. | // Remove the thread for the CMPIProvider. |
|
|
return (0); | return (0); |
} | } |
/* | /* |
// Cleanup the thread and upon deletion of it, call the CMPIProvider' "threadDeleted". |
// Cleanup the thread and upon deletion of it, call the CMPIProvider' |
// to not, all the CMPIProvider ' |
// "threadDeleted". to not, all the CMPIProvider ' |
// Note that this function is called from the thread that finished with | // Note that this function is called from the thread that finished with |
// running the providers function, and returns immediately while scheduling the |
// running the providers function, and returns immediately while scheduling |
// a cleanup procedure. If you want to wait until the thread is truly deleted, |
// the a cleanup procedure. If you want to wait until the thread is truly |
// call 'waitUntilThreadsDone' - but DO NOT do it in the the thread that |
// deleted, call 'waitUntilThreadsDone' - but DO NOT do it in the the thread |
// the Thread owns - you will wait forever. |
// that the Thread owns - you will wait forever. |
// | // |
// @argument t Thread that is not NULL and finished with running the provider function. |
// @argument t Thread that is not NULL and finished with running the provider |
|
// function. |
// @argument p CMPIProvider in which the 't' Thread was running. | // @argument p CMPIProvider in which the 't' Thread was running. |
*/ | */ |
void |
void CMPILocalProviderManager::cleanupThread(Thread *t, CMPIProvider *p) |
CMPILocalProviderManager::cleanupThread(Thread *t, CMPIProvider *p) |
|
{ | { |
PEGASUS_ASSERT( t != 0 && p != 0 ); | PEGASUS_ASSERT( t != 0 && p != 0 ); |
| |
|
|
else | else |
{ | { |
PEG_TRACE_CSTRING(TRC_PROVIDERMANAGER, Tracer::LEVEL2, \ | PEG_TRACE_CSTRING(TRC_PROVIDERMANAGER, Tracer::LEVEL2, \ |
"Could not allocate thread to take care of deleting user threads. "); |
"Could not allocate thread to take care of deleting " |
|
"user threads. "); |
delete _reaperThread; _reaperThread = 0; | delete _reaperThread; _reaperThread = 0; |
return; | return; |
} | } |
|
|
{ | { |
throw Exception(MessageLoaderParms( | throw Exception(MessageLoaderParms( |
"ProviderManager.CMPI.CMPILocalProviderManager.CANNOT_FIND_LIBRARY", | "ProviderManager.CMPI.CMPILocalProviderManager.CANNOT_FIND_LIBRARY", |
"For provider $0 the library name was empty. Check provider registered location.", |
"For provider $0 the library name was empty. Check provider " |
|
"registered location.", |
providerName)); | providerName)); |
| |
} | } |
|
|
PEG_METHOD_EXIT (); | PEG_METHOD_EXIT (); |
} | } |
| |
void |
void CMPILocalProviderManager::shutdownAllProviders () |
CMPILocalProviderManager::shutdownAllProviders (void) |
|
{ | { |
| |
PEG_METHOD_ENTER (TRC_PROVIDERMANAGER, | PEG_METHOD_ENTER (TRC_PROVIDERMANAGER, |
|
|
} | } |
| |
| |
Boolean |
Boolean CMPILocalProviderManager::hasActiveProviders () |
CMPILocalProviderManager::hasActiveProviders () |
|
{ | { |
PEG_METHOD_ENTER (TRC_PROVIDERMANAGER, | PEG_METHOD_ENTER (TRC_PROVIDERMANAGER, |
"ProviderManager::hasActiveProviders"); | "ProviderManager::hasActiveProviders"); |
|
|
return false; | return false; |
} | } |
| |
void |
void CMPILocalProviderManager::unloadIdleProviders () |
CMPILocalProviderManager::unloadIdleProviders (void) |
|
{ | { |
PEG_METHOD_ENTER(TRC_PROVIDERMANAGER, | PEG_METHOD_ENTER(TRC_PROVIDERMANAGER, |
"ProviderManager::unloadIdleProviders"); | "ProviderManager::unloadIdleProviders"); |
|
|
PEG_METHOD_EXIT (); | PEG_METHOD_EXIT (); |
} | } |
| |
Array < |
Array <CMPIProvider *>CMPILocalProviderManager:: |
CMPIProvider * >CMPILocalProviderManager::getIndicationProvidersToEnable () |
getIndicationProvidersToEnable() |
{ | { |
PEG_METHOD_ENTER (TRC_PROVIDERMANAGER, | PEG_METHOD_ENTER (TRC_PROVIDERMANAGER, |
"CMPILocalProviderManager::getIndicationProvidersToEnable"); | "CMPILocalProviderManager::getIndicationProvidersToEnable"); |
|
|
return enableProviders; | return enableProviders; |
} | } |
| |
CMPIProvider * |
CMPIProvider *CMPILocalProviderManager::_initProvider( |
CMPILocalProviderManager::_initProvider (CMPIProvider * provider, |
CMPIProvider * provider, |
const String & moduleFileName) | const String & moduleFileName) |
{ | { |
PEG_METHOD_ENTER (TRC_PROVIDERMANAGER, "_initProvider"); | PEG_METHOD_ENTER (TRC_PROVIDERMANAGER, "_initProvider"); |
|
|
} | } |
| |
| |
void |
void CMPILocalProviderManager::_unloadProvider (CMPIProvider * provider) |
CMPILocalProviderManager::_unloadProvider (CMPIProvider * provider) |
|
{ | { |
// | // |
// NOTE: It is the caller's responsibility to make sure that | // NOTE: It is the caller's responsibility to make sure that |
|
|
PEG_METHOD_EXIT (); | PEG_METHOD_EXIT (); |
} | } |
| |
CMPIProvider * |
CMPIProvider * CMPILocalProviderManager::_lookupProvider( |
CMPILocalProviderManager::_lookupProvider (const String & providerName) |
const String & providerName) |
{ | { |
PEG_METHOD_ENTER (TRC_PROVIDERMANAGER, "_lookupProvider"); | PEG_METHOD_ENTER (TRC_PROVIDERMANAGER, "_lookupProvider"); |
// lock the providerTable mutex | // lock the providerTable mutex |
|
|
} | } |
| |
| |
CMPIProviderModule * |
CMPIProviderModule * CMPILocalProviderManager::_lookupModule( |
CMPILocalProviderManager::_lookupModule (const String & moduleFileName) |
const String & moduleFileName) |
{ | { |
PEG_METHOD_ENTER (TRC_PROVIDERMANAGER, "_lookupModule"); | PEG_METHOD_ENTER (TRC_PROVIDERMANAGER, "_lookupModule"); |
| |
|
|
} | } |
| |
PEGASUS_NAMESPACE_END | PEGASUS_NAMESPACE_END |
|
|