@@ -16,9 +16,9 @@ VALUE cFiddleFunction;
1616
1717static ID id_ptr , id_abi , id_argument_types , id_return_type , id_is_variadic ,
1818 id_need_gvl , id_name , id_closure , id_aref ,
19- id_set_last_error ;
19+ id_last_error ;
2020#if defined(_WIN32 )
21- static ID id_set_win32_last_error , id_set_win32_last_socket_error ;
21+ static ID id_win32_last_error , id_win32_last_socket_error ;
2222#endif
2323
2424#define MAX_ARGS (SIZE_MAX / (sizeof(void *) + sizeof(fiddle_generic)) - 1)
@@ -403,12 +403,13 @@ function_call(int argc, VALUE argv[], VALUE self)
403403#if defined(_WIN32 )
404404 DWORD error = WSAGetLastError ();
405405 int socket_error = WSAGetLastError ();
406- rb_funcall ( mFiddle , id_set_win32_last_error , 1 ,
407- ULONG2NUM (error ));
408- rb_funcall ( mFiddle , id_set_win32_last_socket_error , 1 ,
409- INT2NUM (socket_error ));
406+ rb_thread_local_aset ( rb_thread_current (), id_win32_last_error ,
407+ ULONG2NUM (error ));
408+ rb_thread_local_aset ( rb_thread_current (), id_win32_last_socket_error ,
409+ INT2NUM (socket_error ));
410410#endif
411- rb_funcall (mFiddle , id_set_last_error , 1 , INT2NUM (errno_keep ));
411+ rb_thread_local_aset (rb_thread_current (), id_last_error ,
412+ INT2NUM (errno_keep ));
412413 }
413414
414415 ALLOCV_END (alloc_buffer );
@@ -461,12 +462,11 @@ Init_fiddle_function(void)
461462 id_need_gvl = rb_intern_const ("@need_gvl" );
462463 id_name = rb_intern_const ("@name" );
463464 id_closure = rb_intern_const ("@closure" );
464- id_Pointer = rb_intern_const ("Pointer" );
465465 id_aref = rb_intern_const ("[]" );
466- id_set_last_error = rb_intern_const ("last_error= " );
466+ id_last_error = rb_intern_const ("__FIDDLE_LAST_ERROR__ " );
467467#if defined(_WIN32 )
468- id_set_win32_last_error = rb_intern_const ("win32_last_error= " );
469- id_set_win32_last_socket_error = rb_intern_const ("win32_last_socket_error= " );
468+ id_win32_last_error = rb_intern_const ("__FIDDLE_WIN32_LAST_ERROR__ " );
469+ id_win32_last_socket_error = rb_intern_const ("__FIDDLE_WIN32_LAST_SOCKET_ERROR__ " );
470470#endif
471471
472472 cFiddleFunction = rb_define_class_under (mFiddle , "Function" , rb_cObject );
0 commit comments