If someone is currently connected to a TThreadedServer, then the server will not exit. You may want to try TNonblockingServer. I think that one is able to successfully close if a connection is still outstanding.
Roger Meier <[email protected]> wrote on 01/11/2015 07:55:36 AM: > From: Roger Meier <[email protected]> > To: [email protected], Denis Samoilov <[email protected]>, > Date: 01/11/2015 08:00 AM > Subject: Re: thrift server - hang on exit (thrift 0.9.1) > > Have you tested with 0.9.2 and master branch? > > Quoting Denis Samoilov <[email protected]>: > > > hi, > > Today we found that one of the servers hang on exit: > > > > [Switching to thread 2 (Thread 0x7f3e70dd5700 (LWP 11877))]#0 > > 0x00007f3e70a22b5c in recv () from /lib64/libpthread.so.0 > > > > (gdb) where > > > > #0 0x00007f3e70a22b5c in recv () from /lib64/libpthread.so.0 > > > > #1 0x00000000004a4557 in apache::thrift::transport::TSocket::peek() () > > > > #2 0x00000000004ac2af in > > apache::thrift::server::TThreadedServer::Task::run() () > > > > #3 0x00000000004ad601 in > > apache::thrift::concurrency::PthreadThread::threadMain(void*) () > > > > #4 0x00007f3e70a1b9d1 in start_thread () from /lib64/libpthread.so.0 > > > > #5 0x00007f3e6ffc886d in clone () from /lib64/libc.so.6 > > > > (gdb) thread 1 > > > > [Switching to thread 1 (Thread 0x7f3e70e41720 (LWP 26997))]#0 > > 0x00007f3e70a1f5bc in pthread_cond_wait@@GLIBC_2.3.2 () > > > > from /lib64/libpthread.so.0 > > > > (gdb) where > > > > #0 0x00007f3e70a1f5bc in pthread_cond_wait@@GLIBC_2.3.2 () from > > /lib64/libpthread.so.0 > > > > #1 0x00000000004acf37 in apache::thrift::concurrency::Monitor::wait(long) > > const () > > > > #2 0x00000000004aa18a in apache::thrift::server::TThreadedServer::serve() > > () > > > > #3 0x0000000000489c1c in CacheProxyApp::runThiftServer() () > > > > #4 0x000000000048a990 in CacheProxyApp::run(BoxConfig&, > > std::shared_ptr<PersistentStore>, DaemonPidHelper*) () > > > > #5 0x0000000000452098 in main () > > > > (gdb) quit > > > > > > we use the following simple setup (without explicit setting timeouts). With > > thrift clients we learnt hard way that timeouts must be set :). Do you have > > a suggestion here? > > > > shared_ptr<CacheProxyHandler> proxyhandler(new > > CacheProxyHandler(_configManager.get(), _reportIssueService.get())); > > shared_ptr<TProcessor> processor(new CacheProxyProcessor(proxyhandler)); > > TServerSocket *servsocket = new TServerSocket(_port); > > shared_ptr<TServerTransport> serverTransport(servsocket); > > shared_ptr<TTransportFactory> transportFactory(new > > TFramedTransportFactory()); > > shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory()); > > > > _thriftServer.reset(new TThreadedServer(processor, serverTransport, > > transportFactory, protocolFactory)); > > > > // this blocks until server shutdown > > _thriftServer->serve(); > > > > > > Thank you! > >
