treasure-data / serverengine

A framework to implement robust multiprocess servers like Unicorn
Apache License 2.0
759 stars 86 forks source link

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

Closed ashie closed 3 years ago

ashie commented 3 years ago

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 commented 3 years ago

@repeatedly Could you take look this?

ashie commented 3 years ago

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 commented 3 years ago

@repeatedly Hi, could you kindly review this PR?

repeatedly commented 3 years ago

Looks good to me.

@td-dev Does anyone merge this?

ashie commented 3 years ago

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