Skip to content

Commit f3aa1ea

Browse files
committed
fixes to encoding/transcoding for ractors
1 parent 62fdf27 commit f3aa1ea

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

encoding.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1603,7 +1603,7 @@ enc_set_default_encoding(struct default_encoding *def, VALUE encoding, const cha
16031603
overridden = TRUE;
16041604

16051605
if (!NIL_P(encoding)) {
1606-
enc_check_encoding(encoding); // loads it if necessary. Needs to be done outside of VM lock.
1606+
must_encoding(encoding); // loads it if necessary. Needs to be done outside of VM lock.
16071607
}
16081608

16091609
GLOBAL_ENC_TABLE_LOCKING(enc_table) {

transcode.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1826,7 +1826,9 @@ rb_econv_asciicompat_encoding(const char *ascii_incompat_name)
18261826
st_table *table2;
18271827
struct asciicompat_encoding_t data = {0};
18281828

1829-
RB_VM_LOCKING() {
1829+
unsigned int lev;
1830+
RB_VM_LOCK_ENTER_LEV(&lev);
1831+
{
18301832
if (st_lookup(transcoder_table, (st_data_t)ascii_incompat_name, &v)) {
18311833
table2 = (st_table *)v;
18321834
/*
@@ -1839,12 +1841,14 @@ rb_econv_asciicompat_encoding(const char *ascii_incompat_name)
18391841
if (table2->num_entries == 1) {
18401842
data.ascii_incompat_name = ascii_incompat_name;
18411843
data.ascii_compat_name = NULL;
1844+
RB_VM_LOCK_LEAVE_LEV(&lev);
18421845
st_foreach(table2, asciicompat_encoding_i, (st_data_t)&data);
1846+
RB_VM_LOCK_ENTER_LEV(&lev);
18431847
}
18441848

18451849
}
1846-
18471850
}
1851+
RB_VM_LOCK_LEAVE_LEV(&lev);
18481852

18491853
return data.ascii_compat_name; // can be NULL
18501854
}
@@ -3029,10 +3033,9 @@ econv_s_asciicompat_encoding(VALUE klass, VALUE arg)
30293033
VALUE enc = Qnil;
30303034

30313035
enc_arg(&arg, &arg_name, &arg_enc);
3036+
result_name = rb_econv_asciicompat_encoding(arg_name);
30323037

30333038
RB_VM_LOCKING() {
3034-
result_name = rb_econv_asciicompat_encoding(arg_name);
3035-
30363039
if (result_name) {
30373040
result_enc = make_encoding(result_name);
30383041
enc = rb_enc_from_encoding(result_enc);

0 commit comments

Comments
 (0)