Skip to content

Commit

Permalink
Use sleep in flock wait loop (#12861)
Browse files Browse the repository at this point in the history
  • Loading branch information
straight-shoota authored Dec 22, 2022
1 parent 8674a93 commit 9e47a2d
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/crystal/system/unix/file.cr
Original file line number Diff line number Diff line change
@@ -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")
2 changes: 1 addition & 1 deletion src/crystal/system/win32/file.cr
Original file line number Diff line number Diff line change
@@ -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")

0 comments on commit 9e47a2d

Please sign in to comment.