INT32 _SDB_KRCB::onConfigInit () { _role = utilGetRoleEnum( _optioncb.krcbRole() ) ; pmdSetDBRole( _role ) ; // Call trace start if we want to trace start up procedure if ( _optioncb.isTraceOn() && _optioncb.traceBuffSize() != 0 ) { sdbGetPDTraceCB()->start ( (UINT64)_optioncb.traceBuffSize(), 0xFFFFFFFF ) ; } // enable memory debug option ossEnableMemDebug( _optioncb.memDebugEnabled(), _optioncb.memDebugSize() ) ; return _optioncb.makeAllDir() ; }
INT32 pmdThreadMainEntry( INT32 argc, CHAR** argv ) { INT32 rc = SDB_OK ; pmdKRCB *krcb = pmdGetKRCB() ; CHAR currentPath[ OSS_MAX_PATHSIZE + 1 ] = { 0 } ; CHAR dialogPath[ OSS_MAX_PATHSIZE + 1 ] = { 0 } ; CHAR dialogFile[ OSS_MAX_PATHSIZE + 1 ] = { 0 } ; INT32 delSig[] = { 17, 0 } ; // del SIGCHLD CHAR verText[ OSS_MAX_PATHSIZE + 1 ] = { 0 } ; po::variables_map vm ; rc = initArgs( argc, argv, vm ) ; if ( rc ) { if ( SDB_PMD_HELP_ONLY == rc || SDB_PMD_VERSION_ONLY == rc ) { rc = SDB_OK ; } goto done ; } rc = ossGetEWD( currentPath, OSS_MAX_PATHSIZE ) ; if ( rc ) { std::cout << "Get current path failed: " << rc << std::endl ; goto error ; } ossChDir( currentPath ) ; rc = utilBuildFullPath( currentPath, SDBCM_LOG_PATH, OSS_MAX_PATHSIZE, dialogPath ) ; if ( rc ) { std::cout << "Build dialog path failed: " << rc << std::endl ; goto error ; } rc = ossMkdir( dialogPath ) ; if ( rc && SDB_FE != rc ) { std::cout << "Create dialog dir: " << dialogPath << " failed: " << rc << std::endl ; goto error ; } rc = utilBuildFullPath( dialogPath, SDBCM_DIALOG_FILE_NAME, OSS_MAX_PATHSIZE, dialogFile ) ; if ( rc ) { std::cout << "Build dialog path failed: " << rc << std::endl ; goto error ; } sdbEnablePD( dialogFile ) ; ossSprintVersion( "Version", verText, OSS_MAX_PATHSIZE, FALSE ) ; PD_LOG( PDEVENT, "Start cm[%s]...", verText) ; rc = sdbGetOMAgentOptions()->init( currentPath ) ; if ( rc ) { PD_LOG( PDERROR, "Failed to init config, rc: %d", rc ) ; goto error ; } if ( vm.count( PMD_OPTION_CURUSER ) ) { sdbGetOMAgentOptions()->setCurUser() ; } if ( vm.count( PMD_OPTION_STANDALONE ) ) { sdbGetOMAgentOptions()->setStandAlone() ; if ( vm.count( PMD_OPTION_ALIVE_TIME ) ) { UINT32 timeout = vm[ PMD_OPTION_ALIVE_TIME ].as<INT32>() ; sdbGetOMAgentOptions()->setAliveTimeout( timeout ) ; } } if ( vm.count( PMD_OPTION_PORT ) ) { string svcname = vm[ PMD_OPTION_PORT ].as<string>() ; sdbGetOMAgentOptions()->setCMServiceName( svcname.c_str() ) ; pmdSetLocalPort( (UINT16)ossAtoi( svcname.c_str() ) ) ; } setPDLevel( sdbGetOMAgentOptions()->getDiagLevel() ) ; { string configs ; sdbGetOMAgentOptions()->toString( configs ) ; PD_LOG( PDEVENT, "All configs:\n%s", configs.c_str() ) ; } pmdSetDBRole( SDB_ROLE_OMA ) ; rc = pmdEnableSignalEvent( dialogPath, (PMD_ON_QUIT_FUNC)pmdOnQuit, delSig ) ; PD_RC_CHECK ( rc, PDERROR, "Failed to enable trap, rc: %d", rc ) ; #if defined( _LINUX ) signal( SIGCHLD, SIG_IGN ) ; #endif // _LINUX PMD_REGISTER_CB( sdbGetOMAgentMgr() ) ; rc = krcb->init() ; PD_RC_CHECK( rc, PDERROR, "Failed to init krcb, rc: %d", rc ) ; { EDUID agentEDU = PMD_INVALID_EDUID ; pmdEDUMgr *eduMgr = krcb->getEDUMgr() ; rc = eduMgr->startEDU ( EDU_TYPE_PIPESLISTENER, (void*)sdbGetOMAgentOptions()->getCMServiceName(), &agentEDU ) ; PD_RC_CHECK( rc, PDERROR, "Start PIPELISTENER failed, rc: %d", rc ) ; rc = eduMgr->waitUntil( agentEDU, PMD_EDU_RUNNING ) ; PD_RC_CHECK( rc, PDERROR, "Wait pipe listener to running " "failed, rc: %d", rc ) ; } #if defined (_LINUX) { CHAR pmdProcessName [ OSS_RENAME_PROCESS_BUFFER_LEN + 1 ] = {0} ; ossSnprintf ( pmdProcessName, OSS_RENAME_PROCESS_BUFFER_LEN, "%s(%s)", utilDBTypeStr( pmdGetDBType() ), sdbGetOMAgentOptions()->getCMServiceName() ) ; ossEnableNameChanges ( argc, argv ) ; ossRenameProcess ( pmdProcessName ) ; } #endif // _LINUX while ( PMD_IS_DB_UP() ) { ossSleepsecs ( 1 ) ; } rc = krcb->getShutdownCode() ; done: PMD_SHUTDOWN_DB( rc ) ; pmdSetQuit() ; krcb->destroy () ; PD_LOG ( PDEVENT, "Stop programme, exit code: %d", krcb->getShutdownCode() ) ; return rc == SDB_OK ? 0 : 1 ; error: goto done ; }