Github user jeking3 commented on a diff in the pull request: https://github.com/apache/thrift/pull/980#discussion_r59410629 --- Diff: lib/cpp/src/thrift/server/TThreadedServer.h --- @@ -83,12 +88,56 @@ class TThreadedServer : public TServerFramework { virtual void serve(); protected: + /** + * Drain recently connected clients by joining their threads - this is done lazily because + * we cannot do it inside the thread context that is disconnecting. + */ + virtual void drainDeadClients(); + + /** + * Implementation of TServerFramework::onClientConnected + */ virtual void onClientConnected(const boost::shared_ptr<TConnectedClient>& pClient) /* override */; - virtual void onClientDisconnected(TConnectedClient* pClient) /* override */; + + /** + * Implementation of TServerFramework::onClientDisconnected + */ + virtual void onClientDisconnected(TConnectedClient *pClient) /* override */; boost::shared_ptr<apache::thrift::concurrency::ThreadFactory> threadFactory_; - apache::thrift::concurrency::Monitor clientsMonitor_; + + /** + * A helper wrapper used to wrap the client in something we can use to maintain + * the lifetime of the connected client within a detached thread. --- End diff -- This busted StressTest and StressTestNonBlocking because they are coded to assume that the thread shared pointer will hold on to the runnable after the thread is gone. The TConnectedClientTracker is therefore necessary to avoid breaking existing clients that might depend on this behavior of Thread, so I am not going to simplify to a map of TConnectedClient* to shared_ptr<Thread>.
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---