mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
dir.c: GC guard
* dir.c (dir_initialize): add GC guard for retrying. the argument of RSTRING_PTR() may be eliminated by optimization. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49169 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
376c4e8100
commit
79219d9656
1 changed files with 5 additions and 2 deletions
7
dir.c
7
dir.c
|
@ -445,6 +445,7 @@ dir_initialize(int argc, VALUE *argv, VALUE dir)
|
|||
rb_encoding *fsenc;
|
||||
VALUE dirname, opt, orig;
|
||||
static ID keyword_ids[1];
|
||||
const char *path;
|
||||
|
||||
if (!keyword_ids[0]) {
|
||||
keyword_ids[0] = rb_intern("encoding");
|
||||
|
@ -472,13 +473,15 @@ dir_initialize(int argc, VALUE *argv, VALUE dir)
|
|||
dp->dir = NULL;
|
||||
dp->path = Qnil;
|
||||
dp->enc = fsenc;
|
||||
dp->dir = opendir(RSTRING_PTR(dirname));
|
||||
path = RSTRING_PTR(dirname);
|
||||
dp->dir = opendir(path);
|
||||
if (dp->dir == NULL) {
|
||||
if (errno == EMFILE || errno == ENFILE) {
|
||||
rb_gc();
|
||||
dp->dir = opendir(RSTRING_PTR(dirname));
|
||||
dp->dir = opendir(path);
|
||||
}
|
||||
if (dp->dir == NULL) {
|
||||
RB_GC_GUARD(dirname);
|
||||
rb_sys_fail_path(orig);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue