Boost logo

Boost :

From: Gaurav.Jain_at_[hidden]
Date: 2007-05-22 11:00:01

> On Mon, 21 May 2007 16:37:28 +0530, Gaurav.Jain <at> said:
> > Hi,
> >
> > I am using boost boost 1.33.1 with asio 0.3.8rc2. I have develop a
> > Multi-threaded server program using pool of io_service. In my design
> > have pool of io_service object and this pool is controlled by a pool
> > manager, which is running over a seprate io_service. I want to do
> > shutdown of the server. In the clean shut down i want to close each
> > connection running over related io_service.
> It's worth noting that this is not the only way to do clean shutdown.
> The new HTTP server examples ("server2" and "server3") also perform a
> clean shutdown. However, rather than explicitly closing the
> they simply rely on the fact that the io_service destructor will
> all handler objects associated with unfinished operations.
> > What i am doing is, while
> > shutting down the server, pool manager is posting a request to each
> > io_service object to shut it down. Each io_service object in turn
> > posting a request to all the connection it is hosting to stop
> > themselves. The problem i am facing : connection stop method is not
> > getting executed at all for each running connection.
> >
> > Here is a code snippet of what i am doing :
> [...]
> > scheduler.stop();
> What is scheduler? Is it an io_service? If so, by explicitly stopping
> some of your completion handlers will never be called. If you want to
> use this particular clean shutdown design, it is better to wait for
> io_service::run() call to finish automatically once all the
> operations have finished

Yes scheduler is an io_service. I am now not using scheduler.stop() in
my code &
doing what have you suggested in your reply. But still server is not
getting cleanly
shutdown as per my design. Here is what am I doing :

void tcp_server::handle_stop()
                delete io_object_pool_;
                io_object_pool_ = NULL;


void io_object_pool::shutdown_pool()
        std::vector<io_object*>::const_iterator iter_output =
        std::vector<io_object*>::const_iterator iter_end_output =

        for(; iter_output != iter_end_output; )
                io_object* io_object_temp = *iter_output;

void io_object::stop_all()
        std::set<connection_ptr >::const_iterator iter_output =
        std::set<connection_ptr >::const_iterator iter_end_output =

        for(; iter_output != iter_end_output;)
                connection_ptr conn_temp = *iter_output;

In above code I have also tried with io_service().wrap() instead of
post(), but all in vein

void tcp_connection::stop()
                std::cout << "tcp_connection stop called" << std::endl;
                assigned_io_object_ = NULL;
                is_connection_stop = true;
        catch (std::exception&)

The above cout statement is not getting printed, not even for single

Can you pls suggest what else is getting wrong here


This message contains privileged and confidential information and is intended only for an individual named. If you are not the intended recipient, you should not disseminate, distribute, store, print, copy or deliver this message. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. E-mail transmission cannot be guaranteed to be secure or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete or contain viruses. The sender, therefore, does not accept liability for any errors or omissions in the contents of this message which arise as a result of e-mail transmission. If verification is required, please request a hard-copy version.

Boost list run by bdawes at, gregod at, cpdaniel at, john at