summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorOisin Canty <o.canty@f5.com>2021-05-18 10:14:43 +0000
committerOisin Canty <o.canty@f5.com>2021-05-18 10:14:43 +0000
commitead6ed999a87fac6fc9ad3f4f94a6cec1d287b5e (patch)
tree98f4f9573c1367719f0a13ddccf2bd4f5b998f9d
parent19dfeba86b9dda6f1960ba9b3dba4708565d27ad (diff)
downloadunit-ead6ed999a87fac6fc9ad3f4f94a6cec1d287b5e.tar.gz
unit-ead6ed999a87fac6fc9ad3f4f94a6cec1d287b5e.tar.bz2
Ruby: changing deprecated rb_cData to rb_cObject.
Ruby 3.0 deprecated rb_cData with the intention to remove it in release 3.1. This commit changes references of rb_cData to rb_cObject. This was done so we can support distributions that package Ruby 3.0, such as Fedora 34. We also need to call rb_undef_alloc_func because we're no longer deriving from rb_cData. This prevents unnecessary allocations. See: https://docs.ruby-lang.org/en/3.0.0/doc/extension_rdoc.html "It is recommended that klass derives from a special class called Data (rb_cData) but not from Object or other ordinal classes. If it doesn't, you have to call rb_undef_alloc_func(klass)."
Diffstat (limited to '')
-rw-r--r--docs/changes.xml6
-rw-r--r--src/ruby/nxt_ruby_stream_io.c8
2 files changed, 12 insertions, 2 deletions
diff --git a/docs/changes.xml b/docs/changes.xml
index c69523f9..a4db9ec5 100644
--- a/docs/changes.xml
+++ b/docs/changes.xml
@@ -50,6 +50,12 @@ points on a per-request basis during static file serving.
</para>
</change>
+<change type="feature">
+<para>
+compatibility with Ruby 3.0.
+</para>
+</change>
+
<change type="bugfix">
<para>
a segmentation fault might have occurred in the PHP module if
diff --git a/src/ruby/nxt_ruby_stream_io.c b/src/ruby/nxt_ruby_stream_io.c
index 69bf289e..82ad3908 100644
--- a/src/ruby/nxt_ruby_stream_io.c
+++ b/src/ruby/nxt_ruby_stream_io.c
@@ -25,7 +25,9 @@ nxt_ruby_stream_io_input_init(void)
{
VALUE stream_io;
- stream_io = rb_define_class("NGINX_Unit_Stream_IO_Read", rb_cData);
+ stream_io = rb_define_class("NGINX_Unit_Stream_IO_Read", rb_cObject);
+
+ rb_undef_alloc_func(stream_io);
rb_gc_register_address(&stream_io);
@@ -46,7 +48,9 @@ nxt_ruby_stream_io_error_init(void)
{
VALUE stream_io;
- stream_io = rb_define_class("NGINX_Unit_Stream_IO_Error", rb_cData);
+ stream_io = rb_define_class("NGINX_Unit_Stream_IO_Error", rb_cObject);
+
+ rb_undef_alloc_func(stream_io);
rb_gc_register_address(&stream_io);