You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@thrift.apache.org by Richard Salz <rs...@us.ibm.com> on 2010/10/23 07:21:08 UTC

stop() method?

When a server is in its "serve" loop:
        server.serve()
        printf("Exiting..\n");

What't the right way to make that stop and return so the printf happens? I 
thought having having SIGTERM call server.stop(), but apparently not. What 
should I do?

        /r$

--
STSM, WebSphere Appliance Architect
https://www.ibm.com/developerworks/mydeveloperworks/blogs/soma/


Re: stop() method?

Posted by Rush Manbert <ru...@manbert.com>.
On Oct 25, 2010, at 5:58 AM, Richard Salz wrote:

>> ... [signals are different with threads] ...
> 
> Thanks, but I have all the signal stuff right; I know my handler is 
> getting called.  (I've been doing this for awhile, cf 
> http://www.mail-archive.com/openssl-dev@openssl.org/msg07729.html :)
> 
> I thought that the server was still blocked in polling for accept, and 
> read through the code. To make a long story short, it looks like 
> TSimpleServer::stop() is missing this line:
>        serverTransport_->interrupt()
> 
> Can anyone on the core team confirm this as a bug?
> 

Hi,

I'm not core team, but I can confirm it (It's in my 591 patch).

Best,
Rush


Re: stop() method?

Posted by Richard Salz <rs...@us.ibm.com>.
> This seems like a pretty reasonable possibility. Can you open a JIRA 
ticket?

Done, thrift-972

thanks.

--
STSM, WebSphere Appliance Architect
https://www.ibm.com/developerworks/mydeveloperworks/blogs/soma/


Re: stop() method?

Posted by Bryan Duxbury <br...@rapleaf.com>.
This seems like a pretty reasonable possibility. Can you open a JIRA ticket?

On Mon, Oct 25, 2010 at 5:58 AM, Richard Salz <rs...@us.ibm.com> wrote:

> > ... [signals are different with threads] ...
>
> Thanks, but I have all the signal stuff right; I know my handler is
> getting called.  (I've been doing this for awhile, cf
> http://www.mail-archive.com/openssl-dev@openssl.org/msg07729.html :)
>
> I thought that the server was still blocked in polling for accept, and
> read through the code. To make a long story short, it looks like
> TSimpleServer::stop() is missing this line:
>        serverTransport_->interrupt()
>
> Can anyone on the core team confirm this as a bug?
>
>        /r$
>
> --
> STSM, WebSphere Appliance Architect
> https://www.ibm.com/developerworks/mydeveloperworks/blogs/soma/
>
>

Re: stop() method?

Posted by Richard Salz <rs...@us.ibm.com>.
> ... [signals are different with threads] ...

Thanks, but I have all the signal stuff right; I know my handler is 
getting called.  (I've been doing this for awhile, cf 
http://www.mail-archive.com/openssl-dev@openssl.org/msg07729.html :)

I thought that the server was still blocked in polling for accept, and 
read through the code. To make a long story short, it looks like 
TSimpleServer::stop() is missing this line:
        serverTransport_->interrupt()

Can anyone on the core team confirm this as a bug?

        /r$

--
STSM, WebSphere Appliance Architect
https://www.ibm.com/developerworks/mydeveloperworks/blogs/soma/


Re: stop() method?

Posted by Łukasz Michalik <lm...@ift.uni.wroc.pl>.
Hello,

You are running C++ in a pthread environment, I would presume from
that snippet.  Therefore you need to use pthread_sigmask(3) and
sigwait(3) in the same thread, call server.stop() and serve() will
return.  Usual signal(2) approach in not specified for multithread
environment.

On 01:21 2010-10-23 -0400, Richard Salz wrote:
> When a server is in its "serve" loop:
>         server.serve()
>         printf("Exiting..\n");
> 
> What't the right way to make that stop and return so the printf happens? I 
> thought having having SIGTERM call server.stop(), but apparently not. What 
> should I do?
> 

-- 
Pozdrawiam,
Łukasz P. Michalik

Re: stop() method?

Posted by Dvir Volk <dv...@gmail.com>.
I haven't tried it in C++, but in python I usually do something like:

try:
   server.serve()
except SystemExit: #SIGINT
   sys.exit(0)
except Exception as e: #Something else...
   sys.exit(1)

I suppose you can listen on SIGINT and raise an exception or something
through the signal handler.

On Sat, Oct 23, 2010 at 7:21 AM, Richard Salz <rs...@us.ibm.com> wrote:
> When a server is in its "serve" loop:
>        server.serve()
>        printf("Exiting..\n");
>
> What't the right way to make that stop and return so the printf happens? I
> thought having having SIGTERM call server.stop(), but apparently not. What
> should I do?
>
>        /r$
>
> --
> STSM, WebSphere Appliance Architect
> https://www.ibm.com/developerworks/mydeveloperworks/blogs/soma/
>
>