DWORD UmnSrvInitConfig( PUMN_SRV_API_CONFIG *ppConfig ) { PUMN_SRV_API_CONFIG pConfig = NULL; DWORD dwError = 0; dwError = RTL_ALLOCATE( &pConfig, UMN_SRV_API_CONFIG, sizeof(*pConfig)); BAIL_ON_UMN_ERROR(dwError); pConfig->CheckInterval = 60 * 30; pConfig->SkipNoLogin = FALSE; *ppConfig = pConfig; cleanup: return dwError; error: *ppConfig = NULL; UmnSrvFreeConfig(pConfig); goto cleanup; }
DWORD UmnSrvReadConfig( PUMN_SRV_API_CONFIG *ppConfig ) { DWORD dwError = 0; PUMN_SRV_API_CONFIG pConfig = NULL; dwError = UmnSrvInitConfig(&pConfig); BAIL_ON_UMN_ERROR(dwError); dwError = UmnSrvReadAllocatedConfig(pConfig); BAIL_ON_UMN_ERROR(dwError); UMN_LOG_VERBOSE("CheckInterval = %d seconds\n", pConfig->CheckInterval); UMN_LOG_VERBOSE("SkipNoLogin = %d\n", pConfig->SkipNoLogin); *ppConfig = pConfig; cleanup: return dwError; error: UmnSrvFreeConfig(pConfig); *ppConfig = NULL; goto cleanup; }
DWORD UmnSrvRefreshConfiguration( ) { DWORD dwError = 0; BOOLEAN bUnlockConfigLock = FALSE; PUMN_SRV_API_CONFIG pAPIConfig = NULL; dwError = UmnSrvReadConfig(&pAPIConfig); BAIL_ON_UMN_ERROR(dwError); pthread_rwlock_wrlock(&gUmnConfigLock); bUnlockConfigLock = TRUE; UmnSrvFreeConfig(gpAPIConfig); gpAPIConfig = pAPIConfig; pAPIConfig = NULL; dwError = UmnSrvPollerRefresh(); if (dwError == ESRCH) { // The thread may not be running yet dwError = 0; } BAIL_ON_UMN_ERROR(dwError); cleanup: UmnSrvFreeConfig(pAPIConfig); if (bUnlockConfigLock) { pthread_rwlock_unlock(&gUmnConfigLock); } return(dwError); error: goto cleanup; }
NTSTATUS SvcmStop( PLW_SVCM_INSTANCE pInstance ) { UMN_LOG_VERBOSE("Shutting down threads"); UmnSrvStopPollerThread(); UmnSrvFreeConfig(gpAPIConfig); LW_ASSERT(pthread_rwlock_destroy(&gUmnConfigLock) == 0); UMN_LOG_INFO("Usermonitor Service exiting..."); return 0; }