summaryrefslogtreecommitdiff
path: root/ext/fiddle/lib
diff options
context:
space:
mode:
authorSutou Kouhei <kou@clear-code.com>2021-04-19 16:37:17 +0900
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2021-05-18 12:48:40 +0900
commit71d4a493b890a21fdf3b302849d6d60c11ba1d9e (patch)
tree76cb4bdf49d11ea385907efa30a3664f5fc6ed4b /ext/fiddle/lib
parent2579593a56fd96d9085daa7f11dfc2dd231cb70f (diff)
downloadruby-71d4a493b890a21fdf3b302849d6d60c11ba1d9e.tar.gz
[ruby/fiddle] windows: add Fiddle.win32_last_socket_error{,=}
GitHub: fix GH-72 Users can't use WSAGetLastError() with Ruby 3.0 or later because rb_funcall() resets the last socket error internally. Users can get the last socket error by Fiddle.win32_last_socket_error. Reported by Kentaro Hayashi. Thanks!!! https://github.com/ruby/fiddle/commit/76158db00a
Diffstat (limited to 'ext/fiddle/lib')
-rw-r--r--ext/fiddle/lib/fiddle.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/ext/fiddle/lib/fiddle.rb b/ext/fiddle/lib/fiddle.rb
index 3fdf525b4c..4512989310 100644
--- a/ext/fiddle/lib/fiddle.rb
+++ b/ext/fiddle/lib/fiddle.rb
@@ -17,6 +17,18 @@ module Fiddle
def self.win32_last_error= error
Thread.current[:__FIDDLE_WIN32_LAST_ERROR__] = error
end
+
+ # Returns the last win32 socket +Error+ of the current executing
+ # +Thread+ or nil if none
+ def self.win32_last_socket_error
+ Thread.current[:__FIDDLE_WIN32_LAST_SOCKET_ERROR__]
+ end
+
+ # Sets the last win32 socket +Error+ of the current executing
+ # +Thread+ to +error+
+ def self.win32_last_socket_error= error
+ Thread.current[:__FIDDLE_WIN32_LAST_SOCKET_ERROR__] = error
+ end
end
# Returns the last +Error+ of the current executing +Thread+ or nil if none