Boost logo

Boost Users :

Subject: Re: [Boost-users] AsIO daytime example needs terminate code
From: Christopher Yeleighton (giecrilj_at_[hidden])
Date: 2010-04-28 17:47:13


Boris Schaeling <boris <at> highscore.de> writes:

>
> On Wed, 28 Apr 2010 16:23:43 +0200, Christopher Yeleighton
> <giecrilj <at> stegny.2a.pl> wrote:
>
> > [...]Of course this works for the synchronous server where there is an
> > explicit loop;
> > an asynchronous server needs to call { service->stop(); } My experiment
> > shows
> > that it is does not produce any visible failure under SuSE; however, it
> > is not
> > clear whether io_service::stop can be called from within a signal
> > handler.
>
> It's not safe to call io_service::stop in a signal handler (io_service is
> thread-safe; there are Pthread functions called in io_service::stop which
> are not safe to call in signal handlers).
>

So how do I handle signals without breaking something?

I applied this technique to the TCP echo server example [1]; the result is the
active sessions are never destroyed (leaking) because they are destroyed in
response to a network error only.

Please help. The assumption that the server runs forever is unacceptable.

Chris


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net