diff options
Diffstat (limited to 'ext/fiddle')
-rw-r--r-- | ext/fiddle/function.c | 11 | ||||
-rw-r--r-- | ext/fiddle/lib/fiddle.rb | 12 |
2 files changed, 21 insertions, 2 deletions
diff --git a/ext/fiddle/function.c b/ext/fiddle/function.c index 1d82bc8a3e..d15a54bfa6 100644 --- a/ext/fiddle/function.c +++ b/ext/fiddle/function.c @@ -375,10 +375,17 @@ function_call(int argc, VALUE argv[], VALUE self) (void)rb_thread_call_without_gvl(nogvl_ffi_call, &args, 0, 0); } - rb_funcall(mFiddle, rb_intern("last_error="), 1, INT2NUM(errno)); + { + int errno_keep = errno; #if defined(_WIN32) - rb_funcall(mFiddle, rb_intern("win32_last_error="), 1, INT2NUM(errno)); + int socket_error = WSAGetLastError(); + rb_funcall(mFiddle, rb_intern("win32_last_error="), 1, + INT2NUM(errno_keep)); + rb_funcall(mFiddle, rb_intern("win32_last_socket_error="), 1, + INT2NUM(socket_error)); #endif + rb_funcall(mFiddle, rb_intern("last_error="), 1, INT2NUM(errno_keep)); + } ALLOCV_END(alloc_buffer); 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 |