停止节俭服务器(TSimpleServer) [英] Stopping a Thrift server(TSimpleServer)

查看:144
本文介绍了停止节俭服务器(TSimpleServer)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个节俭服务器一个简单的用例( TSimpleServer ),其中我有几个线程催生了(除了主线程)。其中一个新生成的线程进入节俭事件循环(即 server.serve())。一旦在主线程接收信号我调用 server.stop()这是造成下面张贴的错误。

I have a simple use case for a Thrift Server(TSimpleServer) wherein I have a couple of threads spawned(besides the main thread). One of the newly spawned threads enters the Thrift event loop (i.e server.serve()). Upon receiving a signal in the main thread I invoke server.stop() which is causing the error posted below.

起初我还以为这是一个未捕获的异常。但是包装server.serve的同时调用() server.stop()的try-catch ES并没有帮助隔离问题。任何想法/建议(什么我应该做的)?最节俭的教程/指南/例子似乎谈论服务器开始,但似乎并没有提及停止的情况下,任何指针/最佳做法/在这方面的建议将是巨大的。谢谢你。

At first I thought it was an uncaught exception. However wrapping both the invocations of server.serve() and server.stop() in try-catch'es didn't help isolate the problem. Any thoughts/suggestions(on what I should be doing)? Most Thrift tutorials/guides/examples seem to talk about server start but don't seem to mention the stop scenario, any pointers/best-practices/suggestions in this regard would be great. Thanks.

另外,我使用的节俭0.7.0。

Also, I am using thrift-0.7.0.

错误详细信息:

Thrift: Fri Nov 18 21:22:47 2011 TServerTransport died on accept: TTransportExc\
eption: Interrupted
*** glibc detected *** ./build/mc_daemon: munmap_chunk(): invalid poi\
nter: 0x0000000000695f18 ***
Segmentation fault (core dumped)

此外,这里的堆栈跟踪:

Also here's the stack-trace:

#0  0x00007fb751c92f08 in ?? () from /lib/libc.so.6
#1  0x00007fb7524bb0eb in apache::thrift::server::TSimpleServer::serve (
    this=0x1e5bca0) at src/server/TSimpleServer.cpp:140
#2  0x000000000046ce15 in a::b::server_thread::operator() (
    this=0x695f18)
    at /path/to/server_thread.cpp:80
#3  0x000000000046c1a9 in boost::detail::thread_data<boost::reference_wrapper<a\
ds::data_load::server_thread> >::run (this=0x1e5bd80)
    at /usr/include/boost/thread/detail/thread.hpp:81
#4  0x00007fb7526f2b70 in thread_proxy ()
   from /usr/lib/libboost_thread.so.1.40.0
#5  0x00007fb7516fd9ca in start_thread () from /lib/libpthread.so.0
#6  0x00007fb7519fa70d in clone () from /lib/libc.so.6
#7  0x0000000000000000 in ?? ()

编辑1:我已经添加了伪code为主线程的的节俭服务器线程后台线程

编辑2:我似乎已经解决了原来的问题,因为在我的回答如下说明。然而,这种解决方案引出两个相当不可取/可疑的设计选择:(一)我已经向大家介绍一个节俭的端点,以使一个机制来停止服务器(二)处理类的节俭服务(通常需要实例化一个服务器对象),现在要求到信号反馈给服务器停止,引入各种各样的循环依赖的手段。

Edit 2: I seem to have resolved the original issue as noted in my answer below. However this solution leads to two rather undesirable/questionable design choices: (i) I had to introduce a thrift endpoint to enable a mechanism to stop the server (ii) The handler class for the thrift service(which is usually required to instantiate a server object) now requires a means to signal back to the server to stop, introducing a circular dependency of sorts.

在这些设计问题的任何建议/选择将大大AP preciated。

Any suggestions on these design issues/choices would be greatly appreciated.

推荐答案

我的问题似乎已经从我的code /设计,其中我有信号处理程序code在主线程中调用<$ C $朵朵C>停止这是在一个服务器线程的服务器上启动。改变这种行为(如引擎收录code-片段说明)帮助解决这个问题。

My problem seems to have stemmed from my code/design wherein I had signal-handler code in the main thread invoking stop on the server which was started in a 'server thread'. Changing this behavior(as noted in the pastebin code-snippets) helped resolve this issue.

这篇关于停止节俭服务器(TSimpleServer)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆