version 1.30, 2005/04/01 17:26:54
|
version 1.31, 2005/04/28 20:41:47
|
|
|
// Modified By: Dan Gorey (djgorey@us.ibm.com) | // Modified By: Dan Gorey (djgorey@us.ibm.com) |
// Amit K Arora, IBM (amita@in.ibm.com) for PEP#183 | // Amit K Arora, IBM (amita@in.ibm.com) for PEP#183 |
// Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com) | // Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com) |
|
// David Dillard, VERITAS Software Corp. |
|
// (david.dillard@veritas.com) |
// | // |
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
| |
|
|
,_listener_sem(NULL) | ,_listener_sem(NULL) |
{ | { |
} | } |
|
|
CIMListenerRep::~CIMListenerRep() | CIMListenerRep::~CIMListenerRep() |
{ | { |
// if port is alive, clean up the port | // if port is alive, clean up the port |
if (_thread_pool != NULL) |
if (_thread_pool != 0) |
{ | { |
// Block incoming export requests and unbind the port | // Block incoming export requests and unbind the port |
_svc->stopClientConnection(); | _svc->stopClientConnection(); |
|
|
_svc->shutdown(); | _svc->shutdown(); |
} | } |
| |
if(_sslContext!=NULL) |
|
delete _sslContext; | delete _sslContext; |
|
|
if(_dispatcher!=NULL) |
|
delete _dispatcher; | delete _dispatcher; |
|
|
if(_thread_pool!=NULL) |
|
delete _thread_pool; | delete _thread_pool; |
|
|
if(_listener_sem!=NULL) |
|
delete _listener_sem; | delete _listener_sem; |
| |
// don't delete _svc, this is deleted by _listener_routine | // don't delete _svc, this is deleted by _listener_routine |
|
|
{ | { |
return _sslContext; | return _sslContext; |
} | } |
|
|
void CIMListenerRep::setSSLContext(SSLContext* sslContext) | void CIMListenerRep::setSSLContext(SSLContext* sslContext) |
{ | { |
if(_sslContext!=NULL) |
|
delete _sslContext; | delete _sslContext; |
|
|
_sslContext = sslContext; | _sslContext = sslContext; |
} | } |
|
|
void CIMListenerRep::start() | void CIMListenerRep::start() |
{ | { |
// spawn a thread to do this | // spawn a thread to do this |
if(_thread_pool==NULL) |
if(_thread_pool==0) |
{ | { |
CIMListenerService* svc = new CIMListenerService(_portNumber,_sslContext); |
AutoPtr<CIMListenerService> svc(new CIMListenerService(_portNumber,_sslContext)); |
try |
|
{ |
|
// Try to initialize the service (bug 1394) |
|
svc->setIndicationDispatcher(_dispatcher); | svc->setIndicationDispatcher(_dispatcher); |
svc->init(); | svc->init(); |
} |
|
catch(...) |
|
{ |
|
// Error. Exit without creating the ThreadPool, so that this listener |
|
// is not 'alive' |
|
delete svc; |
|
throw; |
|
} |
|
| |
struct timeval deallocateWait = {15, 0}; | struct timeval deallocateWait = {15, 0}; |
_thread_pool = new ThreadPool(0, "Listener", 0, 1, deallocateWait); |
AutoPtr<ThreadPool> threadPool(new ThreadPool(0, "Listener", 0, 1, deallocateWait)); |
|
AutoPtr<Semaphore> sem(new Semaphore(0)); |
_listener_sem = new Semaphore(0); |
threadPool->allocate_and_awaken(svc.get(), CIMListenerService::_listener_routine, sem.get()); |
_thread_pool->allocate_and_awaken(svc, |
Logger::put(Logger::STANDARD_LOG,System::CIMLISTENER, Logger::INFORMATION, |
CIMListenerService::_listener_routine, |
|
_listener_sem); |
|
|
|
_svc = svc; |
|
|
|
Logger::put(Logger::STANDARD_LOG,System::CIMLISTENER, |
|
Logger::INFORMATION, |
|
"CIMListener started"); | "CIMListener started"); |
| |
PEGASUS_STD(cerr) << "CIMlistener started" << PEGASUS_STD(endl); | PEGASUS_STD(cerr) << "CIMlistener started" << PEGASUS_STD(endl); |
|
|
|
_svc = svc.release(); |
|
_thread_pool = threadPool.release(); |
|
_listener_sem = sem.release(); |
} | } |
} | } |
| |