Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGonzalo Paniagua Javier <gonzalo.mono@gmail.com>2004-09-24 01:18:35 +0400
committerGonzalo Paniagua Javier <gonzalo.mono@gmail.com>2004-09-24 01:18:35 +0400
commitd1c584769d3223e044d8d8c7a7e0bf0ce06e54d4 (patch)
tree2ac951594c55663cf5fc9acac85f69dd6f39d4ab
parent20cb643a975497ff4afe17a56d44a301f64f6e4b (diff)
2004-09-24 Gonzalo Paniagua Javier <gonzalo@ximian.com>
* HttpApplicationFactory.cs: * HttpRuntime.cs: implemented UnloadAppDomain and be ready for domain unloading. svn path=/branches/mono-1-0/mcs/; revision=34319
-rw-r--r--mcs/class/System.Web/System.Web/ChangeLog6
-rw-r--r--mcs/class/System.Web/System.Web/HttpApplicationFactory.cs66
-rw-r--r--mcs/class/System.Web/System.Web/HttpRuntime.cs40
3 files changed, 62 insertions, 50 deletions
diff --git a/mcs/class/System.Web/System.Web/ChangeLog b/mcs/class/System.Web/System.Web/ChangeLog
index 4d69b6dbbce..01478566763 100644
--- a/mcs/class/System.Web/System.Web/ChangeLog
+++ b/mcs/class/System.Web/System.Web/ChangeLog
@@ -1,3 +1,9 @@
+2004-09-24 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * HttpApplicationFactory.cs:
+ * HttpRuntime.cs: implemented UnloadAppDomain and be ready for domain
+ unloading.
+
2004-09-12 Ben Maurer <bmaurer@ximian.com>
* HttpContext.cs: use CallContext. It is a little bit faster.
diff --git a/mcs/class/System.Web/System.Web/HttpApplicationFactory.cs b/mcs/class/System.Web/System.Web/HttpApplicationFactory.cs
index 65ce0a9f9e1..5882982564c 100644
--- a/mcs/class/System.Web/System.Web/HttpApplicationFactory.cs
+++ b/mcs/class/System.Web/System.Web/HttpApplicationFactory.cs
@@ -142,43 +142,39 @@ namespace System.Web {
return appTypeEventHandlers;
}
-
- static bool FireEvents (string method_name, object target, object [] args)
- {
- Hashtable possibleEvents = GetApplicationTypeEvents ((HttpApplication) target);
- MethodInfo method = possibleEvents [method_name] as MethodInfo;
- if (method == null)
- return false;
-
- if (method.GetParameters ().Length == 0)
- method.Invoke (target, null);
- else
- method.Invoke (target, args);
-
- return true;
- }
-
+
+ static bool FireEvent (string method_name, object target, object [] args)
+ {
+ Hashtable possibleEvents = GetApplicationTypeEvents ((HttpApplication) target);
+ MethodInfo method = possibleEvents [method_name] as MethodInfo;
+ if (method == null)
+ return false;
+
+ if (method.GetParameters ().Length == 0)
+ method.Invoke (target, null);
+ else
+ method.Invoke (target, args);
+
+ return true;
+ }
+
internal static void FireOnAppStart (HttpApplication app)
- {
+ {
object [] args = new object [] {app, EventArgs.Empty};
- FireEvents ("Application_Start", app, args);
- }
-
- void FireOnAppEnd ()
- {
- // FireEvents ("Application_End", this, new object [] {this, EventArgs.Empty});
- }
-
- void FireOnSessionStart (HttpSessionState state, object source, EventArgs args)
- {
- // FireEvents ("Session_Start", state, new object [] {source, EventArgs.Empty});
- }
-
- void FireOnSessionEnd (HttpSessionState state, object source, EventArgs args)
- {
- // FireEvents ("Session_End", state, new object [] {source, args});
- }
-
+ FireEvent ("Application_Start", app, args);
+ }
+
+ void FireOnAppEnd ()
+ {
+ if (_appType == null)
+ return; // we didn't even get an application
+
+ HttpApplication app = (HttpApplication) HttpRuntime.CreateInternalObject (_appType);
+ AttachEvents (app);
+ FireEvent ("Application_End", app, new object [] {this, EventArgs.Empty});
+ app.Dispose ();
+ }
+
private void InitializeFactory (HttpContext context)
{
_appFilename = GetAppFilename (context);
diff --git a/mcs/class/System.Web/System.Web/HttpRuntime.cs b/mcs/class/System.Web/System.Web/HttpRuntime.cs
index 9ebbf381c93..da23b53407b 100644
--- a/mcs/class/System.Web/System.Web/HttpRuntime.cs
+++ b/mcs/class/System.Web/System.Web/HttpRuntime.cs
@@ -61,11 +61,10 @@ namespace System.Web {
private int _activeRequests;
private HttpWorkerRequest.EndOfSendNotification _endOfSendCallback;
private AsyncCallback _handlerCallback;
- private WaitCallback _appDomainCallback;
+ private WaitCallback unloadDomainCallback;
private bool _firstRequestStarted;
private bool _firstRequestExecuted;
- private DateTime _firstRequestStartTime;
private Exception _initError;
private TimeoutManager timeoutManager;
@@ -95,9 +94,10 @@ namespace System.Web {
_cache = new Cache ();
timeoutManager = new TimeoutManager ();
- _endOfSendCallback = new HttpWorkerRequest.EndOfSendNotification(OnEndOfSend);
- _handlerCallback = new AsyncCallback(OnHandlerReady);
- _appDomainCallback = new WaitCallback(OnAppDomainUnload);
+ _endOfSendCallback = new HttpWorkerRequest.EndOfSendNotification (OnEndOfSend);
+ _handlerCallback = new AsyncCallback (OnHandlerReady);
+ unloadDomainCallback = new WaitCallback (DoUnload);
+ AppDomain.CurrentDomain.DomainUnload += new EventHandler (OnDomainUnload);
}
catch (Exception error) {
_initError = error;
@@ -238,17 +238,29 @@ namespace System.Web {
_runtime.FinishRequest (context, exception);
}
- private void OnAppDomainUnload(object state) {
- Dispose();
+ void DoUnload (object state)
+ {
+ AppDomain.Unload (AppDomain.CurrentDomain);
}
internal void Dispose() {
- WaitForRequests(5000);
+ WaitForRequests (2000);
queueManager.Dispose (); // Send a 503 to all queued requests
queueManager = null;
_cache = null;
- HttpApplicationFactory.EndApplication();
+ HttpApplicationFactory.EndApplication ();
+ }
+
+ void OnDomainUnload (object o, EventArgs args)
+ {
+ HttpApplicationFactory.EndApplication ();
+ }
+
+ internal void ByeByeDomain ()
+ {
+ HttpApplicationFactory.EndApplication ();
+ ThreadPool.QueueUserWorkItem (unloadDomainCallback);
}
internal void WaitForRequests(int ms) {
@@ -277,7 +289,6 @@ namespace System.Web {
if (!_firstRequestStarted) {
lock (this) {
if (!_firstRequestStarted) {
- _firstRequestStartTime = DateTime.Now;
OnFirstRequestStart(context);
_firstRequestStarted = true;
}
@@ -315,7 +326,7 @@ namespace System.Web {
void TryExecuteQueuedRequests ()
{
// Wait for pending jobs to start
- if (Interlocked.CompareExchange (ref pendingCallbacks, 3, 3) == 3)
+ if (Interlocked.CompareExchange (ref pendingCallbacks, 3, 3) >= 3)
return;
HttpWorkerRequest wr = queueManager.GetNextRequest (null);
@@ -344,10 +355,9 @@ namespace System.Web {
}
#if NET_1_1
- [MonoTODO]
- public void UnloadAppDomain ()
+ public static void UnloadAppDomain ()
{
- throw new NotImplementedException ();
+ _runtime.ByeByeDomain ();
}
#endif
public static Cache Cache {
@@ -444,7 +454,7 @@ namespace System.Web {
public static void Close ()
{
- _runtime.Dispose();
+ _runtime.Dispose ();
}
internal static string FormatResourceString (string key)