From 3376eca80a9e23c295a4fe5fb9049c1ad27bb562 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 15 Feb 2023 03:19:14 +0000 Subject: 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. --- file.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'file.c') 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); -- cgit v1.2.1