version 1.90, 2008/12/02 09:01:57
|
version 1.96, 2014/08/27 23:10:11
|
|
|
| |
PEGASUS_NAMESPACE_BEGIN | PEGASUS_NAMESPACE_BEGIN |
| |
|
|
|
// A request class to hold the provider info passed to the |
|
// AsyncRequestExecutor for processing on different threads. |
|
class UnloadProviderRequest : public AsyncRequestExecutor::AsyncRequestMsg |
|
{ |
|
public: |
|
UnloadProviderRequest(ProviderMessageHandler* provider) |
|
:_provider(provider) {} |
|
|
|
public: |
|
ProviderMessageHandler* _provider; |
|
}; |
|
|
// | // |
// Default Provider Manager | // Default Provider Manager |
// | // |
|
|
response = _handleSubscriptionInitCompleteRequest(request); | response = _handleSubscriptionInitCompleteRequest(request); |
break; | break; |
| |
|
case CIM_INDICATION_SERVICE_DISABLED_REQUEST_MESSAGE: |
|
response = _handleIndicationServiceDisabledRequest(request); |
|
break; |
|
|
default: | default: |
PEGASUS_ASSERT(0); |
PEGASUS_UNREACHABLE(PEGASUS_ASSERT(0);) |
break; | break; |
} | } |
} | } |
|
|
return response; | return response; |
} | } |
| |
|
|
|
CIMResponseMessage* |
|
DefaultProviderManager::_handleIndicationServiceDisabledRequest( |
|
CIMRequestMessage* message) |
|
{ |
|
PEG_METHOD_ENTER(TRC_PROVIDERMANAGER, |
|
"DefaultProviderManager::_handleIndicationServiceDisabledRequest"); |
|
|
|
CIMIndicationServiceDisabledRequestMessage* request = |
|
dynamic_cast<CIMIndicationServiceDisabledRequestMessage*>(message); |
|
PEGASUS_ASSERT(request != 0); |
|
|
|
CIMIndicationServiceDisabledResponseMessage* response = |
|
dynamic_cast<CIMIndicationServiceDisabledResponseMessage*>( |
|
request->buildResponse()); |
|
PEGASUS_ASSERT(response != 0); |
|
|
|
_subscriptionInitComplete = false; |
|
|
|
// Make a copy of the table so it is not locked during the provider calls |
|
Array<ProviderMessageHandler*> providerList; |
|
{ |
|
AutoMutex lock(_providerTableMutex); |
|
|
|
for (ProviderTable::Iterator i = _providers.start(); i != 0; i++) |
|
{ |
|
providerList.append(i.value()); |
|
} |
|
} |
|
|
|
// |
|
// Notify all providers that indication service is disabled |
|
// |
|
for (Uint32 j = 0; j < providerList.size(); j++) |
|
{ |
|
AutoMutex lock(providerList[j]->status.getStatusMutex()); |
|
|
|
if (providerList[j]->status.isInitialized()) |
|
{ |
|
providerList[j]->indicationServiceDisabled(); |
|
} |
|
} |
|
|
|
PEG_METHOD_EXIT(); |
|
return response; |
|
} |
|
|
CIMResponseMessage* | CIMResponseMessage* |
DefaultProviderManager::_handleSubscriptionInitCompleteRequest( | DefaultProviderManager::_handleSubscriptionInitCompleteRequest( |
CIMRequestMessage* message) | CIMRequestMessage* message) |
|
|
} | } |
catch (...) | catch (...) |
{ | { |
|
PEG_TRACE((TRC_PROVIDERMANAGER, Tracer::LEVEL3, |
|
"Initialization Error. Provider %s", |
|
(const char*)provider->getName().getCString())); |
initializeError = true; | initializeError = true; |
} | } |
| |
|
|
PEG_METHOD_ENTER(TRC_PROVIDERMANAGER, | PEG_METHOD_ENTER(TRC_PROVIDERMANAGER, |
"DefaultProviderManager::_shutdownAllProviders"); | "DefaultProviderManager::_shutdownAllProviders"); |
| |
try |
|
{ |
|
AutoMutex lock(_providerTableMutex); | AutoMutex lock(_providerTableMutex); |
|
|
PEG_TRACE((TRC_PROVIDERMANAGER, Tracer::LEVEL4, | PEG_TRACE((TRC_PROVIDERMANAGER, Tracer::LEVEL4, |
"providers in cache = %d", _providers.size())); | "providers in cache = %d", _providers.size())); |
| |
|
//create an array of UnloadProviderRequest requests one per |
|
//provider to process shutdown of providers simultaneously. |
|
Array<AsyncRequestExecutor::AsyncRequestMsg*> ProviderRequests; |
for (ProviderTable::Iterator i = _providers.start(); i != 0; i++) | for (ProviderTable::Iterator i = _providers.start(); i != 0; i++) |
{ | { |
ProviderMessageHandler* provider = i.value(); |
AutoMutex lock(i.value()->status.getStatusMutex()); |
PEGASUS_ASSERT(provider != 0); |
if(i.value()->status.isInitialized()) |
|
|
AutoMutex lock2(provider->status.getStatusMutex()); |
|
|
|
if (provider->status.isInitialized()) |
|
{ | { |
_unloadProvider(provider); |
ProviderRequests.append( |
|
new UnloadProviderRequest(i.value())); |
} | } |
} | } |
} |
|
catch (...) |
//run the stop request on all providers on multiple threads using |
|
//the request executor. This will invoke _asyncRequestCallback() on a |
|
//seperate thread for each provider which in turn will unload that |
|
//provider. |
|
|
|
CIMException exception = |
|
AsyncRequestExecutor(&_asyncRequestCallback,this).executeRequests( |
|
ProviderRequests); |
|
|
|
if(exception.getCode() != CIM_ERR_SUCCESS) |
{ | { |
PEG_TRACE_CSTRING(TRC_PROVIDERMANAGER, Tracer::LEVEL2, | PEG_TRACE_CSTRING(TRC_PROVIDERMANAGER, Tracer::LEVEL2, |
"Unexpected Exception in _shutdownAllProviders()."); | "Unexpected Exception in _shutdownAllProviders()."); |
|
|
return new DefaultProviderManager(); | return new DefaultProviderManager(); |
} | } |
| |
|
//async request handler method invoked on a seperate thread per provider |
|
//through the async request executor. |
|
CIMException DefaultProviderManager::_asyncRequestCallback( |
|
void *callbackPtr, |
|
AsyncRequestExecutor::AsyncRequestMsg* request) |
|
{ |
|
PEG_METHOD_ENTER(TRC_PROVIDERMANAGER, |
|
"DefaultProviderManager::_asyncRequestCallback"); |
|
|
|
CIMException responseException; |
|
|
|
//extract the parameters |
|
UnloadProviderRequest* my_request = |
|
dynamic_cast<UnloadProviderRequest*>(request); |
|
if(my_request != NULL) |
|
{ |
|
PEGASUS_ASSERT(0 != callbackPtr); |
|
|
|
DefaultProviderManager *dpmPtr = |
|
static_cast<DefaultProviderManager*>(callbackPtr); |
|
|
|
ProviderMessageHandler* provider = |
|
dynamic_cast<ProviderMessageHandler*>(my_request->_provider); |
|
try |
|
{ |
|
AutoMutex lock(provider->status.getStatusMutex()); |
|
//unload the provider |
|
if (provider->status.isInitialized()) |
|
{ |
|
dpmPtr->_unloadProvider(provider); |
|
} |
|
else |
|
{ |
|
PEGASUS_ASSERT(0); |
|
} |
|
} |
|
catch (CIMException& e) |
|
{ |
|
PEG_TRACE((TRC_PROVIDERMANAGER, Tracer::LEVEL1,"CIMException: %s", |
|
(const char*)e.getMessage().getCString())); |
|
responseException = e; |
|
} |
|
catch (Exception& e) |
|
{ |
|
PEG_TRACE((TRC_PROVIDERMANAGER, Tracer::LEVEL1,"Exception: %s", |
|
(const char*)e.getMessage().getCString())); |
|
responseException = CIMException(CIM_ERR_FAILED, e.getMessage()); |
|
} |
|
catch (PEGASUS_STD(exception)& e) |
|
{ |
|
responseException = CIMException(CIM_ERR_FAILED, e.what()); |
|
} |
|
catch (...) |
|
{ |
|
PEG_TRACE_CSTRING(TRC_PROVIDERMANAGER, Tracer::LEVEL1, |
|
"Exception: Unknown"); |
|
responseException = PEGASUS_CIM_EXCEPTION( |
|
CIM_ERR_FAILED, "Unknown error."); |
|
} |
|
} |
|
|
|
// delete the UnloadProviderRequest. |
|
delete request; |
|
|
|
PEG_METHOD_EXIT(); |
|
return responseException; |
|
} |
|
|
PEGASUS_NAMESPACE_END | PEGASUS_NAMESPACE_END |
| |
PEGASUS_USING_PEGASUS; | PEGASUS_USING_PEGASUS; |