summaryrefslogtreecommitdiff
path: root/csharp/src/Ice/ConnectRequestHandler.cs
diff options
context:
space:
mode:
Diffstat (limited to 'csharp/src/Ice/ConnectRequestHandler.cs')
-rw-r--r--csharp/src/Ice/ConnectRequestHandler.cs25
1 files changed, 15 insertions, 10 deletions
diff --git a/csharp/src/Ice/ConnectRequestHandler.cs b/csharp/src/Ice/ConnectRequestHandler.cs
index a03a6adb02c..4378f1761dc 100644
--- a/csharp/src/Ice/ConnectRequestHandler.cs
+++ b/csharp/src/Ice/ConnectRequestHandler.cs
@@ -109,7 +109,7 @@ namespace IceInternal
{
lock(this)
{
- Debug.Assert(_exception == null && _connection == null);
+ Debug.Assert(!_flushing && _exception == null && _connection == null);
_connection = connection;
_compress = compress;
}
@@ -134,18 +134,15 @@ namespace IceInternal
{
lock(this)
{
- Debug.Assert(!_initialized && _exception == null);
+ Debug.Assert(!_flushing && !_initialized && _exception == null);
_exception = ex;
- _proxies.Clear();
- _proxy = null; // Break cyclic reference count.
- Monitor.PulseAll(this);
+ _flushing = true; // Ensures request handler is removed before processing new requests.
}
//
- // NOTE: remove the request handler *before* notifying the
- // requests that the connection failed. It's important to ensure
- // that future invocations will obtain a new connect request
- // handler once invocations are notified.
+ // NOTE: remove the request handler *before* notifying the requests that the connection
+ // failed. It's important to ensure that future invocations will obtain a new connect
+ // request handler once invocations are notified.
//
try
{
@@ -164,6 +161,14 @@ namespace IceInternal
}
}
_requests.Clear();
+
+ lock(this)
+ {
+ _flushing = false;
+ _proxies.Clear();
+ _proxy = null; // Break cyclic reference count.
+ Monitor.PulseAll(this);
+ }
}
//
@@ -197,7 +202,7 @@ namespace IceInternal
}
else
{
- while(_flushing && _exception == null)
+ while(_flushing)
{
Monitor.Wait(this);
}