version 1.190.2.2, 2006/10/10 09:49:06
|
version 1.190.2.7, 2006/10/23 16:51:25
|
|
|
// 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 |
|
|
Time::gettimeofday(&now); | Time::gettimeofday(&now); |
| |
#ifdef PEGASUS_SLP_REG_TIMEOUT | #ifdef PEGASUS_SLP_REG_TIMEOUT |
static struct timeval lastReregistrationTime = {0, 0}; |
static struct timeval lastReregistrationTime = now; |
const char * reRegTime = getenv("PEG_SLP_REG_TIMEOUT"); |
// units of PEGASUS_SLP_REG_TIMEOUT is minutes. Multiplying PEGASUS_SLP_REG_TIMEOUT |
if (now.tv_sec - lastReregistrationTime.tv_sec > (atoi(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; |
|
// To allow the Reregistration _runSLP is made true. This flag is checked |
|
// in startSLPProvider() |
|
_runSLP = true; |
startSLPProvider(); | startSLPProvider(); |
|
//To disallow the registration call being made from the start of this routine. |
|
_runSLP = false; |
} | } |
#endif | #endif |
| |
if (now.tv_sec - lastIdleCleanupTime.tv_sec >= 100) |
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"); |
|
|
// onetime check is not needed for re-registration. | // 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 |
|
if (!_runSLP) | if (!_runSLP) |
{ | { |
return; | return; |
|
|
//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; |
} |
|
// 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). |
|
#if defined( PEGASUS_SLP_REG_TIMEOUT ) && !defined( PEGASUS_USE_OPENSLP ) |
_startAdvThread = true; | _startAdvThread = true; |
Thread SLPThread(_advertisePegasus,0,true); | Thread SLPThread(_advertisePegasus,0,true); |
SLPThread.run(); | SLPThread.run(); |
|
|
} | } |
| |
| |
|
|
// 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; |
|
|
| |
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()); |
|
|
{ | { |
if (!handleCloseSLPThread) | if (!handleCloseSLPThread) |
{ | { |
client->srv_reg_local(client, httpUrl, httpAttrs, type, scopes, life); |
int rc_http = client->srv_reg_local(client, httpUrl, httpAttrs, type, scopes, life); |
client->srv_reg_local(client, httpsUrl, httpsAttrs, type, scopes, life); |
int rc_https = client->srv_reg_local(client, httpsUrl, httpsAttrs, type, scopes, life); |
|
if (!rc_http) |
|
{ |
|
PEGASUS_STD(cerr) << "CIMServer http registration is FAILED with External SLP" << PEGASUS_STD(endl); |
|
} |
|
if (!rc_https) |
|
{ |
|
PEGASUS_STD(cerr) << "CIMServer https registration is FAILED with External SLP" << PEGASUS_STD(endl); |
|
} |
} | } |
destroy_slp_client(client); | destroy_slp_client(client); |
} | } |
|
|
| |
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; |