[Mono-list] Simple Hosting fixes

Tim Haynes thaynes@openlinksw.com (Tim Haynes)
Tue, 04 Feb 2003 10:55:26 +0000


--=-=-=

Hi,

The attached diff changes
class/System.Web/System.Web/HttpApplicationFactory.cs to allow
HttpRuntime.Close() to work correctly - decrementing the counter when
deleting/not checking for the counter when about to delete - and
class/System.Web/System.Web.Hosting/SimpleWorkerRequest.cs, to make
MapPath work correctly - the _App{Install,Virtual}Path variables were
being initialised wrongly.

A suggested ChangeLog entry is as follows:

2003-02-04  Tim Haynes <thaynes@openlinksw.com>

	* HttpApplicationFactory.cs: fixed HttpRuntime.Close() to
	decrement instance counter

        * SimpleWorkerRequest.cs: changed the initialised values of
        _App{Install,Virtual}Path variables

Cheers,

~Tim
-- 
OpenLink Software
Tel: +44 (0) 20 8681 7701
Web: <http://www.openlinksw.com/>
Universal Data Access & Data Integration Technology Providers


--=-=-=
Content-Disposition: attachment
Content-Description: hosting diffs

Index: class/System.Web/System.Web/HttpApplicationFactory.cs
===================================================================
RCS file: /mono/mcs/class/System.Web/System.Web/HttpApplicationFactory.cs,v
retrieving revision 1.8
diff -b -B -u -r1.8 HttpApplicationFactory.cs
--- class/System.Web/System.Web/HttpApplicationFactory.cs	18 Dec 2002 02:17:16 -0000	1.8
+++ class/System.Web/System.Web/HttpApplicationFactory.cs	3 Jan 2003 16:32:16 -0000
@@ -189,9 +189,10 @@
 		private void Dispose() {
 			ArrayList torelease = new ArrayList();
 			lock (_appFreePublicList) {
-				do {
+				while (_appFreePublicList.Count > 0) {
 					torelease.Add(_appFreePublicList.Pop());
-				} while (_appFreePublicList.Count > 0);
+					_appFreePublicInstances --;
+				}
 			}
 
 			if (torelease.Count > 0) {
Index: class/System.Web/System.Web.Hosting/SimpleWorkerRequest.cs
===================================================================
RCS file: /mono/mcs/class/System.Web/System.Web.Hosting/SimpleWorkerRequest.cs,v
retrieving revision 1.5
diff -b -B -u -r1.5 SimpleWorkerRequest.cs
--- class/System.Web/System.Web.Hosting/SimpleWorkerRequest.cs	28 Sep 2002 07:44:14 -0000	1.5
+++ class/System.Web/System.Web.Hosting/SimpleWorkerRequest.cs	3 Jan 2003 16:32:23 -0000
@@ -43,12 +43,12 @@
 			o = current.GetData (".hostingVirtualPath");
 			if (o == null)
 				throw new HttpException ("Cannot get .hostingVirtualPath");
-			_AppInstallPath = o.ToString ();
+			_AppVirtualPath = CheckAndAddVSlash (o.ToString ());
 
 			o = current.GetData (".hostingInstallDir");
 			if (o == null)
 				throw new HttpException ("Cannot get .hostingInstallDir");
-			_AppVirtualPath = CheckAndAddSlash (o.ToString ());
+			_AppInstallPath = o.ToString ();
 			_Output = Output;
 
 			if (_AppPhysicalPath == null)
@@ -198,9 +198,9 @@
 			char sep = Path.DirectorySeparatorChar;
 			if (path.StartsWith(_AppVirtualPath)) {
 				if (sep == '/')
-					return sPath + path.Substring (_AppVirtualPath.Length);
+					return _AppPhysicalPath + path.Substring (_AppVirtualPath.Length);
 				else
-					return sPath + path.Substring (_AppVirtualPath.Length).Replace ('/', '\\');
+					return _AppPhysicalPath + path.Substring (_AppVirtualPath.Length).Replace ('/', sep);
 			}
 
 			return null;
@@ -239,6 +239,18 @@
 
 			if (!sPath.EndsWith ("" + Path.DirectorySeparatorChar))
 				return sPath + Path.DirectorySeparatorChar;
+
+			return sPath;
+		}
+
+		// Creates a path string
+		private string CheckAndAddVSlash(string sPath)
+		{
+			if (null == sPath)
+				return null;
+
+			if (!sPath.EndsWith ("/"))
+				return sPath + "/";
 
 			return sPath;
 		}

--=-=-=--