Thrift: C++ peek() method and TException not Exception
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@664876 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/cpp/src/server/TThreadPoolServer.cpp b/lib/cpp/src/server/TThreadPoolServer.cpp
index 7885f0f..357152b 100644
--- a/lib/cpp/src/server/TThreadPoolServer.cpp
+++ b/lib/cpp/src/server/TThreadPoolServer.cpp
@@ -8,6 +8,7 @@
namespace facebook { namespace thrift { namespace server {
using namespace std;
+using namespace facebook::thrift;
using namespace facebook::thrift::concurrency;
using namespace facebook::thrift::transport;
@@ -26,14 +27,18 @@
~Task() {}
void run() {
- while(true) {
- try {
- processor_->process(input_, output_);
- } catch (TTransportException& ttx) {
- break;
- } catch(...) {
- break;
+ try {
+ while (processor_->process(input_, output_)) {
+ if (!input_->getInputTransport()->peek()) {
+ break;
+ }
}
+ } catch (TTransportException& ttx) {
+ cerr << "TThreadPoolServer client died: " << ttx.what() << endl;
+ } catch (TException& x) {
+ cerr << "TThreadPoolServer exception: " << x.what() << endl;
+ } catch (...) {
+ cerr << "TThreadPoolServer uncaught exception." << endl;
}
input_->getInputTransport()->close();
output_->getOutputTransport()->close();
@@ -68,7 +73,7 @@
// Start the server listening
serverTransport_->listen();
} catch (TTransportException& ttx) {
- cerr << "TThreadPoolServer::run() listen(): " << ttx.getMessage() << endl;
+ cerr << "TThreadPoolServer::run() listen(): " << ttx.what() << endl;
return;
}