📄 cmpilocalprovidermanager.cpp
字号:
{ continue; } provider->_quantum = quantum; if (provider->_current_operations.get ()) { PEG_TRACE_STRING (TRC_PROVIDERMANAGER, Tracer::LEVEL4, "CMPIProvider has pending operations: " + provider->getName ()); continue; } PEG_TRACE_STRING (TRC_PROVIDERMANAGER, Tracer::LEVEL4, "Checking timeout data for CMPIProvider: " + provider->getName ()); struct timeval timeout = { 0, 0 }; provider->get_idle_timer (&timeout); PEG_TRACE_STRING (TRC_PROVIDERMANAGER, Tracer::LEVEL4, " provider->unload_ok() returns: " + provider->unload_ok ()? "true" : "false"); if (provider->unload_ok () == true && (now.tv_sec - timeout.tv_sec) > ((Sint32) myself->_idle_timeout)) { // Remember this provider to be unloaded unloadProviderArray[upaIndex] = provider; upaIndex++; } //else cout<<"--- NOT unloaded: "+ provider->getName()<<endl; } // Now finally we unload all providers that we identified as // candidates above. for (Uint32 index = 0; index < upaIndex; index++) { PEG_TRACE_STRING (TRC_PROVIDERMANAGER, Tracer::LEVEL4, "Now trying to unload CMPIProvider " + provider->getName ()); CMPIProvider *provider = unloadProviderArray[index]; { // lock the provider mutex AutoMutex pr_lock (provider->_statusMutex); if (provider->tryTerminate () == false) { // provider not unloaded -- we are respecting this! PEG_TRACE_STRING (TRC_PROVIDERMANAGER, Tracer::LEVEL4, "Provider refused to unload: " + unloadProviderArray[index]->getName()); continue; } PEGASUS_ASSERT (provider->_module != 0); // unload provider module provider->_module->unloadModule (); Logger::put (Logger::STANDARD_LOG, System::CIMSERVER, Logger::TRACE, "CMPILocalProviderManager::_provider_crtl - Unload provider $0", provider->getName ()); // Note: The deleting of the cimom handle is being // moved after the call to unloadModule() based on // a previous fix for bug 3669 and consistency with // other provider managers. Do not move it back before // the call to unloadModule(). PEG_TRACE_STRING (TRC_PROVIDERMANAGER, Tracer::LEVEL4, "Destroying CMPIProvider's CIMOM Handle " + provider->getName()); delete provider->_cimom_handle; // set provider status to UNINITIALIZED provider->reset (); } } } catch (...) { PEG_TRACE_STRING (TRC_PROVIDERMANAGER, Tracer::LEVEL4, "Unexpected Exception in UNLOAD_IDLE_PROVIDERS."); } delete [] unloadProviderArray; } // if there are any providers break; } default: ccode = -1; break; } PEG_METHOD_EXIT (); return (ccode);}/* * The reaper function polls out the threads from the global list (_finishedThreadList), * joins them deletes them, and removes them from the CMPIProvider specific list. */ThreadReturnType PEGASUS_THREAD_CDECL CMPILocalProviderManager::_reaper(void *parm){ Thread *myself = reinterpret_cast<Thread *>(parm); do { _pollingSem.wait(); // All of the threads are finished working. We just need to reap 'em cleanupThreadRecord *rec = 0; while (_finishedThreadList.size() >0 ) { // Pull of the the threads from the global list. rec = _finishedThreadList.remove_front(); DDD(cerr << "Reaping the thread " << rec->thread << " from " << rec->provider->getName() << endl); rec->thread->join(); // Remove the thread for the CMPIProvider. rec->provider->threadDelete(rec->thread); // Delete the thread. delete rec->thread; delete rec; } } while (_stopPolling.get() == 0); myself->exit_self( (ThreadReturnType) 0); return (0);} /* // Cleanup the thread and upon deletion of it, call the CMPIProvider' "threadDeleted". // to not, all the CMPIProvider ' // Note that this function is called from the thread that finished with // running the providers function, and returns immediately while scheduling the // a cleanup procedure. If you want to wait until the thread is truly deleted, // call 'waitUntilThreadsDone' - but DO NOT do it in the the thread that // the Thread owns - you will wait forever. // // @argument t Thread that is not NULL and finished with running the provider function. // @argument p CMPIProvider in which the 't' Thread was running. */void CMPILocalProviderManager::cleanupThread(Thread *t, CMPIProvider *p){ PEGASUS_ASSERT( t != 0 && p != 0 ); PEGASUS_ASSERT ( p->isThreadOwner(t) ); // The mutex guards against a race condition for _reaperThread creation. AutoMutex lock(_reaperMutex); // Put the Thread and the CMPIProvider on the global list. cleanupThreadRecord *record = new cleanupThreadRecord(t, p); _finishedThreadList.insert_back(record); if (_reaperThread == 0) { _reaperThread = new Thread(_reaper, NULL, false); ThreadStatus rtn = PEGASUS_THREAD_OK; while ( (rtn = _reaperThread->run()) != PEGASUS_THREAD_OK) { if (rtn == PEGASUS_THREAD_INSUFFICIENT_RESOURCES) Threads::yield(); else { PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL2, \ "Could not allocate thread to take care of deleting user threads. "); delete _reaperThread; _reaperThread = 0; return; } } }/* Tracer::trace(TRC_PROVIDERMANAGER, Tracer::LEVEL2, \ "Cleaning up provider thread (%p) from provider %s.", t, (const char *)p->getName().getCString());*/ // Wake up the reaper. _pollingSem.signal();}CMPIProvider::OpProviderHolder CMPILocalProviderManager::getRemoteProvider (const String & location, const String & providerName){ CMPIProvider::OpProviderHolder ph; CTRL_STRINGS strings; Sint32 ccode; const String proxy ("CMPIRProxyProvider"); String rproviderName ("R"); PEG_METHOD_ENTER (TRC_PROVIDERMANAGER, "ProvidertManager::getRemoteProvider"); rproviderName.append (providerName); strings.fileName = &proxy; strings.providerName = &rproviderName; strings.location = &location; try { ccode = _provider_ctrl (GET_PROVIDER, &strings, &ph); } catch (const Exception & e) { DDD(cerr << "--- loading proxy: " << e.getMessage () << endl); PEG_METHOD_EXIT (); throw; } catch (...) { PEG_METHOD_EXIT (); throw; } CMPIProvider & prov = ph.GetProvider (); PEG_METHOD_EXIT (); return (ph);}CMPIProvider::OpProviderHolder CMPILocalProviderManager::getProvider (const String & fileName, const String & providerName){ CMPIProvider::OpProviderHolder ph; CTRL_STRINGS strings; Sint32 ccode; String lproviderName ("L"); PEG_METHOD_ENTER (TRC_PROVIDERMANAGER, "ProviderManager::getProvider"); if (fileName.size() == 0) { throw Exception(MessageLoaderParms( "ProviderManager.CMPI.CMPILocalProviderManager.CANNOT_FIND_LIBRARY", "For provider $0 the library name was empty. Check provider registered location.", providerName)); } lproviderName.append (providerName); strings.fileName = &fileName; strings.providerName = &lproviderName; strings.location = &String::EMPTY; try { ccode = _provider_ctrl (GET_PROVIDER, &strings, &ph); } catch (const Exception & e) { DDD(cerr << "--- loading proxy: " << e.getMessage () << endl); PEG_METHOD_EXIT (); throw; } catch (...) { PEG_METHOD_EXIT (); throw; } PEG_METHOD_EXIT (); return (ph);}voidCMPILocalProviderManager::unloadProvider (const String & fileName, const String & providerName){ CTRL_STRINGS strings; PEG_METHOD_ENTER (TRC_PROVIDERMANAGER, "ProviderManager::unloadProvider"); String lproviderName ("L"); String rproviderName ("R"); lproviderName.append (providerName); rproviderName.append (providerName); strings.fileName = &fileName; strings.providerName = &lproviderName; strings.location = &String::EMPTY; _provider_ctrl (UNLOAD_PROVIDER, &strings, (void *) 0); strings.providerName = &rproviderName; _provider_ctrl (UNLOAD_PROVIDER, &strings, (void *) 0); PEG_METHOD_EXIT ();}voidCMPILocalProviderManager::shutdownAllProviders (void){ PEG_METHOD_ENTER (TRC_PROVIDERMANAGER, "ProviderManager::shutdownAllProviders"); _provider_ctrl (UNLOAD_ALL_PROVIDERS, (void *) this, (void *) 0); PEG_METHOD_EXIT ();}BooleanCMPILocalProviderManager::hasActiveProviders (){ PEG_METHOD_ENTER (TRC_PROVIDERMANAGER, "ProviderManager::hasActiveProviders"); try { AutoMutex lock (_providerTableMutex); Tracer::trace (TRC_PROVIDERMANAGER, Tracer::LEVEL4, "providers in _providers table = %d", _providers.size ()); // Iterate through the _providers table looking for an active provider for (ProviderTable::Iterator i = _providers.start (); i != 0; i++) { if (i.value ()->getStatus () == CMPIProvider::INITIALIZED) { PEG_METHOD_EXIT (); return true; } } } catch (...)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -