GUACAMOLE-172: Ignore insane timestamps when calculating lag.

This commit is contained in:
Michael Jumper 2017-01-15 13:59:15 -08:00
parent 234f98705e
commit 6131ad0341

View File

@ -95,29 +95,35 @@ int __guac_handle_sync(guac_user* user, int argc, char** argv) {
if (timestamp > user->client->last_sent_timestamp) if (timestamp > user->client->last_sent_timestamp)
return -1; return -1;
/* Update stored timestamp */ /* Only update lag calculations if timestamp is sane */
user->last_received_timestamp = timestamp; if (timestamp >= user->last_received_timestamp) {
/* Calculate length of frame, including network and processing lag */ /* Update stored timestamp */
frame_duration = current - timestamp; user->last_received_timestamp = timestamp;
/* Update lag statistics if at least one frame has been rendered */ /* Calculate length of frame, including network and processing lag */
if (user->last_frame_duration != 0) { frame_duration = current - timestamp;
/* Calculate lag using the previous frame as a baseline */ /* Update lag statistics if at least one frame has been rendered */
int processing_lag = frame_duration - user->last_frame_duration; if (user->last_frame_duration != 0) {
/* Adjust back to zero if cumulative error leads to a negative value */ /* Calculate lag using the previous frame as a baseline */
if (processing_lag < 0) int processing_lag = frame_duration - user->last_frame_duration;
processing_lag = 0;
user->processing_lag = processing_lag; /* Adjust back to zero if cumulative error leads to a negative
* value */
if (processing_lag < 0)
processing_lag = 0;
user->processing_lag = processing_lag;
}
/* Record baseline duration of frame by excluding lag */
user->last_frame_duration = frame_duration - user->processing_lag;
} }
/* Record baseline duration of frame by excluding lag */
user->last_frame_duration = frame_duration - user->processing_lag;
if (user->sync_handler) if (user->sync_handler)
return user->sync_handler(user, timestamp); return user->sync_handler(user, timestamp);
return 0; return 0;