[Boost-bugs] [Boost C++ Libraries] #8861: boost 1.39 io_service_pool accept hangs

Subject: [Boost-bugs] [Boost C++ Libraries] #8861: boost 1.39 io_service_pool accept hangs
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2013-07-19 14:18:07


#8861: boost 1.39 io_service_pool accept hangs
---------------------------------+----------------------------
 Reporter: bill <shuzhouliu@…> | Owner: chris_kohlhoff
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: asio
  Version: Boost 1.39.0 | Severity: Problem
 Keywords: |
---------------------------------+----------------------------
 O.S.: Centos 5.4 64 bit
 Boost version: 1.39
 Symptom: With io_service-per-CPU and thread pool size 4, after the sever
 accepted at 8th connection, it cannot accept any connections afterwards.

 How to reproduce it:
 (1) Get the server2 example at
 http://www.boost.org/doc/libs/1_39_0/doc/html/boost_asio/example/http/server2/

 (2) Modify connection.cpp to support persistent connection:
 void connection::handle_write(const boost::system::error_code& e)
 {
   if (!e)
   {
     // Initiate graceful connection closure.
     //boost::system::error_code ignored_ec;
     //socket_.shutdown(boost::asio::ip::tcp::socket::shutdown_both,
 ignored_ec);
     start();
   }

 (3) Modify the server.cpp to use different acceptor_ constructor
 server::server(const std::string& address, const std::string& port,
     const std::string& doc_root, std::size_t io_service_pool_size)
   : io_service_pool_(io_service_pool_size),
 // acceptor_(io_service_pool_.get_io_service()),
     acceptor_( io_service_pool_.get_io_service(),
            boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v4(),
 atoi(port.c_str()))),

     new_connection_(new connection(
           io_service_pool_.get_io_service(), request_handler_)),

     request_handler_(doc_root)
 {
   // Open the acceptor with the option to reuse the address (i.e.
 SO_REUSEADDR).

 /*
   boost::asio::ip::tcp::endpoint endpoint(boost::asio::ip::tcp::v4(),
 1025);
   acceptor_.open(endpoint.protocol());
 acceptor_.set_option(boost::asio::ip::tcp::acceptor::reuse_address(true));
   acceptor_.bind(endpoint);
   acceptor_.listen();
 */
   acceptor_.async_accept(new_connection_->socket(),
       boost::bind(&server::handle_accept, this,
         boost::asio::placeholders::error));
 }

 (4) The client test harness create threads each second. In the thread, it
 will connect to the server, send a request and receive the response (both
 request/response should be small enough for one read/write). After that,
 the thread will sleep 1000 seconds without closing the connection.

 (5) The server cannot accept any connections after 8th requests.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/8861>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:13 UTC