From 92c63de7536bd1d91a75ae6452c656f53622fc61 Mon Sep 17 00:00:00 2001 From: Leonid Bugaev Date: Thu, 1 Jul 2021 23:27:34 +0300 Subject: [PATCH] Fix replay of requests with timestampp in "past" In some rare cases, requests can be recorded out of order. It was causing replay from file significanty slodown when such issue met. Now it replays them but without adding sleep. --- input_file.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/input_file.go b/input_file.go index a039d9c..5447492 100644 --- a/input_file.go +++ b/input_file.go @@ -238,13 +238,15 @@ func (i *FileInput) emit() { if lastTime != -1 { diff := reader.timestamp - lastTime - lastTime = reader.timestamp if i.speedFactor != 1 { diff = int64(float64(diff) / i.speedFactor) } - time.Sleep(time.Duration(diff)) + if diff >= 0 { + lastTime = reader.timestamp + time.Sleep(time.Duration(diff)) + } } else { lastTime = reader.timestamp }