-- Servers should not crash on accept.

Summary:
- Continue running if there is an accept issue

Reviewed By: slee


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@664988 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/cpp/src/server/TSimpleServer.cpp b/lib/cpp/src/server/TSimpleServer.cpp
index 1e7e7fb..f7e2673 100644
--- a/lib/cpp/src/server/TSimpleServer.cpp
+++ b/lib/cpp/src/server/TSimpleServer.cpp
@@ -28,8 +28,8 @@
   }
 
   // Fetch client from server
-  try {
-    while (true) {
+  while (true) {
+    try {
       client = serverTransport_->accept();
       inputTransport = inputTransportFactory_->getTransport(client);
       outputTransport = outputTransportFactory_->getTransport(client);
@@ -49,12 +49,26 @@
       }
       inputTransport->close();
       outputTransport->close();
+      client->close();    
+    } catch (TTransportException& ttx) {
+      inputTransport->close();
+      outputTransport->close();
       client->close();
+      cerr << "TServerTransport died on accept: " << ttx.what() << endl;
+      continue;
+    } catch (TException& tx) {
+      inputTransport->close();
+      outputTransport->close();
+      client->close();
+      cerr << "Some kind of accept exception: " << tx.what() << endl;
+      continue;
+    } catch (string s) {
+      inputTransport->close();
+      outputTransport->close();
+      client->close();
+      cerr << "TThreadPoolServer: Unknown exception: " << s << endl;
+      break;
     }
-  } catch (TTransportException& ttx) {
-    cerr << "TServerTransport died on accept: " << ttx.what() << endl;
-  } catch (TException& tx) {
-    cerr << "Some kind of accept exception: " << tx.what() << endl;
   }
 
   // TODO(mcslee): Could this be a timeout case? Or always the real thing?