aboutsummaryrefslogtreecommitdiffstats
path: root/file.c
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2023-02-15 03:19:14 +0000
committerEric Wong <normal@ruby-lang.org>2023-02-15 03:26:47 +0000
commit3376eca80a9e23c295a4fe5fb9049c1ad27bb562 (patch)
treefc3c8a66d8357b85b1fda046d8383c73ed18847c /file.c
parent15ef2b2d7c6a7fb0d485d1e5a9b795a730ef7967 (diff)
downloadruby-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.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/file.c b/file.c
index 48f57ec621..68122de6ae 100644
--- a/file.c
+++ b/file.c
@@ -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);