[phobos] [D-Programming-Language/phobos] d3f9e2: std.file: Fix race condition when mkdirRecurse run...

GitHub noreply at github.com
Mon Jan 6 06:47:05 PST 2014


  Branch: refs/heads/master
  Home:   https://github.com/D-Programming-Language/phobos
  Commit: d3f9e24f91aaedb56cedec5608efd27917a48eab
      https://github.com/D-Programming-Language/phobos/commit/d3f9e24f91aaedb56cedec5608efd27917a48eab
  Author: Vladimir Panteleev <vladimir at thecybershadow.net>
  Date:   2014-01-06 (Mon, 06 Jan 2014)

  Changed paths:
    M std/file.d

  Log Message:
  -----------
  std.file: Fix race condition when mkdirRecurse runs concurrently

mkdirRecurse would crash if a directory was created between its
exists() and mkdir() calls. This could occur if mkdirRecurse was called
at the same time from mutiple threads or processes.

Instead of relying on the exists() check to indicate whether the next
mkdir() should succeed, we explicitly ignore "already exists" errors
from the OS. Note that this changes the behavior of mkdirRecurse when
the leaf directory already existed: previously it would throw, whereas
now it will silently succeed. The new behavior is conformant with some
other implementations of "recursive mkdir": the -p flag of the GNU
tool, Ruby's mkpath, Java's mkdirs, and Perl's make_path. (On the
other hand, the old behavior was equivalent to the behavior of
Python's makedirs).


  Commit: 2c981df4d1832c0cab9ac660114e050ebe95af6e
      https://github.com/D-Programming-Language/phobos/commit/2c981df4d1832c0cab9ac660114e050ebe95af6e
  Author: Vladimir Panteleev <vladimir at thecybershadow.net>
  Date:   2014-01-06 (Mon, 06 Jan 2014)

  Changed paths:
    M std/file.d

  Log Message:
  -----------
  std.file: Simplify/optimize mkdirRecurse

The left.length != pathname.length check both takes care of the
Windows-only check, and it avoids a pointless stat on the FS root.


  Commit: eea81d8a863421d9e6f855f487c6fe809a434b1c
      https://github.com/D-Programming-Language/phobos/commit/eea81d8a863421d9e6f855f487c6fe809a434b1c
  Author: Andrej Mitrovic <andrej.mitrovich at gmail.com>
  Date:   2014-01-06 (Mon, 06 Jan 2014)

  Changed paths:
    M std/file.d

  Log Message:
  -----------
  Merge pull request #1818 from CyberShadow/std-file-mkdirRecurse

std.file: Fix race condition when mkdirRecurse runs concurrently


Compare: https://github.com/D-Programming-Language/phobos/compare/7933ee1e57d0...eea81d8a8634


More information about the phobos mailing list