Skip to content
Permalink
Browse files

Cope with failure to open a directory in DIR-RECURSE

DIR-RECURSE is used in CompUnit::Repository::FileSystem
S11-repository/curi-install.t installs modules into a directory that
S11-modules/nested.t uses as a CURFS lib. S11-repository/curi-install.t also
deletes its files when it is finished. This can lead to a race condition if
these two tests are run at the same time, but never in isolation.

With this change, we skip any directories that fail to open - this is fine for
how DIR-RECURSE gets used internally.

Many thanks to ugexe++ for uncovering this long standing flapper!
Fixes GH #1956
  • Loading branch information...
niner committed Jun 24, 2018
1 parent c441d8d commit e9351cbaa961c4d1e4ef8b4cb52418d55766a8d6
Showing with 13 additions and 3 deletions.
  1. +13 −3 src/core/Rakudo/Internals.pm6
@@ -1176,15 +1176,25 @@ my class Rakudo::Internals {

method !next() {
nqp::while(
nqp::isnull_s(my str $elem = nqp::nextfiledir($!handle))
!$!handle
|| nqp::isnull_s(my str $elem = nqp::nextfiledir($!handle))
|| nqp::iseq_i(nqp::chars($elem),0),
nqp::stmts(
nqp::closedir($!handle),
nqp::if(
nqp::defined($!handle),
nqp::stmts(
nqp::closedir($!handle),
($!handle := Any),
)
),
nqp::if(
nqp::elems($!todo),
nqp::stmts(
($!abspath = nqp::pop_s($!todo)),
($!handle := nqp::opendir($!abspath)),
nqp::handle(
($!handle := nqp::opendir($!abspath)),
'CATCH', 0
),
($!abspath = nqp::concat($!abspath,$!dir-sep))
),
return ''

0 comments on commit e9351cb

Please sign in to comment.
You can’t perform that action at this time.