Boost logo

Boost :

From: Vladimir Prus (ghost_at_[hidden])
Date: 2004-03-09 01:55:12

Beman Dawes wrote:

> >What can be done? Basically, adding a mutex for MT build and adding a
> >warning to docs are the variants. Opinions?
> There is already a general race-condition warning in the docs. See

True, I've missed that.

> Even if the filesystem library itself were made thread-safe, the problem
> could still happen because the state of the external file system may be
> altered by some other process or other machine.
> Is there a issue with solving your particular problem by either using your
> own mutex, or catching and discarding the exception, or moving the
> create_directory() call to prolog code that is single-threaded?

No issues with those, I only wanted to make sure this problem is known.
After more though, I wonder if create_directories should not swallow
exceptions itself. E.g.

   try {
   catch(const filesystem_error& e) {
         if (e.error() == filesystem::already_exists_error)
               ; // do nothing

After all, caller only cares if directory exists, if it was created by
another thread it's ok.

- Volodya

Boost list run by bdawes at, gregod at, cpdaniel at, john at