Repository: thrift
Updated Branches:
  refs/heads/master df3223c85 -> d4fa706dc


THRIFT-4160: Fix use closed(freed) connections in non-blocking server
Client: cpp

When failing to add tasks into the thread manager, we close the
corresponding connections, then set the flags of these connections,
which have been already freed.

We should decrease the number of active processors.

This closes #1211


Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/d4fa706d
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/d4fa706d
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/d4fa706d

Branch: refs/heads/master
Commit: d4fa706dcab91f85153f4243eaa28eb604df1290
Parents: df3223c
Author: Changli Gao <[email protected]>
Authored: Fri Mar 10 13:25:43 2017 +0800
Committer: James E. King, III <[email protected]>
Committed: Sun Apr 2 23:24:54 2017 -0400

----------------------------------------------------------------------
 lib/cpp/src/thrift/server/TNonblockingServer.cpp | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/thrift/blob/d4fa706d/lib/cpp/src/thrift/server/TNonblockingServer.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/server/TNonblockingServer.cpp 
b/lib/cpp/src/thrift/server/TNonblockingServer.cpp
index 2cf64f8..c03327d 100644
--- a/lib/cpp/src/thrift/server/TNonblockingServer.cpp
+++ b/lib/cpp/src/thrift/server/TNonblockingServer.cpp
@@ -591,21 +591,24 @@ void TNonblockingServer::TConnection::transition() {
       // The application is now waiting on the task to finish
       appState_ = APP_WAIT_TASK;
 
+      // Set this connection idle so that libevent doesn't process more
+      // data on it while we're still waiting for the threadmanager to
+      // finish this task
+      setIdle();
+
       try {
         server_->addTask(task);
       } catch (IllegalStateException& ise) {
         // The ThreadManager is not ready to handle any more tasks (it's 
probably shutting down).
         GlobalOutput.printf("IllegalStateException: Server::process() %s", 
ise.what());
+        server_->decrementActiveProcessors();
         close();
       } catch (TimedOutException& to) {
         GlobalOutput.printf("[ERROR] TimedOutException: Server::process() %s", 
to.what());
+        server_->decrementActiveProcessors();
         close();
       }
 
-      // Set this connection idle so that libevent doesn't process more
-      // data on it while we're still waiting for the threadmanager to
-      // finish this task
-      setIdle();
       return;
     } else {
       try {

Reply via email to