@@ -56,7 +56,7 @@ static VALUE sGroup;
5656#endif
5757RUBY_EXTERN char * getlogin (void );
5858
59- #define RUBY_ETC_VERSION "1.4.5 "
59+ #define RUBY_ETC_VERSION "1.4.6 "
6060
6161#define SYMBOL_LIT (str ) ID2SYM(rb_intern_const(str ""))
6262
@@ -1163,14 +1163,26 @@ Init_etc(void)
11631163{
11641164 VALUE mEtc ;
11651165
1166- #ifdef HAVE_RB_EXT_RACTOR_SAFE
1167- RB_EXT_RACTOR_SAFE (true);
1168- #endif
11691166 mEtc = rb_define_module ("Etc" );
11701167 /* The version */
11711168 rb_define_const (mEtc , "VERSION" , rb_str_new_cstr (RUBY_ETC_VERSION ));
11721169 init_constants (mEtc );
11731170
1171+ /* Ractor-safe methods */
1172+ #ifdef HAVE_RB_EXT_RACTOR_SAFE
1173+ RB_EXT_RACTOR_SAFE (true);
1174+ #endif
1175+ rb_define_module_function (mEtc , "systmpdir" , etc_systmpdir , 0 );
1176+ rb_define_module_function (mEtc , "uname" , etc_uname , 0 );
1177+ rb_define_module_function (mEtc , "sysconf" , etc_sysconf , 1 );
1178+ rb_define_module_function (mEtc , "confstr" , etc_confstr , 1 );
1179+ rb_define_method (rb_cIO , "pathconf" , io_pathconf , 1 );
1180+ rb_define_module_function (mEtc , "nprocessors" , etc_nprocessors , 0 );
1181+
1182+ /* Non-Ractor-safe methods, see https://bugs.ruby-lang.org/issues/21115 */
1183+ #ifdef HAVE_RB_EXT_RACTOR_SAFE
1184+ RB_EXT_RACTOR_SAFE (false);
1185+ #endif
11741186 rb_define_module_function (mEtc , "getlogin" , etc_getlogin , 0 );
11751187
11761188 rb_define_module_function (mEtc , "getpwuid" , etc_getpwuid , -1 );
@@ -1186,13 +1198,9 @@ Init_etc(void)
11861198 rb_define_module_function (mEtc , "setgrent" , etc_setgrent , 0 );
11871199 rb_define_module_function (mEtc , "endgrent" , etc_endgrent , 0 );
11881200 rb_define_module_function (mEtc , "getgrent" , etc_getgrent , 0 );
1201+
1202+ /* Uses RbConfig::CONFIG so does not work in a Ractor */
11891203 rb_define_module_function (mEtc , "sysconfdir" , etc_sysconfdir , 0 );
1190- rb_define_module_function (mEtc , "systmpdir" , etc_systmpdir , 0 );
1191- rb_define_module_function (mEtc , "uname" , etc_uname , 0 );
1192- rb_define_module_function (mEtc , "sysconf" , etc_sysconf , 1 );
1193- rb_define_module_function (mEtc , "confstr" , etc_confstr , 1 );
1194- rb_define_method (rb_cIO , "pathconf" , io_pathconf , 1 );
1195- rb_define_module_function (mEtc , "nprocessors" , etc_nprocessors , 0 );
11961204
11971205 sPasswd = rb_struct_define_under (mEtc , "Passwd" ,
11981206 "name" ,
@@ -1303,4 +1311,8 @@ Init_etc(void)
13031311 rb_extend_object (sGroup , rb_mEnumerable );
13041312 rb_define_singleton_method (sGroup , "each" , etc_each_group , 0 );
13051313#endif
1314+
1315+ #if defined(HAVE_GETPWENT ) || defined(HAVE_GETGRENT )
1316+ (void )safe_setup_str ;
1317+ #endif
13061318}
0 commit comments