Changeset 64300 in vbox
- Timestamp:
- Oct 17, 2016 2:20:08 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceTimeSync.cpp
r62679 r64300 71 71 * 72 72 * It now boils down to these three (configuration) factors: 73 * -# g_ TimeSyncMinAdjust - The minimum drift we will ever bother with.73 * -# g_cMsTimeSyncMinAdjust - The minimum drift we will ever bother with. 74 74 * -# g_TimeSyncLatencyFactor - The factor we multiply the latency by to 75 75 * calculate the dynamic minimum adjust factor. 76 * -# g_ TimeSyncMaxLatency - When to start discarding the data as utterly76 * -# g_cMsTimeSyncMaxLatency - When to start discarding the data as utterly 77 77 * useless and take a rest (someone is too busy to give us good data). 78 78 * -# g_TimeSyncSetThreshold - The threshold at which we will just set the time … … 109 109 static uint32_t g_TimeSyncInterval = 0; 110 110 /** 111 * @see pg_v boxservice_timesync111 * @see pg_vgsvc_timesync 112 112 * 113 113 * @remark OS/2: There is either a 1 second resolution on the DosSetDateTime … … 116 116 */ 117 117 #ifdef RT_OS_OS2 118 static uint32_t g_ TimeSyncMinAdjust = 1000;118 static uint32_t g_cMsTimeSyncMinAdjust = 1000; 119 119 #else 120 static uint32_t g_ TimeSyncMinAdjust = 100;120 static uint32_t g_cMsTimeSyncMinAdjust = 100; 121 121 #endif 122 /** @see pg_v boxservice_timesync */122 /** @see pg_vgsvc_timesync */ 123 123 static uint32_t g_TimeSyncLatencyFactor = 8; 124 /** @see pg_v boxservice_timesync */125 static uint32_t g_ TimeSyncMaxLatency = 250;126 /** @see pg_v boxservice_timesync */124 /** @see pg_vgsvc_timesync */ 125 static uint32_t g_cMsTimeSyncMaxLatency = 250; 126 /** @see pg_vgsvc_timesync */ 127 127 static uint32_t g_TimeSyncSetThreshold = 20*60*1000; 128 128 /** Whether the next adjustment should just set the time instead of trying to … … 185 185 || rc == VERR_NOT_FOUND) 186 186 rc = VGSvcReadPropUInt32(uGuestPropSvcClientID, "/VirtualBox/GuestAdd/VBoxService/--timesync-min-adjust", 187 &g_ TimeSyncMinAdjust, 0, 3600000);187 &g_cMsTimeSyncMinAdjust, 0, 3600000); 188 188 if ( RT_SUCCESS(rc) 189 189 || rc == VERR_NOT_FOUND) … … 193 193 || rc == VERR_NOT_FOUND) 194 194 rc = VGSvcReadPropUInt32(uGuestPropSvcClientID, "/VirtualBox/GuestAdd/VBoxService/--timesync-max-latency", 195 &g_ TimeSyncMaxLatency, 1, 3600000);195 &g_cMsTimeSyncMaxLatency, 1, 3600000); 196 196 if ( RT_SUCCESS(rc) 197 197 || rc == VERR_NOT_FOUND) … … 245 245 rc = VGSvcArgUInt32(argc, argv, "", pi, &g_TimeSyncInterval, 50, UINT32_MAX - 1); 246 246 else if (!strcmp(argv[*pi], "--timesync-min-adjust")) 247 rc = VGSvcArgUInt32(argc, argv, "", pi, &g_ TimeSyncMinAdjust, 0, 3600000);247 rc = VGSvcArgUInt32(argc, argv, "", pi, &g_cMsTimeSyncMinAdjust, 0, 3600000); 248 248 else if (!strcmp(argv[*pi], "--timesync-latency-factor")) 249 249 rc = VGSvcArgUInt32(argc, argv, "", pi, &g_TimeSyncLatencyFactor, 1, 1024); 250 250 else if (!strcmp(argv[*pi], "--timesync-max-latency")) 251 rc = VGSvcArgUInt32(argc, argv, "", pi, &g_ TimeSyncMaxLatency, 1, 3600000);251 rc = VGSvcArgUInt32(argc, argv, "", pi, &g_cMsTimeSyncMaxLatency, 1, 3600000); 252 252 else if (!strcmp(argv[*pi], "--timesync-set-threshold")) 253 253 rc = VGSvcArgUInt32(argc, argv, "", pi, &g_TimeSyncSetThreshold, 0, 7*24*60*60*1000); /* a week */ … … 528 528 RTTIMESPEC GuestElapsed = GuestNow; 529 529 RTTimeSpecSub(&GuestElapsed, &GuestNow0); 530 if ((uint32_t)RTTimeSpecGetMilli(&GuestElapsed) < g_ TimeSyncMaxLatency)530 if ((uint32_t)RTTimeSpecGetMilli(&GuestElapsed) < g_cMsTimeSyncMaxLatency) 531 531 { 532 532 /* … … 551 551 */ 552 552 uint32_t MinAdjust = RTTimeSpecGetMilli(&GuestElapsed) * g_TimeSyncLatencyFactor; 553 if (MinAdjust < g_ TimeSyncMinAdjust)554 MinAdjust = g_ TimeSyncMinAdjust;553 if (MinAdjust < g_cMsTimeSyncMinAdjust) 554 MinAdjust = g_cMsTimeSyncMinAdjust; 555 555 556 556 RTTIMESPEC Drift = HostNow; 557 557 RTTimeSpecSub(&Drift, &GuestNow); 558 558 if (RTTimeSpecGetMilli(&Drift) < 0) 559 MinAdjust += g_ TimeSyncMinAdjust; /* extra buffer against moving time backwards. */559 MinAdjust += g_cMsTimeSyncMinAdjust; /* extra buffer against moving time backwards. */ 560 560 561 561 RTTIMESPEC AbsDrift = Drift; … … 591 591 break; 592 592 } 593 VGSvcVerbose(3, "vgsvcTimeSyncWorker: %RDtimespec: latency too high (%RDtimespec) sleeping 1s\n", GuestElapsed); 593 VGSvcVerbose(3, "vgsvcTimeSyncWorker: %RDtimespec: latency too high (%RDtimespec, max %ums) sleeping 1s\n", 594 &GuestNow, &GuestElapsed, g_cMsTimeSyncMaxLatency); 594 595 RTThreadSleep(1000); 595 596 } while (--cTries > 0);
Note:
See TracChangeset
for help on using the changeset viewer.