diff options
author | Eric Wong <e@80x24.org> | 2023-02-15 03:19:14 +0000 |
---|---|---|
committer | Eric Wong <normal@ruby-lang.org> | 2023-02-15 03:26:47 +0000 |
commit | 3376eca80a9e23c295a4fe5fb9049c1ad27bb562 (patch) | |
tree | fc3c8a66d8357b85b1fda046d8383c73ed18847c /file.c | |
parent | 15ef2b2d7c6a7fb0d485d1e5a9b795a730ef7967 (diff) | |
download | ruby-3376eca80a9e23c295a4fe5fb9049c1ad27bb562.tar.gz |
file.c: rb_file_load_ok: GC+retry on EMFILE/ENFILE/ENOMEM
`require' should make a best effort to avoid failure on
recoverable resource exhaustion errors.
Diffstat (limited to 'file.c')
-rw-r--r-- | file.c | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -6374,7 +6374,11 @@ rb_file_load_ok(const char *path) #endif 0); int fd = rb_cloexec_open(path, mode, 0); - if (fd == -1) return 0; + if (fd < 0) { + if (!rb_gc_for_fd(errno)) return 0; + fd = rb_cloexec_open(path, mode, 0); + if (fd < 0) return 0; + } rb_update_max_fd(fd); ret = ruby_is_fd_loadable(fd); (void)close(fd); |