summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Kanis <lars@greiz-reinsdorf.de>2023-04-18 10:31:18 +0200
committerLars Kanis <lars@greiz-reinsdorf.de>2023-04-18 13:13:25 +0200
commit82f5942f97731d8a46401d2465d007d89092a45c (patch)
tree45445eebc9ce3509971025f2f5a388831670057e
parent8f77740e3bae97eae50ac17132b133db50da197b (diff)
downloadffi-82f5942f97731d8a46401d2465d007d89092a45c.tar.gz
Ensure errno is usable in Ractor
No need to share per thread data object accross ractors.
-rw-r--r--ext/ffi_c/LastError.c2
-rw-r--r--spec/ffi/errno_spec.rb8
2 files changed, 9 insertions, 1 deletions
diff --git a/ext/ffi_c/LastError.c b/ext/ffi_c/LastError.c
index 877a3d3..f4da301 100644
--- a/ext/ffi_c/LastError.c
+++ b/ext/ffi_c/LastError.c
@@ -105,7 +105,7 @@ static const rb_data_type_t thread_data_data_type = {
},
// IMPORTANT: WB_PROTECTED objects must only use the RB_OBJ_WRITE()
// macro to update VALUE references, as to trigger write barriers.
- .flags = RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED | FFI_RUBY_TYPED_FROZEN_SHAREABLE
+ .flags = RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED
};
static ID id_thread_data;
diff --git a/spec/ffi/errno_spec.rb b/spec/ffi/errno_spec.rb
index 4170f92..c0207b8 100644
--- a/spec/ffi/errno_spec.rb
+++ b/spec/ffi/errno_spec.rb
@@ -34,4 +34,12 @@ describe "FFI.errno" do
expect(FFI.errno).to eq(0x12345678)
end
end
+
+ it "works in Ractor", :ractor do
+ res = Ractor.new do
+ LibTest.setLastError(0x12345678)
+ FFI.errno
+ end.take
+ expect(res).to eq(0x12345678)
+ end
end