diff --git a/mri/ext/llhttp/extconf.rb b/mri/ext/llhttp/extconf.rb index 3f82f7a..a58db9f 100644 --- a/mri/ext/llhttp/extconf.rb +++ b/mri/ext/llhttp/extconf.rb @@ -3,4 +3,8 @@ require "mkmf" dir_config("llhttp_ext") + +# Check for Ractor support +have_func("rb_ext_ractor_safe", "ruby.h") + create_makefile("llhttp_ext") diff --git a/mri/ext/llhttp/llhttp_ext.c b/mri/ext/llhttp/llhttp_ext.c index cf38e36..f6bee8c 100644 --- a/mri/ext/llhttp/llhttp_ext.c +++ b/mri/ext/llhttp/llhttp_ext.c @@ -341,6 +341,10 @@ static VALUE rb_llhttp_init(VALUE self, VALUE type) { } void Init_llhttp_ext(void) { +#ifdef HAVE_RB_EXT_RACTOR_SAFE + rb_ext_ractor_safe(true); +#endif + mLLHttp = rb_const_get(rb_cObject, rb_intern("LLHttp")); cParser = rb_const_get(mLLHttp, rb_intern("Parser")); eError = rb_const_get(mLLHttp, rb_intern("Error"));