You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by jk...@apache.org on 2016/11/14 17:40:34 UTC
thrift git commit: THRIFT-3955 TThreadedServer Memory Leak Client:
C++ Patch: tzongw@gmail.com
Repository: thrift
Updated Branches:
refs/heads/master 220d5f842 -> 4337983d1
THRIFT-3955 TThreadedServer Memory Leak
Client: C++
Patch: tzongw@gmail.com
This closes #1117
Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/4337983d
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/4337983d
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/4337983d
Branch: refs/heads/master
Commit: 4337983d157dd7041c17340107682f26d2c0c795
Parents: 220d5f8
Author: James E. King, III <jk...@apache.org>
Authored: Mon Nov 14 12:39:33 2016 -0500
Committer: James E. King, III <jk...@apache.org>
Committed: Mon Nov 14 12:39:33 2016 -0500
----------------------------------------------------------------------
lib/cpp/src/thrift/server/TThreadedServer.cpp | 16 ++++------------
lib/cpp/src/thrift/server/TThreadedServer.h | 5 +----
2 files changed, 5 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/thrift/blob/4337983d/lib/cpp/src/thrift/server/TThreadedServer.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/server/TThreadedServer.cpp b/lib/cpp/src/thrift/server/TThreadedServer.cpp
index 9de1db8..c413be1 100644
--- a/lib/cpp/src/thrift/server/TThreadedServer.cpp
+++ b/lib/cpp/src/thrift/server/TThreadedServer.cpp
@@ -117,9 +117,10 @@ void TThreadedServer::drainDeadClients() {
void TThreadedServer::onClientConnected(const shared_ptr<TConnectedClient>& pClient) {
Synchronized sync(clientMonitor_);
- ClientMap::iterator it = activeClientMap_.insert(ClientMap::value_type(pClient.get(), boost::make_shared<TConnectedClientRunner>(pClient))).first;
- boost::shared_ptr<apache::thrift::concurrency::Thread> pThread = threadFactory_->newThread(it->second);
- it->second->setThread(pThread);
+ boost::shared_ptr<TConnectedClientRunner> pRunnable = boost::make_shared<TConnectedClientRunner>(pClient);
+ boost::shared_ptr<Thread> pThread = threadFactory_->newThread(pRunnable);
+ pRunnable->thread(pThread);
+ activeClientMap_.insert(ClientMap::value_type(pClient.get(), pThread));
pThread->start();
}
@@ -142,20 +143,11 @@ TThreadedServer::TConnectedClientRunner::TConnectedClientRunner(const boost::sha
TThreadedServer::TConnectedClientRunner::~TConnectedClientRunner() {
}
-void TThreadedServer::TConnectedClientRunner::join() {
- pThread_->join();
-}
-
void TThreadedServer::TConnectedClientRunner::run() /* override */ {
pClient_->run(); // Run the client
pClient_.reset(); // The client is done - release it here rather than in the destructor for safety
}
-void TThreadedServer::TConnectedClientRunner::setThread(
- const boost::shared_ptr<apache::thrift::concurrency::Thread>& pThread) {
- pThread_ = pThread;
-}
-
}
}
} // apache::thrift::server
http://git-wip-us.apache.org/repos/asf/thrift/blob/4337983d/lib/cpp/src/thrift/server/TThreadedServer.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/server/TThreadedServer.h b/lib/cpp/src/thrift/server/TThreadedServer.h
index 758d1d9..56da901 100644
--- a/lib/cpp/src/thrift/server/TThreadedServer.h
+++ b/lib/cpp/src/thrift/server/TThreadedServer.h
@@ -116,17 +116,14 @@ protected:
public:
TConnectedClientRunner(const boost::shared_ptr<TConnectedClient>& pClient);
virtual ~TConnectedClientRunner();
- void join();
void run() /* override */;
- void setThread(const boost::shared_ptr<apache::thrift::concurrency::Thread>& pThread);
private:
boost::shared_ptr<TConnectedClient> pClient_;
- boost::shared_ptr<apache::thrift::concurrency::Thread> pThread_;
};
apache::thrift::concurrency::Monitor clientMonitor_;
- typedef std::map<TConnectedClient *, boost::shared_ptr<TConnectedClientRunner> > ClientMap;
+ typedef std::map<TConnectedClient *, boost::shared_ptr<apache::thrift::concurrency::Thread> > ClientMap;
/**
* A map of active clients