From 4791b2bc2289e36c33c7ba0e2c9f09a5f509f28d Mon Sep 17 00:00:00 2001 From: nobu Date: Fri, 21 Oct 2016 07:06:27 +0000 Subject: [PATCH] ruby.c: retry loading with GC * ruby.c (open_load_file): retry after GC when the limit for open file descriptors reached. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56463 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ ruby.c | 8 +++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index f26eae7ac1..bab1afbdd0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Fri Oct 21 16:06:25 2016 Nobuyoshi Nakada + + * ruby.c (open_load_file): retry after GC when the limit for open + file descriptors reached. + Fri Oct 21 11:34:17 2016 Pascal Schmid * string.c (rb_str_sub, rb_str_gsub): [DOC] 'backlash' should read diff --git a/ruby.c b/ruby.c index b21a32638b..feae61da64 100644 --- a/ruby.c +++ b/ruby.c @@ -1899,7 +1899,13 @@ open_load_file(VALUE fname_v, int *xflag) #endif if ((fd = rb_cloexec_open(fname, mode, 0)) < 0) { - rb_load_fail(fname_v, strerror(errno)); + int e = errno; + if (!rb_gc_for_fd(e)) { + rb_load_fail(fname_v, strerror(e)); + } + if ((fd = rb_cloexec_open(fname, mode, 0)) < 0) { + rb_load_fail(fname_v, strerror(errno)); + } } rb_update_max_fd(fd);