Boost logo

Boost Users :

Subject: [Boost-users] HTTP server3 example question
From: huvcbo (christer.borgqvist10_at_[hidden])
Date: 2013-01-24 15:42:47


Hi all,

I have problem with HTTP Server3 example,
in connection::handle_write i have a dedline_timer with a
async_wait.
but before the handle_timed execute the connection_ptr goes out of
scope, why?

Appriciate any help.

Christer

The boost HTTP Server 3 in file connection.cpp
in server.hpp
boost::shared_ptr<connection> connection_ptr;
server.cpp
         void server::handle_accept(const boost::system::error_code& e)
         {
             if (!e)
             {
                 new_connection_->start();
                 new_connection_.reset(new connection(io_service_));
                 acceptor_.async_accept(new_connection_->socket(),
                     boost::bind(&server::handle_accept, this,
                         boost::asio::placeholders::error));
             }
         }

in connection.cpp

void connection::handle_write(const boost::system::error_code& e)
{
     if (!e)
     {
        const boost::shared_ptr<boost::asio::deadline_timer> t(new
        boost::asio::deadline_timer(*io_service_,
        boost::posix_time::seconds(15)));
     }
}

void connection::handle_timed(
       const boost::system::error_code& ec,
        const boost::shared_ptr<boost::asio::deadline_timer> t)
{
      syslog(LOG_INFO, "handle_timed: %s", ec.message().c_str());

}


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