Changeset 19084 in vbox for trunk/src/VBox/Additions
- Timestamp:
- Apr 21, 2009 3:13:05 PM (16 years ago)
- Location:
- trunk/src/VBox/Additions/common/VBoxService
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxService/VBoxService.cpp
r19031 r19084 549 549 rc = VbglR3Daemonize(false /* fNoChDir */, false /* fNoClose */); 550 550 if (RT_FAILURE(rc)) 551 return VBoxServiceError(" daemon failed: %Rrc\n", rc);551 return VBoxServiceError("Daemon failed: %Rrc\n", rc); 552 552 /* in-child */ 553 553 #endif -
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceTimeSync.cpp
r19031 r19084 130 130 static HANDLE g_hTokenProcess = NULL; 131 131 /** Old token privileges. */ 132 static TOKEN_PRIVILEGES g_tkOldPrivileges; 132 static TOKEN_PRIVILEGES g_TkOldPrivileges; 133 /** Backup values for time adjustment. */ 134 static DWORD g_dwWinTimeAdjustment; 135 static DWORD g_dwWinTimeIncrement; 136 static BOOL g_bWinTimeAdjustmentDisabled; 133 137 #endif 134 138 … … 191 195 if (LookupPrivilegeValue(NULL, SE_SYSTEMTIME_NAME, &tkPriv.Privileges[0].Luid)) 192 196 { 193 DWORD cbRet = sizeof(g_ tkOldPrivileges);194 if (!AdjustTokenPrivileges(g_hTokenProcess, FALSE, &tkPriv, sizeof(TOKEN_PRIVILEGES), &g_ tkOldPrivileges, &cbRet))197 DWORD cbRet = sizeof(g_TkOldPrivileges); 198 if (!AdjustTokenPrivileges(g_hTokenProcess, FALSE, &tkPriv, sizeof(TOKEN_PRIVILEGES), &g_TkOldPrivileges, &cbRet)) 195 199 { 196 200 DWORD dwErr = GetLastError(); … … 220 224 } 221 225 } 226 227 if (!::GetSystemTimeAdjustment(&g_dwWinTimeAdjustment, &g_dwWinTimeIncrement, &g_bWinTimeAdjustmentDisabled)) 228 { 229 DWORD dwErr = GetLastError(); 230 rc = RTErrConvertFromWin32(dwErr); 231 VBoxServiceError("Could not get time adjustment values! Last error: %ld!\n", dwErr); 232 } 233 else VBoxServiceVerbose(3, "Windows time adjustment: Initially %ld (100ns) units per %ld (100 ns) units interval, disabled=%d\n", 234 g_dwWinTimeAdjustment, g_dwWinTimeIncrement, g_bWinTimeAdjustmentDisabled ? 1 : 0); 222 235 #endif /* RT_OS_WINDOWS */ 223 236 … … 289 302 */ 290 303 #ifdef RT_OS_WINDOWS 291 /* Just make sure it compiles for now, but later: 292 SetSystemTimeAdjustment and fall back on SetSystemTime. 293 */ 294 //AssertFatalFailed(); 304 DWORD dwWinTimeAdjustment, dwWinNewTimeAdjustment, dwWinTimeIncrement; 305 BOOL bWinTimeAdjustmentDisabled; 306 if (!::GetSystemTimeAdjustment(&dwWinTimeAdjustment, &dwWinTimeIncrement, &bWinTimeAdjustmentDisabled)) 307 { 308 VBoxServiceError("GetSystemTimeAdjustment failed, error=%ld\n", GetLastError()); 309 } 310 else 311 { 312 DWORD dwDiffMax = g_dwWinTimeAdjustment * 0.50; 313 DWORD dwDiffNew = dwWinTimeAdjustment * 0.10; 314 315 if (RTTimeSpecGetMilli(&Drift) > 0) 316 { 317 dwWinNewTimeAdjustment = dwWinTimeAdjustment + dwDiffNew; 318 if (dwWinNewTimeAdjustment > (g_dwWinTimeAdjustment + dwDiffMax)) 319 { 320 dwWinNewTimeAdjustment = g_dwWinTimeAdjustment + dwDiffMax; 321 dwDiffNew = dwDiffMax; 322 } 323 } 324 else 325 { 326 dwWinNewTimeAdjustment = dwWinTimeAdjustment - dwDiffNew; 327 if (dwWinNewTimeAdjustment < (g_dwWinTimeAdjustment - dwDiffMax)) 328 { 329 dwWinNewTimeAdjustment = g_dwWinTimeAdjustment - dwDiffMax; 330 dwDiffNew = dwDiffMax; 331 } 332 } 333 334 VBoxServiceVerbose(3, "Windows time adjustment: Drift=%ldms\n", RTTimeSpecGetMilli(&Drift)); 335 VBoxServiceVerbose(3, "Windows time adjustment: OrgTA=%ld, CurTA=%ld, NewTA=%ld, DiffNew=%ld, DiffMax=%ld\n", 336 g_dwWinTimeAdjustment, dwWinTimeAdjustment, dwWinNewTimeAdjustment, dwDiffNew, dwDiffMax); 337 338 if (!::SetSystemTimeAdjustment(dwWinNewTimeAdjustment, FALSE /* Periodic adjustments enabled. */)) 339 { 340 VBoxServiceError("SetSystemTimeAdjustment failed, error=%ld\n", GetLastError()); 341 } 342 } 343 295 344 #else /* !RT_OS_WINDOWS */ 296 345 struct timeval tv; … … 331 380 #endif /* !RT_OS_WINDOWS */ 332 381 } 382 else 383 { 384 #ifdef RT_OS_WINDOWS 385 if (::SetSystemTimeAdjustment(0, TRUE /* Periodic adjustments disabled. */)) 386 VBoxServiceVerbose(3, "Windows Time Adjustment is now disabled."); 387 #endif /* !RT_OS_WINDOWS */ 388 } 333 389 break; 334 390 } … … 378 434 if (g_hTokenProcess) 379 435 { 380 if (!AdjustTokenPrivileges(g_hTokenProcess, FALSE, &g_ tkOldPrivileges, sizeof(TOKEN_PRIVILEGES), NULL, NULL))436 if (!AdjustTokenPrivileges(g_hTokenProcess, FALSE, &g_TkOldPrivileges, sizeof(TOKEN_PRIVILEGES), NULL, NULL)) 381 437 { 382 438 DWORD dwErr = GetLastError();
Note:
See TracChangeset
for help on using the changeset viewer.