summaryrefslogtreecommitdiff
path: root/lib/cpp/src/thrift/server/TNonblockingServer.cpp
diff options
context:
space:
mode:
authorJens Geyer <jensg@apache.org>2014-12-04 21:49:07 +0100
committerJens Geyer <jensg@apache.org>2014-12-04 21:52:28 +0100
commitfb05cf67db2d9515186acb94aa41160d2a1281fc (patch)
treef5ad7b44dd4dedeb391d2f9788df5540b845fe0e /lib/cpp/src/thrift/server/TNonblockingServer.cpp
parent78c57e1720995821d80009dd99698b3a34f52e93 (diff)
downloadthrift-fb05cf67db2d9515186acb94aa41160d2a1281fc.tar.gz
THRIFT-2789 TNonblockingServer leaks socket FD's under load
Client: C++ Patch: Sergey <drigh@deviantart.com> and Qiao Mu <qiaomuf@gmail.com>
Diffstat (limited to 'lib/cpp/src/thrift/server/TNonblockingServer.cpp')
-rw-r--r--lib/cpp/src/thrift/server/TNonblockingServer.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/cpp/src/thrift/server/TNonblockingServer.cpp b/lib/cpp/src/thrift/server/TNonblockingServer.cpp
index 1cfdef8fa..9833f10e3 100644
--- a/lib/cpp/src/thrift/server/TNonblockingServer.cpp
+++ b/lib/cpp/src/thrift/server/TNonblockingServer.cpp
@@ -283,6 +283,7 @@ public:
void forceClose() {
appState_ = APP_CLOSE_CONNECTION;
if (!notifyIOThread()) {
+ close();
throw TException("TConnection::forceClose: failed write on notify pipe");
}
}
@@ -342,6 +343,8 @@ public:
// Signal completion back to the libevent thread via a pipe
if (!connection_->notifyIOThread()) {
+ GlobalOutput.printf("TNonblockingServer: failed to notifyIOThread, closing.");
+ connection_->close();
throw TException("TNonblockingServer::Task::run: failed write on notify pipe");
}
}
@@ -568,6 +571,9 @@ void TNonblockingServer::TConnection::transition() {
// The ThreadManager is not ready to handle any more tasks (it's probably shutting down).
GlobalOutput.printf("IllegalStateException: Server::process() %s", ise.what());
close();
+ } catch (TimedOutException& to) {
+ GlobalOutput.printf("[ERROR] TimedOutException: Server::process() %s", to.what());
+ close();
}
// Set this connection idle so that libevent doesn't process more
@@ -969,7 +975,10 @@ void TNonblockingServer::handleEvent(THRIFT_SOCKET fd, short which) {
if (clientConnection->getIOThreadNumber() == 0) {
clientConnection->transition();
} else {
- clientConnection->notifyIOThread();
+ if (!clientConnection->notifyIOThread()) {
+ GlobalOutput.perror("[ERROR] notifyIOThread failed on fresh connection, closing", errno);
+ returnConnection(clientConnection);
+ }
}
// addrLen is written by the accept() call, so needs to be set before the next call.