Fixing a race condition in makedirs when doit is run in parallel mode.

Hi.
This fix tries to mitigate #1550.
Cheers,
Felix