Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add API.last_error #55

Merged
merged 4 commits into from
Apr 17, 2021
Merged

Add API.last_error #55

merged 4 commits into from
Apr 17, 2021

Conversation

ashie
Copy link
Contributor

@ashie ashie commented Apr 16, 2021

Because Ruby may call Win32 API and reset the error code before a user
calls GetLastError(), the user might not be able to correct error code.
To avoid it win32-api should store last error code like FFI or Fiddle
do it. FYI:

Signed-off-by: Takuro Ashie ashie@clear-code.com

@ashie ashie force-pushed the last-error branch 2 times, most recently from ed3d898 to 5b25c3d Compare April 16, 2021 08:48
@ashie ashie changed the title Add API.last_error and API.last_error= Add API.last_error Apr 16, 2021
@ashie ashie marked this pull request as ready for review April 16, 2021 08:49
Because Ruby may call Win32 API and reset the error code before a user
calls GetLastError(), the user might not be able to correct error code.
To avoid it win32-api should store last error code like FFI or Fiddle
do it. FYI:

* FFI::LastError.winapi_error
  https://www.rubydoc.info/github/ffi/ffi/FFI/LastError#winapi_error-class_method
* Fiddle.win32_last_error
  https://rubyapi.org/3.0/o/fiddle#method-c-win32_last_error

Signed-off-by: Takuro Ashie <ashie@clear-code.com>
Signed-off-by: Hiroshi Hatake <cosmo0920.oucc@gmail.com>
Signed-off-by: Hiroshi Hatake <cosmo0920.oucc@gmail.com>
Because these Rubies does not communicates with rubygems via HTTPS.
This is SSL certificates expirations.
And they are already EOL.

Signed-off-by: Hiroshi Hatake <cosmo0920.oucc@gmail.com>
Copy link
Owner

@cosmo0920 cosmo0920 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd tweaked for AppVeyor CI tasks. Yeah, adding last_error singleton method is reasonable for me. 👍 Thanks for your work!

@cosmo0920 cosmo0920 merged commit 3604d7c into cosmo0920:master Apr 17, 2021
ashie added a commit to ashie/fluentd that referenced this pull request Apr 19, 2021
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 by using it.

Signed-off-by: Takuro Ashie <ashie@clear-code.com>
ashie added a commit to ashie/fluentd that referenced this pull request Apr 19, 2021
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 by using it.

Signed-off-by: Takuro Ashie <ashie@clear-code.com>
ashie added a commit to ashie/fluentd that referenced this pull request Apr 19, 2021
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>
kenhys pushed a commit to kenhys/fluentd that referenced this pull request Apr 22, 2021
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants