} catch (TTransportException& ttx) {
// This is reasonably expected, client didn't send a full request so just
// ignore him
- //cerr << "TThreadPoolServer client died: " << ttx.what() << endl;
+ // string errStr = string("TThreadPoolServer client died: ") + ttx.what();
+ // GlobalOutput(errStr.c_str());
} catch (TException& x) {
- cerr << "TThreadPoolServer exception: " << x.what() << endl;
+ string errStr = string("TThreadPoolServer exception: ") + x.what();
+ GlobalOutput(errStr.c_str());
} catch (std::exception &x) {
- cerr << "TThreadPoolServer, std::exception: " << x.what() << endl;
+ string errStr = string("TThreadPoolServer, std::exception: ") + x.what();
+ GlobalOutput(errStr.c_str());
}
if (eventHandler != NULL) {
eventHandler->clientEnd(input_, output_);
}
- input_->getTransport()->close();
- output_->getTransport()->close();
+
+ try {
+ input_->getTransport()->close();
+ } catch (TTransportException& ttx) {
+ string errStr = string("TThreadPoolServer input close failed: ") + ttx.what();
+ GlobalOutput(errStr.c_str());
+ }
+ try {
+ output_->getTransport()->close();
+ } catch (TTransportException& ttx) {
+ string errStr = string("TThreadPoolServer output close failed: ") + ttx.what();
+ GlobalOutput(errStr.c_str());
+ }
+
}
private:
// Start the server listening
serverTransport_->listen();
} catch (TTransportException& ttx) {
- cerr << "TThreadPoolServer::run() listen(): " << ttx.what() << endl;
+ string errStr = string("TThreadPoolServer::run() listen(): ") + ttx.what();
+ GlobalOutput(errStr.c_str());
return;
}
if (outputTransport != NULL) { outputTransport->close(); }
if (client != NULL) { client->close(); }
if (!stop_ || ttx.getType() != TTransportException::INTERRUPTED) {
- cerr << "TThreadPoolServer: TServerTransport died on accept: " << ttx.what() << endl;
+ string errStr = string("TThreadPoolServer: TServerTransport died on accept: ") + ttx.what();
+ GlobalOutput(errStr.c_str());
}
continue;
} catch (TException& tx) {
if (inputTransport != NULL) { inputTransport->close(); }
if (outputTransport != NULL) { outputTransport->close(); }
if (client != NULL) { client->close(); }
- cerr << "TThreadPoolServer: Caught TException: " << tx.what() << endl;
+ string errStr = string("TThreadPoolServer: Caught TException: ") + tx.what();
+ GlobalOutput(errStr.c_str());
continue;
} catch (string s) {
if (inputTransport != NULL) { inputTransport->close(); }
if (outputTransport != NULL) { outputTransport->close(); }
if (client != NULL) { client->close(); }
- cerr << "TThreadPoolServer: Unknown exception: " << s << endl;
+ string errStr = "TThreadPoolServer: Unknown exception: " + s;
+ GlobalOutput(errStr.c_str());
break;
}
}
serverTransport_->close();
threadManager_->join();
} catch (TException &tx) {
- cerr << "TThreadPoolServer: Exception shutting down: " << tx.what() << endl;
+ string errStr = string("TThreadPoolServer: Exception shutting down: ") + tx.what();
+ GlobalOutput(errStr.c_str());
}
stop_ = false;
}
}
}
} catch (TTransportException& ttx) {
- cerr << "TThreadedServer client died: " << ttx.what() << endl;
+ string errStr = string("TThreadedServer client died: ") + ttx.what();
+ GlobalOutput(errStr.c_str());
} catch (TException& x) {
- cerr << "TThreadedServer exception: " << x.what() << endl;
+ string errStr = string("TThreadedServer exception: ") + x.what();
+ GlobalOutput(errStr.c_str());
} catch (...) {
- cerr << "TThreadedServer uncaught exception." << endl;
+ GlobalOutput("TThreadedServer uncaught exception.");
}
if (eventHandler != NULL) {
eventHandler->clientEnd(input_, output_);
}
- input_->getTransport()->close();
- output_->getTransport()->close();
+
+ try {
+ input_->getTransport()->close();
+ } catch (TTransportException& ttx) {
+ string errStr = string("TThreadedServer input close failed: ") + ttx.what();
+ GlobalOutput(errStr.c_str());
+ }
+ try {
+ output_->getTransport()->close();
+ } catch (TTransportException& ttx) {
+ string errStr = string("TThreadedServer output close failed: ") + ttx.what();
+ GlobalOutput(errStr.c_str());
+ }
// Remove this task from parent bookkeeping
{
// Start the server listening
serverTransport_->listen();
} catch (TTransportException& ttx) {
- cerr << "TThreadedServer::run() listen(): " << ttx.what() << endl;
+ string errStr = string("TThreadedServer::run() listen(): ") +ttx.what();
+ GlobalOutput(errStr.c_str());
return;
}
if (outputTransport != NULL) { outputTransport->close(); }
if (client != NULL) { client->close(); }
if (!stop_ || ttx.getType() != TTransportException::INTERRUPTED) {
- cerr << "TThreadedServer: TServerTransport died on accept: " << ttx.what() << endl;
+ string errStr = string("TThreadedServer: TServerTransport died on accept: ") + ttx.what();
+ GlobalOutput(errStr.c_str());
}
continue;
} catch (TException& tx) {
if (inputTransport != NULL) { inputTransport->close(); }
if (outputTransport != NULL) { outputTransport->close(); }
if (client != NULL) { client->close(); }
- cerr << "TThreadedServer: Caught TException: " << tx.what() << endl;
+ string errStr = string("TThreadedServer: Caught TException: ") + tx.what();
+ GlobalOutput(errStr.c_str());
continue;
} catch (string s) {
if (inputTransport != NULL) { inputTransport->close(); }
if (outputTransport != NULL) { outputTransport->close(); }
if (client != NULL) { client->close(); }
- cerr << "TThreadedServer: Unknown exception: " << s << endl;
+ string errStr = "TThreadedServer: Unknown exception: " + s;
+ GlobalOutput(errStr.c_str());
break;
}
}
try {
serverTransport_->close();
} catch (TException &tx) {
- cerr << "TThreadedServer: Exception shutting down: " << tx.what() << endl;
+ string errStr = string("TThreadedServer: Exception shutting down: ") + tx.what();
+ GlobalOutput(errStr.c_str());
}
try {
Synchronized s(tasksMonitor_);
tasksMonitor_.wait();
}
} catch (TException &tx) {
- cerr << "TThreadedServer: Exception joining workers: " << tx.what() << endl;
+ string errStr = string("TThreadedServer: Exception joining workers: ") + tx.what();
+ GlobalOutput(errStr.c_str());
}
stop_ = false;
}