From a3c6e13e2f7921e4dda817052563d0fe36f46df6 Mon Sep 17 00:00:00 2001 From: Boris van Katwijk Date: Thu, 12 Aug 2021 11:53:16 +0200 Subject: [PATCH] [REFACTOR][AOM2-172] Sleep for a random millisecond instead of microsecond to avoid the difference being smaller than the save time, which would result in duplicate CSP reports. --- Model/ReportRepository.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Model/ReportRepository.php b/Model/ReportRepository.php index b63a32b..908c9cf 100644 --- a/Model/ReportRepository.php +++ b/Model/ReportRepository.php @@ -104,8 +104,8 @@ public function save( // @TODO: [Nice to have] Find the reason csp reports are sent directly at the same time, to prevent having to // to use the usleep() mechanic to de-synchronise saving. - // Sleep for a random microsecond to prevent double saves - $sleep = rand(1, 1000000); + // Sleep for a random millisecond to prevent double saves + $sleep = rand(1000, 1000000); usleep($sleep); $existingReport = $this->doesReportExistAlready($report);