version 1.19, 2005/06/24 19:34:26
|
version 1.21, 2005/11/18 18:38:35
|
|
|
PEG_METHOD_ENTER(TRC_PROVIDERMANAGER, | PEG_METHOD_ENTER(TRC_PROVIDERMANAGER, |
"ProviderAgentContainer::_startAgentProcess"); | "ProviderAgentContainer::_startAgentProcess"); |
| |
|
// |
|
// Serialize the starting of agent processes. If two agent processes are |
|
// started at the same time, they may get copies of each other's pipe |
|
// descriptors. If this happens, the cimserver will not get a pipe read |
|
// error when one of the agent processes exits, because the pipe will |
|
// still be writable by the other process. This locking control needs to |
|
// cover the period from where the pipes are created to where the agent |
|
// ends of the pipes are closed by the cimserver. |
|
// |
|
static Mutex agentStartupMutex; |
|
AutoMutex lock(agentStartupMutex); |
|
|
AutoPtr<AnonymousPipe> pipeFromAgent(new AnonymousPipe()); | AutoPtr<AnonymousPipe> pipeFromAgent(new AnonymousPipe()); |
AutoPtr<AnonymousPipe> pipeToAgent(new AnonymousPipe()); | AutoPtr<AnonymousPipe> pipeToAgent(new AnonymousPipe()); |
| |
|
|
| |
// Start a thread to read and process responses from the Provider Agent | // Start a thread to read and process responses from the Provider Agent |
ThreadStatus rtn = PEGASUS_THREAD_OK; | ThreadStatus rtn = PEGASUS_THREAD_OK; |
while ( ( rtn = MessageQueueService::get_thread_pool()->allocate_and_awaken( |
while ((rtn = MessageQueueService::get_thread_pool()-> |
this, _responseProcessor)) != PEGASUS_THREAD_OK) |
allocate_and_awaken(this, _responseProcessor)) != |
|
PEGASUS_THREAD_OK) |
{ | { |
if (rtn == PEGASUS_THREAD_INSUFFICIENT_RESOURCES) | if (rtn == PEGASUS_THREAD_INSUFFICIENT_RESOURCES) |
|
{ |
pegasus_yield(); | pegasus_yield(); |
|
} |
else | else |
{ | { |
Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::TRACE, |
Logger::put( |
"Not enough threads to process responses from the provider agent."); |
Logger::STANDARD_LOG, System::CIMSERVER, Logger::TRACE, |
|
"Not enough threads to process responses from the " |
|
"provider agent."); |
| |
Tracer::trace(TRC_PROVIDERMANAGER, Tracer::LEVEL2, | Tracer::trace(TRC_PROVIDERMANAGER, Tracer::LEVEL2, |
"Could not allocate thread to process responses from the provider agent."); |
"Could not allocate thread to process responses from the " |
break; |
"provider agent."); |
|
|
|
throw Exception(MessageLoaderParms( |
|
"ProviderManager.OOPProviderManagerRouter." |
|
"CIMPROVAGT_THREAD_ALLOCATION_FAILED", |
|
"Failed to allocate thread for cimprovagt \"$0\".", |
|
_moduleName)); |
} | } |
} | } |
} | } |
catch (...) | catch (...) |
{ | { |
|
// Closing the connection causes the agent process to exit |
|
_pipeToAgent.reset(); |
|
_pipeFromAgent.reset(); |
|
|
#if defined(PEGASUS_HAS_SIGNALS) | #if defined(PEGASUS_HAS_SIGNALS) |
if (_isInitialized) | if (_isInitialized) |
{ | { |
|
|
#endif | #endif |
| |
_isInitialized = false; | _isInitialized = false; |
_pipeToAgent.reset(); |
|
_pipeFromAgent.reset(); |
|
| |
{ | { |
AutoMutex lock(_numProviderProcessesMutex); | AutoMutex lock(_numProviderProcessesMutex); |