Skip to content

Commit

Permalink
Fix replay of requests with timestampp in "past"
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
buger committed Jul 1, 2021
1 parent b6cc6a3 commit 92c63de
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions input_file.go
Expand Up @@ -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
}
Expand Down

0 comments on commit 92c63de

Please sign in to comment.