GUAC-1452: Cap timing entries at a maximum of 24 hours per entry.

This commit is contained in:
Michael Jumper 2016-01-27 09:39:58 -08:00
parent 8a6a2a1156
commit 6297f11724
2 changed files with 12 additions and 3 deletions

View File

@ -98,13 +98,15 @@ void guac_terminal_typescript_flush(guac_terminal_typescript* typescript) {
guac_timestamp this_flush = guac_timestamp_current(); guac_timestamp this_flush = guac_timestamp_current();
guac_timestamp last_flush = typescript->last_flush; guac_timestamp last_flush = typescript->last_flush;
/* Calculate elapsed time in seconds */ /* Calculate time since last flush */
double elapsed_time = (this_flush - last_flush) / 1000.0; int elapsed_time = this_flush - last_flush;
if (elapsed_time > GUAC_TERMINAL_TYPESCRIPT_MAX_DELAY)
elapsed_time = GUAC_TERMINAL_TYPESCRIPT_MAX_DELAY;
/* Produce single line of timestamp output */ /* Produce single line of timestamp output */
char timestamp_buffer[32]; char timestamp_buffer[32];
int timestamp_length = snprintf(timestamp_buffer, sizeof(timestamp_buffer), int timestamp_length = snprintf(timestamp_buffer, sizeof(timestamp_buffer),
"%0.6f %i\n", elapsed_time, typescript->length); "%0.6f %i\n", elapsed_time / 1000.0, typescript->length);
/* Calculate actual length of timestamp line */ /* Calculate actual length of timestamp line */
if (timestamp_length > sizeof(timestamp_buffer)) if (timestamp_length > sizeof(timestamp_buffer))

View File

@ -40,6 +40,13 @@
*/ */
#define GUAC_TERMINAL_TYPESCRIPT_FOOTER "\n[END TYPESCRIPT]\n" #define GUAC_TERMINAL_TYPESCRIPT_FOOTER "\n[END TYPESCRIPT]\n"
/**
* The maximum amount of time to allow for a particular timing entry, in
* milliseconds. Any timing entries exceeding this value will be written as
* exactly this value instead.
*/
#define GUAC_TERMINAL_TYPESCRIPT_MAX_DELAY 86400000
/** /**
* An active typescript, consisting of a data file (raw terminal output) and * An active typescript, consisting of a data file (raw terminal output) and
* timing file (related timestamps and byte counts). * timing file (related timestamps and byte counts).