Boost logo

Boost :

From: Gaurav.Jain_at_[hidden]
Date: 2007-05-21 07:07:28


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 i
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 clean
shutdown of the server. In the clean shut down i want to close each
connection running over related io_service. 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 :

bool io_object_pool::shutdown_pool()
{
        
        std::vector<io_object*>::const_iterator iter_output =
io_object_vec.begin();
        std::vector<io_object*>::const_iterator iter_end_output =
io_object_vec.end();

        for(; iter_output != iter_end_output; )
        {
                io_object* io_object_temp = *iter_output;
                iter_output++;
        
io_object_temp->get_ioservice().post(boost::bind(&io_object::stop_all,
io_object_temp)
                );
        }
        io_object_vec.clear();
        is_pool_destroyed = true;
        return true;
}

bool io_object::stop_all()
{
        
        std::set<connection_ptr >::const_iterator iter_output =
connections_.begin();
        std::set<connection_ptr >::const_iterator iter_end_output =
connections_.end();

        for(; iter_output != iter_end_output;)
        {
                connection_ptr conn_temp = *iter_output;
                iter_output++;
        
conn_temp->socket().io_service().post(boost::bind(&tcp_connection::stop,
conn_temp)
                );
        }
                
        scheduler.stop();
        execution_thread->join();
        return true;
}

bool tcp_connection::stop()
{
        try
        {
                assigned_io_object_->stop(shared_from_this());
                socket_.close();

                std::cout << "tcp_connection stop called" << std::endl;

                        
                assigned_io_object_->remove_request(); // remove the
//connection from the repository of connection managed by the
//related io service object

                assigned_io_object_ = NULL;
                is_connection_stop = true;
                        
        }
        catch (std::exception&)
        {

        }

        return true;
}

The message "tcp_connection stop called" is not getting called for each
of the io service. Any suggestion what might wrong in this case ? Or is
this still considered as a clean shutdown (tcp_connection::stop still
not getting execute for each of the connection).

Regards,
Gaurav Jain

DISCLAIMER:
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 acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk