[Mono-devel-list] Exists() and races.

Paolo Molaro lupus at ximian.com
Mon Jun 9 05:34:48 EDT 2003


> --- FileStream.cs	9 Jun 2003 06:48:35 -0000	1.36
> +++ FileStream.cs	9 Jun 2003 08:02:51 -0000	1.37
> @@ -114,7 +114,10 @@
>  			// TODO: demand permissions
>  
>  			MonoIOError error;
> -			
> +
> +  			if (!MonoIO.ExistsDirectory (Path.GetDirectoryName (name), out error))
> +  				throw new DirectoryNotFoundException (Path.GetDirectoryName (name));
> +
>  			this.handle = MonoIO.Open (name, mode, access, share,
>  						   out error);
>  			if (handle == MonoIO.InvalidHandle) {

I picked this commit, but I think there are other example of the use
of the Exists*() methods that are incorrect.
The if (!MonoIO.ExistsDirectory (...)) test is incorrect: what happens
if the directory is removed between the check and the open? We're still
back at the original bug that this change probably tryed to fix.
The check must be removed, since it's usless and we should make sure
that Open() sets the correct error if the directory is missing and the
DirectoryNotFound exception gets thrown only if Open reports the
directory is missing.

Anyone up to the task of auditing the assemblies for incorrect use of
Exists*() and fixing the issues in the correct way?

Thanks.

lupus

-- 
-----------------------------------------------------------------
lupus at debian.org                                     debian/rules
lupus at ximian.com                             Monkeys do it better



More information about the Mono-devel-list mailing list