Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

race condition creating directories in parallel #2

Closed
dominictarr opened this Issue Jun 29, 2011 · 1 comment

Comments

Projects
None yet
2 participants
Contributor

dominictarr commented Jun 29, 2011

If many parallel calls are made to makedirp, there is a possible race condition.

say your creating testdir/data/apps and testdir/data/log. the mkdirp call for data/apps sees that data doesn't exists and then the mkdir call for data/log sees the same. Both start to create the directory, but one of the two fails because the other already created the data dir. The failed mkdirp call returns directly and the other just creates all subdirs.

hmm, https://github.com/substack/node-mkdirp/blob/master/index.js#L12 needs to check if there the error is that the directory already exists.

Owner

substack commented Jun 29, 2011

Wrote a test. All fixed.

@substack substack closed this Jun 29, 2011

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment