Boost C++ Libraries: Ticket #8861: boost 1.39 io_service_pool accept hangs https://svn.boost.org/trac10/ticket/8861 <p> 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. </p> <p> How to reproduce it: (1) Get the server2 example at <a href="http://www.boost.org/doc/libs/1_39_0/doc/html/boost_asio/example/http/server2/">http://www.boost.org/doc/libs/1_39_0/doc/html/boost_asio/example/http/server2/</a> </p> <p> (2) Modify connection.cpp to support persistent connection: void connection::handle_write(const boost::system::error_code&amp; e) { </p> <blockquote> <p> if (!e) { </p> <blockquote> <p> <em> Initiate graceful connection closure. </em>boost::system::error_code ignored_ec; <em>socket_.shutdown(boost::asio::ip::tcp::socket::shutdown_both, ignored_ec); start(); </em></p> </blockquote> <p> } </p> </blockquote> <p> (3) Modify the server.cpp to use different acceptor_ constructor server::server(const std::string&amp; address, const std::string&amp; port, </p> <blockquote> <p> const std::string&amp; doc_root, std::size_t io_service_pool_size) </p> </blockquote> <blockquote> <p> : io_service_pool_(io_service_pool_size), </p> </blockquote> <p> <em> acceptor_(io_service_pool_.get_io_service()), </em></p> <blockquote> <p> acceptor_( io_service_pool_.get_io_service(), </p> <blockquote> <p> boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v4(), atoi(port.c_str()))), </p> </blockquote> </blockquote> <blockquote> <p> new_connection_(new connection( </p> <blockquote> <p> io_service_pool_.get_io_service(), request_handler_)), </p> </blockquote> </blockquote> <blockquote> <p> request_handler_(doc_root) </p> </blockquote> <p> { </p> <blockquote> <p> <em> Open the acceptor with the option to reuse the address (i.e. SO_REUSEADDR). </em></p> </blockquote> <p> /* </p> <blockquote> <p> 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(); </p> </blockquote> <p> */ </p> <blockquote> <p> acceptor_.async_accept(new_connection_-&gt;socket(), </p> <blockquote> <p> boost::bind(&amp;server::handle_accept, this, </p> <blockquote> <p> boost::asio::placeholders::error)); </p> </blockquote> </blockquote> </blockquote> <p> } </p> <p> (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. </p> <p> (5) The server cannot accept any connections after 8th requests. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/8861 Trac 1.4.3 bill <shuzhouliu@…> Fri, 19 Jul 2013 14:24:41 GMT attachment set https://svn.boost.org/trac10/ticket/8861 https://svn.boost.org/trac10/ticket/8861 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">testhang.tar.bz2</span> </li> </ul> Ticket bill <shuzhouliu@…> Fri, 19 Jul 2013 14:26:56 GMT <link>https://svn.boost.org/trac10/ticket/8861#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8861#comment:1</guid> <description> <p> Added the test harness and modification to the server2 example as an attachment </p> </description> <category>Ticket</category> </item> </channel> </rss>