diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-10-21 07:44:46 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-10-21 07:44:46 +0000 |
commit | 5d20d347c772a64a1dab362dbfae765a8d687f43 (patch) | |
tree | 8b77794c595208096addc3b60351e2324f80cb82 /dir.c | |
parent | 9590e99031c434a2ac481d62e4bc921a91a2481c (diff) | |
download | ruby-5d20d347c772a64a1dab362dbfae765a8d687f43.tar.gz |
dir.c: retry glob with GC
* dir.c (do_opendir): retry after GC when the limit for open file
descriptors reached.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56467 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'dir.c')
-rw-r--r-- | dir.c | 15 |
1 files changed, 13 insertions, 2 deletions
@@ -1286,8 +1286,19 @@ do_opendir(const char *path, int flags, rb_encoding *enc) } #endif dirp = opendir(path); - if (dirp == NULL && !to_be_ignored(errno)) - sys_warning(path, enc); + if (!dirp) { + int e = errno; + switch (rb_gc_for_fd(e)) { + default: + dirp = opendir(path); + if (dirp) break; + e = errno; + /* fallback */ + case 0: + if (to_be_ignored(e)) break; + sys_warning(path, enc); + } + } #ifdef _WIN32 if (tmp) rb_str_resize(tmp, 0); /* GC guard */ #endif |