3

我有一个用 C++ 编写的非阻塞多线程节俭服务器和一个用 python 编写的节俭客户端。下面的代码片段简要展示了如何在 C++ 服务器和 python 客户端中完成节俭协议和绑定配置。

我的问题是,当 python 客户端通过 thrift 调用 C++ 服务器时,我在 C++ 服务器输出(即终端)中收到一条错误消息“ thrift non-blocking server overload condition ”,这已在第 3 和第 4 中指出下面的片段。我附上了通过 GDB 回溯命令检索到的堆栈,以供您参考。谁能告诉我我在这里缺少什么?您认为可能导致此错误的原因是什么。python 端或 C++ 端的节俭配置是否存在错误。请参考以下片段。我做了很多谷歌搜索,但到目前为止找不到线索。谢谢。

1) Python 客户端 - Thrift 配置

     try:
        self.transport = TSocket.TSocket( host , port)
        <----- NONBLOCKING --------->
        self.transport = TTransport.TFramedTransport(self.transport)    
        <----- NONBLOCKING --------->
        protocol = TBinaryProtocol.TBinaryProtocol(self.transport)


        # Instantiate the thrift client
        self.client = MyService.Client(protocol)
        # Connect to the thrift server
        self.transport.open()
        print 'Connection established via thrift...\n'   

2) C++ 服务器 - Thrift 配置

    using boost::shared_ptr;
    printf("          *** Starting non-block THRIFT! ***\n");
    shared_ptr<MyServiceHandler> handler(new MyServiceHandler(this));
    shared_ptr<TProcessor> processor(new MyServiceProcessor(handler));
    shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory());

    shared_ptr<ThreadManager>  threadManager=ThreadManager::newSimpleThreadManager(15);
    shared_ptr<PosixThreadFactory> threadFactory =
    shared_ptr<PosixThreadFactory>(new PosixThreadFactory());
    threadManager->threadFactory(threadFactory);
    threadManager->start();
    ats::TNonblockingServer server(processor,protocolFactory, port, threadManager);
    server.serve();

3) C++ 服务器中的错误输出

   !!!! ERROR BEGIN !!!! 
   Thrift: Tue Nov 15 17:59:49 2011 **thrift non-blocking server overload condition**
   !!!! ERROR IS END !!!!

4) GDB 回溯栈

   thrift non-blocking server overload condition

   Program received signal SIGSEGV, Segmentation fault.
   [Switching to Thread 0xb7ad7b70 (LWP 17961)]
   0x080bb3a8 in vtable for __cxxabiv1::__si_class_type_info ()
  (gdb) bt
  #0 0x080bb3a8 in vtable for __cxxabiv1::__si_class_type_info ()
  #1 0xb7ec8195 in apache::thrift::server::TConnection::workSocket (this=0x80be4f0)
  at src/server/TNonblockingServer.cpp:168
  #2 0xb7ecc88d in apache::thrift::server::TConnection::eventHandler (fd=13, v=0x80be4f0)
  at src/server/TNonblockingServer.h:915
  #3 0xb7ea8e90 in event_base_loop () from /usr/lib/libevent-1.4.so.2
  #4 0xb7ec782f in apache::thrift::server::TNonblockingServer::serve (this=0xb7ad7194)
  at src/server/TNonblockingServer.cpp:923
  #5 0x0807bef5 in MyConfiguration::runNonBlockingServer (this=0xbffff2ec, port=9090)
  at /home/configuration/my_configuration.cpp:485
  #6 0x0807de19 in MyConfiguration::run (this=0xbffff2ec)
  at /home/configuration/my_configuration.cpp:54
  #7 0x08078a2a in redirectPthreadRun (m=0xbffff2ec)
  at /home/src/common/p_thread_run.cpp:107
  #8 0xb7fa0725 in start_thread () from /lib/libpthread.so.0
  #9 0xb7ceb1ce in clone () from /lib/libc.so.6
4

0 回答 0