Make Addrinfo objects Ractor shareable
Allow Addrinfo objects to be shared among Ractors. Addrinfo objects are already immutable, so I think it's safe for us to tag them as RUBY_TYPED_FROZEN_SHAREABLE shareable too.
This commit is contained in:
parent
b08e20d34a
commit
1c66124273
Notes:
git
2025-05-21 01:04:50 +00:00
@ -1211,6 +1211,7 @@ addrinfo_memsize(const void *ptr)
|
||||
static const rb_data_type_t addrinfo_type = {
|
||||
"socket/addrinfo",
|
||||
{addrinfo_mark, addrinfo_free, addrinfo_memsize,},
|
||||
0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_FROZEN_SHAREABLE,
|
||||
};
|
||||
|
||||
static VALUE
|
||||
|
@ -360,6 +360,12 @@ class TestSocketAddrinfo < Test::Unit::TestCase
|
||||
assert_raise(Socket::ResolutionError) { Addrinfo.tcp("0.0.0.0", 4649).family_addrinfo("::1", 80) }
|
||||
end
|
||||
|
||||
def test_ractor_shareable
|
||||
assert_ractor(<<~'RUBY', require: 'socket', timeout: 60)
|
||||
Ractor.make_shareable Addrinfo.new "\x10\x02\x14\xE9\xE0\x00\x00\xFB\x00\x00\x00\x00\x00\x00\x00\x00".b
|
||||
RUBY
|
||||
end
|
||||
|
||||
def random_port
|
||||
# IANA suggests dynamic port for 49152 to 65535
|
||||
# http://www.iana.org/assignments/port-numbers
|
||||
|
Loading…
x
Reference in New Issue
Block a user