version 1.190.2.3, 2006/10/10 10:16:03
|
version 1.190.2.9, 2006/10/27 13:03:17
|
|
|
#include <Pegasus/ControlProviders/InteropProvider/InteropProvider.h> | #include <Pegasus/ControlProviders/InteropProvider/InteropProvider.h> |
#endif | #endif |
| |
|
#ifdef PEGASUS_SLP_REG_TIMEOUT |
|
#include <slp/slp_client/src/cmd-utils/slp_client/lslp-linux.h> |
|
#include <slp/slp_client/src/cmd-utils/slp_client/lslp.h> |
|
#include <slp/slp_client/src/cmd-utils/slp_client/lslp-common-defs.h> |
|
#include <slp/slp_client/src/cmd-utils/slp_client/slp_client.h> |
|
#endif |
|
|
// l10n | // l10n |
#include <Pegasus/Common/MessageLoader.h> | #include <Pegasus/Common/MessageLoader.h> |
| |
#include <Pegasus/Common/Threads.h> |
|
|
|
PEGASUS_NAMESPACE_BEGIN | PEGASUS_NAMESPACE_BEGIN |
#ifdef PEGASUS_SLP_REG_TIMEOUT | #ifdef PEGASUS_SLP_REG_TIMEOUT |
ThreadReturnType PEGASUS_THREAD_CDECL _advertisePegasus(void *parm); | ThreadReturnType PEGASUS_THREAD_CDECL _advertisePegasus(void *parm); |
# define MAX_LIFE 0x0fff |
//Definig maximum life of registration as the reregistration interval |
|
# define MAX_LIFE PEGASUS_SLP_REG_TIMEOUT * 60 |
# define SLP_PORT 427 | # define SLP_PORT 427 |
# define LOCALHOST_IP "127.0.0.1" | # define LOCALHOST_IP "127.0.0.1" |
#endif | #endif |
|
|
static CIMServer *_cimserver = NULL; | static CIMServer *_cimserver = NULL; |
| |
// Need a static method to act as a callback for the control provider. | // Need a static method to act as a callback for the control provider. |
|
|
// Signal handler for shutdown signals, currently SIGHUP and SIGTERM | // Signal handler for shutdown signals, currently SIGHUP and SIGTERM |
// | // |
Boolean handleShutdownSignal = false; | Boolean handleShutdownSignal = false; |
#ifdef PEGASUS_SLP_REG_TIMEOUT |
|
// Signal to shutdown the SLP advertising thread |
|
Boolean handleCloseSLPThread = false; |
|
#endif |
|
void shutdownSignalHandler(int s_n, PEGASUS_SIGINFO_T * s_info, void * sig) | void shutdownSignalHandler(int s_n, PEGASUS_SIGINFO_T * s_info, void * sig) |
{ | { |
PEG_METHOD_ENTER(TRC_SERVER, "shutdownSignalHandler"); | PEG_METHOD_ENTER(TRC_SERVER, "shutdownSignalHandler"); |
|
|
{ | { |
PEG_METHOD_ENTER(TRC_SERVER, "CIMServer::shutdownSignal()"); | PEG_METHOD_ENTER(TRC_SERVER, "CIMServer::shutdownSignal()"); |
handleShutdownSignal = true; | handleShutdownSignal = true; |
#ifdef PEGASUS_SLP_REG_TIMEOUT |
|
handleCloseSLPThread = true; |
|
#endif |
|
_cimserver->tickle_monitor(); | _cimserver->tickle_monitor(); |
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
} | } |
|
|
PEG_METHOD_ENTER(TRC_SERVER, "CIMServer::CIMServer()"); | PEG_METHOD_ENTER(TRC_SERVER, "CIMServer::CIMServer()"); |
_init(); | _init(); |
_cimserver = this; | _cimserver = this; |
#ifdef PEGASUS_SLP_REG_TIMEOUT |
|
SLPThread = NULL; |
|
#endif |
|
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
} | } |
| |
|
|
CIMServer::~CIMServer () | CIMServer::~CIMServer () |
{ | { |
PEG_METHOD_ENTER (TRC_SERVER, "CIMServer::~CIMServer()"); | PEG_METHOD_ENTER (TRC_SERVER, "CIMServer::~CIMServer()"); |
#ifdef PEGASUS_SLP_REG_TIMEOUT |
|
handleCloseSLPThread = true; |
|
#endif |
|
| |
// Wait until the Shutdown provider request has cleared through the | // Wait until the Shutdown provider request has cleared through the |
// system. | // system. |
|
|
// Note: Trace code in this method will be invoked frequently. | // Note: Trace code in this method will be invoked frequently. |
if(!_dieNow) | if(!_dieNow) |
{ | { |
#ifdef PEGASUS_ENABLE_SLP |
|
// Note - this func prevents multiple starting of slp provider |
|
startSLPProvider(); |
|
#endif |
|
|
|
_monitor->run(500000); |
|
|
|
static struct timeval lastIdleCleanupTime = {0, 0}; |
|
struct timeval now; | struct timeval now; |
Time::gettimeofday(&now); | Time::gettimeofday(&now); |
|
#ifdef PEGASUS_ENABLE_SLP |
#ifdef PEGASUS_SLP_REG_TIMEOUT | #ifdef PEGASUS_SLP_REG_TIMEOUT |
static struct timeval lastReregistrationTime = {0, 0}; | static struct timeval lastReregistrationTime = {0, 0}; |
const char * reRegTime = getenv("PEGASUS_SLP_REG_TIMEOUT"); |
// units of PEGASUS_SLP_REG_TIMEOUT is minutes. Multiplying PEGASUS_SLP_REG_TIMEOUT |
if (now.tv_sec - lastReregistrationTime.tv_sec > (atoi((const char*)reRegTime) * 60)) |
// to convert in to seconds. |
|
if (now.tv_sec - lastReregistrationTime.tv_sec > (PEGASUS_SLP_REG_TIMEOUT * 60)) |
{ | { |
lastReregistrationTime.tv_sec = now.tv_sec; | lastReregistrationTime.tv_sec = now.tv_sec; |
|
#endif |
startSLPProvider(); | startSLPProvider(); |
|
#ifdef PEGASUS_SLP_REG_TIMEOUT |
} | } |
#endif | #endif |
|
#endif |
|
_monitor->run(500000); |
| |
if (now.tv_sec - lastIdleCleanupTime.tv_sec >= 100) |
static struct timeval lastIdleCleanupTime = {0, 0}; |
|
|
|
if (now.tv_sec - lastIdleCleanupTime.tv_sec > 300) |
{ | { |
lastIdleCleanupTime.tv_sec = now.tv_sec; | lastIdleCleanupTime.tv_sec = now.tv_sec; |
try | try |
|
|
{ | { |
| |
PEG_METHOD_ENTER(TRC_PROVIDERMANAGER, "CIMServer::startSLPProvider"); | PEG_METHOD_ENTER(TRC_PROVIDERMANAGER, "CIMServer::startSLPProvider"); |
|
#ifndef PEGASUS_SLP_REG_TIMEOUT |
// onetime check is not needed for re-registration. |
|
//if(!reRegister) |
|
{ |
|
// This is a onetime function. If already issued, or config is not to use simply | // This is a onetime function. If already issued, or config is not to use simply |
// return | // return |
if (!_runSLP) | if (!_runSLP) |
{ | { |
return; | return; |
} | } |
|
#endif |
// Get Config parameter to determine if we should start SLP. | // Get Config parameter to determine if we should start SLP. |
ConfigManager* configManager = ConfigManager::getInstance(); | ConfigManager* configManager = ConfigManager::getInstance(); |
_runSLP = ConfigManager::parseBooleanValue( | _runSLP = ConfigManager::parseBooleanValue( |
|
|
{ | { |
return; | return; |
} | } |
|
#ifndef PEGASUS_SLP_REG_TIMEOUT |
//SLP startup is onetime function; reset the switch so this | //SLP startup is onetime function; reset the switch so this |
// function does not get called a second time. | // function does not get called a second time. |
_runSLP = false; | _runSLP = false; |
} |
#endif |
// Start SLPProvider for Built-in SA and Open SLP SA. if the PEGASUS_SLP_REG_TIMEOUT is defined |
// Start SLPProvider for Built-in SA and Open SLP SA. If the |
// start a thread which advertises CIMOM with a external SLP SA. |
// PEGASUS_SLP_REG_TIMEOUT is defined and if Open SLP is not used, start a |
#ifdef PEGASUS_SLP_REG_TIMEOUT |
// thread which advertises CIMOM with a external SLP SA( i.e . IBM SA). |
_startAdvThread = true; |
#if defined( PEGASUS_SLP_REG_TIMEOUT ) && !defined( PEGASUS_USE_OPENSLP ) |
Thread SLPThread(_advertisePegasus,0,true); | Thread SLPThread(_advertisePegasus,0,true); |
SLPThread.run(); | SLPThread.run(); |
#else | #else |
|
|
} | } |
| |
| |
|
|
// startSLPProvider is a function to get the slp provider kicked off | // startSLPProvider is a function to get the slp provider kicked off |
// during startup. It is placed in the provider manager simply because | // during startup. It is placed in the provider manager simply because |
// the provider manager is the only component of the system is | // the provider manager is the only component of the system is |
|
|
// open connection to CIMOM | // open connection to CIMOM |
// | // |
String hostStr = System::getHostName(); | String hostStr = System::getHostName(); |
|
|
try | try |
{ | { |
// | // |
|
|
{ | { |
| |
PEG_METHOD_ENTER(TRC_SERVER, "CIMServer::_advertisePegasus()"); | PEG_METHOD_ENTER(TRC_SERVER, "CIMServer::_advertisePegasus()"); |
|
SLPAttrib SLPHttpAttribObj; |
static SLPAttrib SLPHttpAttribObj; |
SLPAttrib SLPHttpsAttribObj; |
static SLPAttrib SLPHttpsAttribObj; |
|
struct slp_client *client; | struct slp_client *client; |
time_t now,last; | time_t now,last; |
lslpMsg msg_list; | lslpMsg msg_list; |
|
|
char *httpAttrs = (char *)NULL; | char *httpAttrs = (char *)NULL; |
char *httpsAttrs = (char *)NULL; | char *httpsAttrs = (char *)NULL; |
| |
if (!handleCloseSLPThread) |
|
{ |
|
// Comes here only if the cimserver is not terminated. | // Comes here only if the cimserver is not terminated. |
// Get all the SLP attributes and data for the Pegasus cimserver. | // Get all the SLP attributes and data for the Pegasus cimserver. |
SLPHttpAttribObj.fillData("http"); | SLPHttpAttribObj.fillData("http"); |
SLPHttpsAttribObj.fillData("https"); | SLPHttpsAttribObj.fillData("https"); |
SLPHttpAttribObj.formAttributes(); | SLPHttpAttribObj.formAttributes(); |
SLPHttpsAttribObj.formAttributes(); | SLPHttpsAttribObj.formAttributes(); |
} |
|
| |
scopes = strdup("DEFAULT"); | scopes = strdup("DEFAULT"); |
| |
|
//Populate datastructures required for registering a service with External SLP SA (i.e IBM SLP SA) |
type = strdup(SLPHttpAttribObj.getServiceType().getCString()); | type = strdup(SLPHttpAttribObj.getServiceType().getCString()); |
httpUrl = strdup(SLPHttpAttribObj.getServiceUrl().getCString()); | httpUrl = strdup(SLPHttpAttribObj.getServiceUrl().getCString()); |
httpsUrl = strdup(SLPHttpsAttribObj.getServiceUrl().getCString()); | httpsUrl = strdup(SLPHttpsAttribObj.getServiceUrl().getCString()); |
|
|
FALSE, | FALSE, |
FALSE))) | FALSE))) |
{ | { |
if (!handleCloseSLPThread) |
int rc_http = client->srv_reg_local(client, httpUrl, httpAttrs, type, scopes, life); |
|
int rc_https = client->srv_reg_local(client, httpsUrl, httpsAttrs, type, scopes, life); |
|
if (!rc_http) |
{ | { |
client->srv_reg_local(client, httpUrl, httpAttrs, type, scopes, life); |
PEG_TRACE_STRING(TRC_SERVER, Tracer::LEVEL2, |
client->srv_reg_local(client, httpsUrl, httpsAttrs, type, scopes, life); |
"CIMServer http registration is FAILED with External SLP"); |
|
} |
|
if (!rc_https) |
|
{ |
|
PEG_TRACE_STRING(TRC_SERVER, Tracer::LEVEL2, |
|
"CIMServer https registration is FAILED with External SLP"); |
} | } |
destroy_slp_client(client); | destroy_slp_client(client); |
} | } |
|
|
| |
// This routine deregisters the CIM Server registration with external SLP SA. | // This routine deregisters the CIM Server registration with external SLP SA. |
| |
int _deregPegasus() |
void deregPegasus() |
{ | { |
| |
PEG_METHOD_ENTER(TRC_SERVER, "CIMServer::deregPegasus()"); | PEG_METHOD_ENTER(TRC_SERVER, "CIMServer::deregPegasus()"); |
| |
static SLPAttrib SLPHttpAttribObj1; |
SLPAttrib SLPHttpAttribObj1; |
static SLPAttrib SLPHttpsAttribObj1; |
SLPAttrib SLPHttpsAttribObj1; |
struct slp_client *client; | struct slp_client *client; |
time_t now,last; | time_t now,last; |
lslpMsg msg_list; | lslpMsg msg_list; |
|
|
free(iface); | free(iface); |
| |
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
return( 32 ); |
return; |
} | } |
#endif | #endif |
PEGASUS_NAMESPACE_END | PEGASUS_NAMESPACE_END |