Index: HttpContext.cs =================================================================== RCS file: /cvs/public/mcs/class/System.Web/System.Web/HttpContext.cs,v retrieving revision 1.31 diff -u -r1.31 HttpContext.cs --- HttpContext.cs 30 Sep 2004 01:00:32 -0000 1.31 +++ HttpContext.cs 4 Oct 2004 22:30:52 -0000 @@ -59,7 +59,7 @@ private bool _skipauth; private Hashtable _oItems; private DateTime _oTimestamp; - int timeoutPossible; + volatile bool timeoutPossible; long timeoutBegin; object configTimeout; string errorPage; @@ -281,29 +281,31 @@ } internal bool TimeoutPossible { - get { return (Interlocked.CompareExchange (ref timeoutPossible, 1, 1) == 1); } + get { return timeoutPossible; } } internal void BeginTimeoutPossible () { - timeoutPossible = 1; + timeoutPossible = true; timeoutBegin = DateTime.UtcNow.Ticks; } internal void EndTimeoutPossible () { - Interlocked.CompareExchange (ref timeoutPossible, 0, 1); + timeoutPossible = false; } internal void TryWaitForTimeout () { - while (Interlocked.CompareExchange (ref timeoutPossible, 1, 1) == 1) { + while (TimeoutPossible) Thread.Sleep (500); - } } internal bool CheckIfTimeout (DateTime dt) { + if (!TimeoutPossible) + return false; + TimeSpan ts = new TimeSpan (dt.Ticks - timeoutBegin); return (ts > ConfigTimeout); } Index: HttpApplication.cs =================================================================== RCS file: /cvs/public/mcs/class/System.Web/System.Web/HttpApplication.cs,v retrieving revision 1.41 diff -u -r1.41 HttpApplication.cs --- HttpApplication.cs 25 Sep 2004 14:47:34 -0000 1.41 +++ HttpApplication.cs 4 Oct 2004 22:30:53 -0000 @@ -639,10 +639,10 @@ { bool ready_sync = false; IStateHandler handler; - bool timeoutPossible = false; lock (_app) { _app.OnStateExecuteEnter (); + HttpRuntime.TimeoutManager.Add (_app.Context); try { do { if (null != lasterror) { @@ -663,25 +663,17 @@ handler = _handlers [_currentStateIdx]; _countSteps++; - timeoutPossible = handler.PossibleToTimeout; - try { - if (timeoutPossible) - HttpRuntime.TimeoutManager.Add (_app.Context); - - lasterror = ExecuteState (handler, ref ready_sync); - if (ready_sync) - _countSyncSteps++; - } finally { - if (timeoutPossible) - HttpRuntime.TimeoutManager.Remove (_app.Context); - } + + lasterror = ExecuteState (handler, ref ready_sync); + if (ready_sync) + _countSyncSteps++; + } while (ready_sync && _currentStateIdx < _endStateIdx); if (null != lasterror) _app.HandleError (lasterror); } finally { - - + HttpRuntime.TimeoutManager.Remove (_app.Context); _app.OnStateExecuteLeave (); } }