#define _THRIFT_CONCURRENCY_EXCEPTION_H_ 1
#include <exception>
+#include <Thrift.h>
namespace facebook { namespace thrift { namespace concurrency {
-class NoSuchTaskException : public std::exception {};
+class NoSuchTaskException : public facebook::thrift::TException {};
-class UncancellableTaskException : public std::exception {};
+class UncancellableTaskException : public facebook::thrift::TException {};
-class InvalidArgumentException : public std::exception {};
+class InvalidArgumentException : public facebook::thrift::TException {};
-class IllegalStateException : public std::exception {};
+class IllegalStateException : public facebook::thrift::TException {};
-class TimedOutException : public std::exception {};
+class TimedOutException : public facebook::thrift::TException {};
}}} // facebook::thrift::concurrency
}
// Fetch client from server
- try {
- while (true) {
+ while (true) {
+ try {
client = serverTransport_->accept();
inputTransport = inputTransportFactory_->getTransport(client);
outputTransport = outputTransportFactory_->getTransport(client);
} catch (TException& tx) {
cerr << "TSimpleServer exception: " << tx.what() << endl;
}
+ 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?
outputProtocol = outputProtocolFactory_->getProtocol(outputTransport);
// Add to threadmanager pool
- threadManager_->add(shared_ptr<TThreadPoolServer::Task>(new TThreadPoolServer::Task(processor_, inputProtocol, outputProtocol)));
+ threadManager_->add(shared_ptr<TThreadPoolServer::Task>(new TThreadPoolServer::Task(processor_,
+ inputProtocol,
+ outputProtocol)));
} catch (TTransportException& ttx) {
+ inputTransport->close();
+ outputTransport->close();
+ client->close();
+ cerr << "TThreadPoolServer: TServerTransport died on accept: " << ttx.what() << endl;
+ continue;
+ } catch (TException& tx) {
+ inputTransport->close();
+ outputTransport->close();
+ client->close();
+ cerr << "TThreadPoolServer: Caught TException: " << tx.what() << endl;
+ continue;
+ } catch (string s) {
+ inputTransport->close();
+ outputTransport->close();
+ client->close();
+ cerr << "TThreadPoolServer: Unknown exception: " << s << endl;
break;
}
}