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

WinSock: Ensure to retrieve correct error code on Ruby 3.0 #112

Merged
merged 2 commits into from
May 20, 2021

Conversation

ashie
Copy link
Collaborator

@ashie ashie commented Apr 21, 2021

On Ruby 3.0, calling WSAGetLastError from Ruby script cannot get a
correct error code because Ruby's internal code resets it. Use
Fiddle.win32_last_socket_error instead if it's availbale.
You need fiddle 1.0.8 or later to use it. In addition, when you use
RubyInstaller, you need to specify the path of fiddle by RUBYLIB or
ruby -I at this moment because it loads Ruby's bundled fiddle before
initializing gem. This is the why we don't add a dependency to fiddle,
just only installing fiddle doesn't take effect.

e.g.)

gem install fiddle --version 1.0.8
set RUBYLIB=C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/fiddle-1.0.8/lib
bundle exec rake spec

See also:

ashie added 2 commits April 27, 2021 13:31
On Ruby 3.0, calling WSAGetLastError from Ruby script cannot get a
correct error code because Ruby's internal code resets it. Use
`Fiddle.win32_last_socket_error` instead if it's availbale.
You need fiddle 1.0.8 or later to use it. In addition, when you use
RubyInstaller, you need to specify the path of fiddle by `RUBYLIB` or
`ruby -I` at this moment because it loads Ruby's bundled fiddle before
initializing gem. This is the why we don't add a dependency to fiddle,
just only installing fiddle doesn't take effect.

e.g.)

  > gem install fiddle --version 1.0.8
  > set RUBYLIB=C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/fiddle-1.0.8/lib
  > bundle exec rake spec

See also:
* ruby/fiddle#72
* https://bugs.ruby-lang.org/issues/17813
* https://github.com/oneclick/rubyinstaller2/blob/8225034c22152d8195bc0aabc42a956c79d6c712/lib/ruby_installer/build/dll_directory.rb

Signed-off-by: Takuro Ashie <[email protected]>
@ashie ashie force-pushed the fix-WSAGetLastError branch from 21038a8 to 6aad8b2 Compare April 27, 2021 04:32
@ashie
Copy link
Collaborator Author

ashie commented Apr 27, 2021

@repeatedly Could you take look this?

@ashie
Copy link
Collaborator Author

ashie commented May 6, 2021

CI for Windows fails on a test but it's not this PR's issue:

Failures:
  1) ServerEngine::BlockingFlag wait_for_set timeout
     Failure/Error: elapsed.should >= 0.1 * 0.95
       expected: >= 0.095
            got:    0.093236
     # ./spec/blocking_flag_spec.rb:29:in `block (2 levels) in <top (required)>'

@kenhys
Copy link
Collaborator

kenhys commented May 17, 2021

@repeatedly Hi, could you kindly review this PR?

@repeatedly
Copy link
Contributor

Looks good to me.

@td-dev Does anyone merge this?

@ashie ashie merged commit 75faf5e into treasure-data:master May 20, 2021
@ashie ashie deleted the fix-WSAGetLastError branch May 20, 2021 00:34
@ashie
Copy link
Collaborator Author

ashie commented May 20, 2021

Now I've got the permission.
Thank you for your review!

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.

3 participants