Boost C++ Libraries: Ticket #4898: Incorect behaviour of function boost::asio::io_service::run() in case when io_service::work was reinitialized https://svn.boost.org/trac10/ticket/4898 <pre class="wiki">using boost::asio::io_service; io_service io_service; io_service::work *work = new io_service::work(io_service); delete work; work = new io_service::work(io_service); io_service.run(); /// must wait but doesn't do it </pre><p> gcc (Debian 4.3.2-1.1) 4.3.2<br /> Debian 5.0.6<br /> Linux version 2.6.26-2-amd64 </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/4898 Trac 1.4.3 Alexander Korkov <korkov@…> Thu, 25 Nov 2010 15:20:08 GMT <link>https://svn.boost.org/trac10/ticket/4898#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4898#comment:1</guid> <description> <p> may be it's not a bug...<br /> after io_service.stop() run() doesn't work </p> </description> <category>Ticket</category> </item> <item> <dc:creator>chris_kohlhoff</dc:creator> <pubDate>Thu, 25 Nov 2010 21:12:12 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/4898#comment:2 https://svn.boost.org/trac10/ticket/4898#comment:2 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">invalid</span> </li> </ul> <p> You need to call io_service.reset(): </p> <p> <a href="http://www.boost.org/doc/libs/1_45_0/doc/html/boost_asio/reference/io_service/reset.html">http://www.boost.org/doc/libs/1_45_0/doc/html/boost_asio/reference/io_service/reset.html</a> </p> <p> In your first example, deleting the work object makes the io_service run out of work. In the second, you call stop(). Both situations require a call to reset() to clear the "stopped" flag before calling run() again. </p> Ticket