Add Stop methods for C# servers.
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665538 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/csharp/src/Server/TThreadPoolServer.cs b/lib/csharp/src/Server/TThreadPoolServer.cs
index b62de81..f8ee355 100644
--- a/lib/csharp/src/Server/TThreadPoolServer.cs
+++ b/lib/csharp/src/Server/TThreadPoolServer.cs
@@ -25,6 +25,7 @@
{
private const int DEFAULT_MIN_THREADS = 10;
private const int DEFAULT_MAX_THREADS = 100;
+ private volatile bool stop = false;
public TThreadPoolServer(TProcessor processor, TServerTransport serverTransport)
:this(processor, serverTransport,
@@ -81,7 +82,7 @@
return;
}
- while (true)
+ while (!stop)
{
int failureCount = 0;
try
@@ -95,6 +96,25 @@
Console.Error.WriteLine(ttx);
}
}
+
+ if (stop)
+ {
+ try
+ {
+ serverTransport.Close();
+ }
+ catch (TTransportException ttx)
+ {
+ Console.Error.WriteLine("TServerTrasnport failed on close: " + ttx.Message);
+ }
+ stop = false;
+ }
+ }
+
+
+ public override void Stop()
+ {
+ stop = true;
}
/// <summary>