[Mono-bugs] [Bug 54860][Wis] New - w32api

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Wed, 25 Feb 2004 16:59:57 -0500 (EST)

Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by derek.mcumber@datamtnsol.com.


--- shadow/54860	2004-02-25 16:59:57.000000000 -0500
+++ shadow/54860.tmp.15196	2004-02-25 16:59:57.000000000 -0500
@@ -0,0 +1,77 @@
+Bug#: 54860
+Product: Mono/Runtime
+Version: unspecified
+OS Details: 
+Status: NEW   
+Priority: Wishlist
+Component: misc
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: derek.mcumber@datamtnsol.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+Summary: w32api
+On windowsxp/2k/etc., the GetFileAttributes w32api
+command in MonoIO.cs will raise an unhandled exception and will halt
+the executibles and require a restart.  This occurs under heavy load,
+primarily during a codegen and compile of code behinds in .aspx pages.
+Changes to metadata/file-io.c
+        and System/Microsoft.CSharp/
+Note: (I forgot) This also requires my native mcs compile solution,
+which omits the need for msft .net on the windows machine.  I will
+post this code as well.  (VC++ 6.0).  The MONO_PATH needs to be changed
+to a directory containing corlib.dll and the mcs class libraries before
+the standard mcs.exe (renamed to mcs3.exe in my code).
+I tried a number of things,
+and have gotten a somewhat stable solution, but more work is required.
+On calls to GetFileAttributes in MonoIO.cs, the following needs to be
+added to catch the exception and keep on trying:
+	public static bool Exists (string path, out MonoIOError error)
+	{
+	     FileAttributes attrs = (FileAttributes)(-1);
+		error = MonoIOError.ERROR_SUCCESS;
+		Exception exc = new IOException();
+		do {
+			try {
+				attrs = GetFileAttributes (path,
+							  out error);
+				exc = null;
+			} catch (Exception e) {
+				exc = e;
+			}
+		} while (exc !=null);
+		if (attrs == InvalidFileAttributes)
+			return false;
+		return true;
+	}
+This should be added to ExistsFile and ExistsDirectory, too.
+I also changed the System/Microsoft.CSharp/CSharpCodeCompiler.cs
+to not use the FileInfo class (which repeatedly calls the Existence
+routines in MonoIO), and create files with File.Create and move with
+Finally, I wrote a simple cache in the mono.exe runtime in
+metadata/file-io.c that will cache the last 20 requests to
+GetFileAttributes (omitting tmp files, .cs files, and dlls)
+so that a surge in requests will not unload the kernel and
+halt the app.
+I will send this cache if there is interest or just keep this hack
+to myself.  I am able to run mono on multi-CPU windows machines
+with these in place, but it still requires more optimization.
+Perhaps do away with the w32api for file and directory existence
+calls alltogether.  This cache may be better served in MonoIO.cs
+so the performance gain is greater.  Early tests show promise.