Skip to content

Commit 961683b

Browse files
committed
Run .so init functions in namespaces to be loaded
1 parent ba74fcd commit 961683b

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

load.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1212,17 +1212,19 @@ load_ext(VALUE path, VALUE fname)
12121212
return (VALUE)dln_load_feature(RSTRING_PTR(loaded), RSTRING_PTR(fname));
12131213
}
12141214

1215-
static bool
1216-
run_static_ext_init(rb_vm_t *vm, const char *feature)
1215+
static VALUE
1216+
run_static_ext_init(VALUE vm_ptr, VALUE feature_value)
12171217
{
1218+
rb_vm_t *vm = (rb_vm_t *)vm_ptr;
1219+
const char *feature = RSTRING_PTR(feature_value);
12181220
st_data_t key = (st_data_t)feature;
12191221
st_data_t init_func;
12201222

12211223
if (vm->static_ext_inits && st_delete(vm->static_ext_inits, &key, &init_func)) {
12221224
((void (*)(void))init_func)();
1223-
return true;
1225+
return Qtrue;
12241226
}
1225-
return false;
1227+
return Qfalse;
12261228
}
12271229

12281230
static int
@@ -1331,7 +1333,7 @@ require_internal(rb_execution_context_t *ec, VALUE fname, int exception, bool wa
13311333
else if (!*ftptr) {
13321334
result = TAG_RETURN;
13331335
}
1334-
else if (found == 's' && run_static_ext_init(th->vm, RSTRING_PTR(path))) {
1336+
else if (found == 's' && RTEST(rb_vm_call_cfunc_in_namespace(Qnil, run_static_ext_init, (VALUE)th->vm, path, path, ns))) {
13351337
result = TAG_RETURN;
13361338
}
13371339
else if (RTEST(rb_hash_aref(realpaths,

0 commit comments

Comments
 (0)