From 60af3ce213ec1e097fcf0662acfc0385388148f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20M=C3=BCller?= Date: Wed, 21 Dec 2022 00:56:58 +0100 Subject: [PATCH] Use `sleep` in flock wait loop --- src/crystal/system/unix/file.cr | 2 +- src/crystal/system/win32/file.cr | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/crystal/system/unix/file.cr b/src/crystal/system/unix/file.cr index 36b54ea305a0..a976b4b08012 100644 --- a/src/crystal/system/unix/file.cr +++ b/src/crystal/system/unix/file.cr @@ -257,7 +257,7 @@ module Crystal::System::File if retry until flock(op) - ::Fiber.yield + sleep 0.1 end else flock(op) || raise IO::Error.from_errno("Error applying file lock: file is already locked") diff --git a/src/crystal/system/win32/file.cr b/src/crystal/system/win32/file.cr index bda41cde8b69..3fb3998e3c48 100644 --- a/src/crystal/system/win32/file.cr +++ b/src/crystal/system/win32/file.cr @@ -276,7 +276,7 @@ module Crystal::System::File handle = windows_handle if retry until lock_file(handle, flags) - ::Fiber.yield + sleep 0.1 end else lock_file(handle, flags) || raise IO::Error.from_winerror("Error applying file lock: file is already locked")