Skip to content

Commit

Permalink
ruby: Fix build failures with Ruby 3.4
Browse files Browse the repository at this point in the history
Ruby 3.4 started to actually mark some deprecated functions as
*deprecated* now resulting in compiler warnings (which due to -Werror we
treat as errors and thus the build fails).

The *new* functions were actually introduced back in Ruby 1.9.2, so have
been around for quite some time. We claim support for Ruby 2.0 onwards
so this is more than fine.

The new API replaces the old 'mark' and 'free' parameters with a struct
that allows for more fine tuning/configuration. We never made use of
either of those parameters and so the only member of this struct we
*need* to set is the structure wrapper name.

Ruby pytests still pass after this change...

Closes: nginx#1525
Link: <https://bugs.ruby-lang.org/issues/19998>
Signed-off-by: Andrew Clayton <[email protected]>
  • Loading branch information
ac000 committed Jan 21, 2025
1 parent b4201ab commit 60fc255
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/ruby/nxt_ruby_stream_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ static VALUE nxt_ruby_stream_io_flush(VALUE obj);
static VALUE nxt_ruby_stream_io_close(VALUE obj);


static const rb_data_type_t nxt_rctx_dt = { .wrap_struct_name = "rctx" };


VALUE
nxt_ruby_stream_io_input_init(void)
{
Expand Down Expand Up @@ -73,7 +76,7 @@ nxt_ruby_stream_io_new(VALUE class, VALUE arg)
{
VALUE self;

self = Data_Wrap_Struct(class, 0, 0, (void *) (uintptr_t) arg);
self = TypedData_Wrap_Struct(class, &nxt_rctx_dt, (void *)(uintptr_t)arg);

rb_obj_call_init(self, 0, NULL);

Expand All @@ -96,7 +99,7 @@ nxt_ruby_stream_io_gets(VALUE obj)
nxt_ruby_ctx_t *rctx;
nxt_unit_request_info_t *req;

Data_Get_Struct(obj, nxt_ruby_ctx_t, rctx);
TypedData_Get_Struct(obj, nxt_ruby_ctx_t, &nxt_rctx_dt, rctx);
req = rctx->req;

if (req->content_length == 0) {
Expand Down Expand Up @@ -152,7 +155,7 @@ nxt_ruby_stream_io_read(VALUE obj, VALUE args)
long copy_size, u_size;
nxt_ruby_ctx_t *rctx;

Data_Get_Struct(obj, nxt_ruby_ctx_t, rctx);
TypedData_Get_Struct(obj, nxt_ruby_ctx_t, &nxt_rctx_dt, rctx);

copy_size = rctx->req->content_length;

Expand Down Expand Up @@ -208,7 +211,7 @@ nxt_ruby_stream_io_puts(VALUE obj, VALUE args)
return Qnil;
}

Data_Get_Struct(obj, nxt_ruby_ctx_t, rctx);
TypedData_Get_Struct(obj, nxt_ruby_ctx_t, &nxt_rctx_dt, rctx);

nxt_ruby_stream_io_s_write(rctx, RARRAY_PTR(args)[0]);

Expand All @@ -226,7 +229,7 @@ nxt_ruby_stream_io_write(VALUE obj, VALUE args)
return Qnil;
}

Data_Get_Struct(obj, nxt_ruby_ctx_t, rctx);
TypedData_Get_Struct(obj, nxt_ruby_ctx_t, &nxt_rctx_dt, rctx);

len = nxt_ruby_stream_io_s_write(rctx, RARRAY_PTR(args)[0]);

Expand Down

0 comments on commit 60fc255

Please sign in to comment.