Github user jeking3 commented on a diff in the pull request:

    https://github.com/apache/thrift/pull/977#discussion_r58481087
  
    --- Diff: lib/cpp/src/thrift/server/TThreadedServer.cpp ---
    @@ -77,44 +83,29 @@ TThreadedServer::TThreadedServer(const 
shared_ptr<TProcessor>& processor,
                                      const shared_ptr<TProtocolFactory>& 
inputProtocolFactory,
                                      const shared_ptr<TProtocolFactory>& 
outputProtocolFactory,
                                      const shared_ptr<ThreadFactory>& 
threadFactory)
    -  : TServerFramework(processor,
    -                     serverTransport,
    -                     inputTransportFactory,
    -                     outputTransportFactory,
    -                     inputProtocolFactory,
    -                     outputProtocolFactory),
    -    threadFactory_(threadFactory) {
    +  : TThreadPoolServer(processor,
    +                      serverTransport,
    +                      inputTransportFactory,
    +                      outputTransportFactory,
    +                      inputProtocolFactory,
    +                      outputProtocolFactory,
    +                      
apache::thrift::concurrency::ThreadManager::newSimpleThreadManager(0, 0)) {
    +    threadManager_->threadFactory(threadFactory);
    +    threadManager_->start();
     }
     
     TThreadedServer::~TThreadedServer() {
     }
     
    -void TThreadedServer::serve() {
    -  TServerFramework::serve();
    -
    -  // Drain all clients - no more will arrive
    -  try {
    -    Synchronized s(clientsMonitor_);
    -    while (getConcurrentClientCount() > 0) {
    -      clientsMonitor_.wait();
    -    }
    -  } catch (TException& tx) {
    -    string errStr = string("TThreadedServer: Exception joining workers: ") 
+ tx.what();
    -    GlobalOutput(errStr.c_str());
    +void TThreadedServer::onClientConnected(const 
shared_ptr<TConnectedClient>& pClient) {
    +  if (!threadManager_->idleWorkerCount())
    --- End diff --
    
    As submitted the number of threads will grow to the maximum number of 
concurrent connections and will not shrink.  Additional work is needed to allow 
ThreadManager::removeWorker() to do the right thing when many threads arrive at 
it at the same time.  In gdb I found that workerCount_ was 10 but 
workerMaxCount_ was 0; the stop behavior for ThreadManager calls 
removeWorker(workerCount_) and gets an exception, which eventually causes a 
core.  This is why, for this submission, I left it as stated.  


---
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.
---

Reply via email to