Boost logo

Boost :

From: Vladimir Prus (ghost_at_[hidden])
Date: 2004-03-05 09:40:51


I have an application which sometimes fails saying that it can't create a
directory, because it already exists. The directory is created by

     fs::create_directories("run");

and the application is multi-threaded. It seems there's a race condition:

         if (ph.empty() || exists(ph)) return;

         // First create branch, by calling ourself recursively
         create_directories(ph.branch_path());
         // Now that parent's path exists, create the directory
         create_directory(ph);

After one thread checks that 'ph' does not exist, another one creates the same
directory, so call to 'create_directory' fails.

What can be done? Basically, adding a mutex for MT build and adding a warning
to docs are the variants. Opinions?

- Volodya


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk