summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CSharp/Ivy/IvyPPC/Ivy.cs25
1 files changed, 20 insertions, 5 deletions
diff --git a/CSharp/Ivy/IvyPPC/Ivy.cs b/CSharp/Ivy/IvyPPC/Ivy.cs
index 60c3ff4..56aa68c 100644
--- a/CSharp/Ivy/IvyPPC/Ivy.cs
+++ b/CSharp/Ivy/IvyPPC/Ivy.cs
@@ -56,6 +56,10 @@ namespace IvyBus
{
return debug;
}
+ set
+ {
+ debug = value;
+ }
}
/// <summary>ClientNames accesses the name list of the connected clients</summary>
@@ -137,7 +141,7 @@ namespace IvyBus
{
callbacks = new Hashtable();
clients = Hashtable.Synchronized( new Hashtable() );
- regexp_out = new Hashtable();
+ regexp_out = Hashtable.Synchronized( new Hashtable());
appName = name;
ready_message = message;
String debug_str = ConfigurationSettings.AppSettings["IVY_DEBUG"];
@@ -249,14 +253,19 @@ namespace IvyBus
((IvyWatcher) watchers[i]).stop();
}
// stopping the remaining IvyClients
+ // copy the values in temporary variable to eliminate Thread modifying collection
+ IvyClient[] copyClient;
+ copyClient = new IvyClient[clients.Count];
lock( clients.SyncRoot )
{
- foreach (IvyClient c in clients.Values )
+ clients.Values.CopyTo( copyClient,0 );
+ }
+ foreach (IvyClient client in copyClient )
{
- c.close(true); // will notify the reading thread
- //removeClient(c); already donne in the thread
+ client.close(true); // will notify the reading thread
+ //removeClient(client); already donne in the thread
}
- }
+
}
catch (IOException e)
{
@@ -594,6 +603,12 @@ namespace IvyBus
Console.Out.WriteLine("Ivy server socket reader caught an exception " + e.Message);
// e.printStackTrace();
}
+ catch (ThreadInterruptedException te)
+ {
+ Console.Error.WriteLine( te.Message );
+ Console.Error.WriteLine( te.StackTrace);
+ running = false;
+ }
catch (SocketException e)
{
traceDebug("my server socket has been closed");