You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by jrckkyy <jr...@gmail.com> on 2011/09/22 03:59:08 UTC

thirft server accept thread can stop, but work threads cann't stop [hidden BUG?]

hello everyone:

      I have one question, it's possible my fault ! my thirft server accept
thread can stop, but work threads cann't stop.

my server code A:

shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory());
 shared_ptr<DNSServerHandler> handler(new DNSServerHandler());
 shared_ptr<TProcessor> processor(new DNSServerProcessor(handler));
 serverTransport = shared_ptr<TServerTransport>(new
TServerSocket(listenPort));
 shared_ptr<TTransportFactory> transportFactory(new
TBufferedTransportFactory());
  threadManager = ThreadManager::newSimpleThreadManager(n);
  shared_ptr<PosixThreadFactory> threadFactory =
shared_ptr<PosixThreadFactory>(new PosixThreadFactory());
  threadManager->threadFactory(threadFactory);
  threadManager->start();
  server = new TThreadPoolServer(processor,
  serverTransport,
  transportFactory,
  protocolFactory,
  threadManager);

 fprintf( stdout, "Starting the server listenPort : %d workerCount :
%d...\n", listenPort, workerCount );

 server->serve(); // block here

server run A code

and now client run code B:

shared_ptr<TTransport> socket(new TSocket("localhost", 8002));
 shared_ptr<TTransport> transport(new TBufferedTransport(socket));
 shared_ptr<TProtocol> protocol(new TBinaryProtocol(transport));
 DNSServerClient client(protocol);
while(true)
 {
...
client.sendData( dataResponsePack, dataRequestPack );
...
}

client not exe transport->close(); , client long connet to server, client
have n connet threads .

now server run code C:
server->stop();
serverTransport->close();

the issue go out ,server not accept another client open , but already build
long connet with client not release(if client not exe
transport->close(); server always
block at  server->serve(); and client can continue exe client.sendData ,server
have thread process this data from client and return to client. server
process thread it not stop!!!), I want shutdown both socket fd when i
exe  server->stop();
it not correct run

what can i do ? it is a bug?


file TThreadPoolServer.h at line:62:

  virtual void stop() {
    stop_ = true;
    serverTransport_->interrupt();
  }

it not correct work.


--                jrckkyy

此致
       敬礼!