Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WindowsFile: Retrieve correct Win32 error codes
WindowsFile calls GetLastError via win32-api to retrieve win32 error code but the error code may be already reset by Ruby's internal code so that it can't retrive a correct error code. Sometimes it causes random unrecoverable errors when in_tail plugin tries to read a non-existent file like the following: 2021-04-14 03:15:45 +0000 [error]: #2 Fluent::Win32Error code: 158, The segment is already unlocked.: C:/path/to/log.txt Fiddle or FFI has a method to avoid this issue: * Fiddle.win32_last_error https://ruby-doc.org/stdlib-3.0.0/libdoc/fiddle/rdoc/Fiddle.html#method-c-win32_last_error * FFI::LastError.winapi_error https://www.rubydoc.info/github/ffi/ffi/FFI/LastError#winapi_error-instance_method We've added an equivalent method for win32-api: cosmo0920/win32-api#55 This commit replaces the retrieving the error code with this method. Signed-off-by: Takuro Ashie <ashie@clear-code.com>
- Loading branch information