Changeset 69953 in vbox
- Timestamp:
- Dec 6, 2017 11:30:48 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceTimeSync.cpp
r69500 r69953 503 503 504 504 /* 505 * Initialize the last host time to prevent log message. 506 */ 507 RTTIMESPEC HostLast; 508 if (RT_FAILURE(VbglR3GetHostTime(&HostLast))) 509 RTTimeSpecSetNano(&HostLast, 0); 510 511 /* 505 512 * The Work Loop. 506 513 */ … … 513 520 do 514 521 { 515 /* query it. */ 516 RTTIMESPEC GuestNow0, GuestNow, HostNow; 522 /* 523 * Query the session id (first to keep lantency low) and the time. 524 */ 525 uint64_t idNewSession = g_idTimeSyncSession; 526 if (g_fTimeSyncSetOnRestore) 527 VbglR3GetSessionId(&idNewSession); 528 529 RTTIMESPEC GuestNow0; 517 530 RTTimeNow(&GuestNow0); 531 532 RTTIMESPEC HostNow; 518 533 int rc2 = VbglR3GetHostTime(&HostNow); 519 534 if (RT_FAILURE(rc2)) … … 523 538 break; 524 539 } 540 541 RTTIMESPEC GuestNow; 525 542 RTTimeNow(&GuestNow); 526 543 527 /* calc latency and check if it's ok. */ 544 /* 545 * Calc latency and check if it's ok. 546 */ 528 547 RTTIMESPEC GuestElapsed = GuestNow; 529 548 RTTimeSpecSub(&GuestElapsed, &GuestNow0); … … 531 550 { 532 551 /* 533 * Set the time once after we were restored. 534 * (Of course only if the drift is bigger than MinAdjust) 552 * If we were just restored, set the adjustment threshold to zero to force a resync. 535 553 */ 536 554 uint32_t TimeSyncSetThreshold = g_TimeSyncSetThreshold; 537 if (g_fTimeSyncSetOnRestore) 555 if ( g_fTimeSyncSetOnRestore 556 && idNewSession != g_idTimeSyncSession) 538 557 { 539 uint64_t idNewSession = g_idTimeSyncSession; 540 VbglR3GetSessionId(&idNewSession); 541 if (idNewSession != g_idTimeSyncSession) 542 { 543 VGSvcVerbose(3, "vgsvcTimeSyncWorker: The VM session ID changed, forcing resync.\n"); 544 TimeSyncSetThreshold = 0; 545 g_idTimeSyncSession = idNewSession; 546 } 558 VGSvcVerbose(3, "vgsvcTimeSyncWorker: The VM session ID changed, forcing resync.\n"); 559 g_idTimeSyncSession = idNewSession; 560 TimeSyncSetThreshold = 0; 547 561 } 548 562 … … 578 592 * too big, fall back on just setting the time. 579 593 */ 580 581 if ( AbsDriftMilli > TimeSyncSetThreshold 582 || g_fTimeSyncSetNext 583 || !vgsvcTimeSyncAdjust(&Drift)) 594 if ( AbsDriftMilli > TimeSyncSetThreshold 595 || g_fTimeSyncSetNext 596 || !vgsvcTimeSyncAdjust(&Drift)) 584 597 { 585 598 vgsvcTimeSyncCancelAdjust(); 586 599 vgsvcTimeSyncSet(&Drift); 587 600 } 601 602 /* 603 * Log radical host time changes. 604 */ 605 int64_t cNsHostDelta = RTTimeSpecGetNano(&HostNow) - RTTimeSpecGetNano(&HostLast); 606 if ((uint64_t)RT_ABS(cNsHostDelta) > RT_NS_1HOUR / 2) 607 VGSvcVerbose(0, "vgsvcTimeSyncWorker: Radical host time change: %'RI64ns (HostNow=%RDtimespec HostLast=%RDtimespec)\n", 608 cNsHostDelta, &HostNow, &HostLast); 588 609 } 589 610 else 590 611 vgsvcTimeSyncCancelAdjust(); 612 HostLast = HostNow; 591 613 break; 592 614 }
Note:
See TracChangeset
for help on using the changeset viewer.