Opened 12 years ago

Closed 12 years ago

#4898 closed Bugs (invalid)

Incorect behaviour of function boost::asio::io_service::run() in case when io_service::work was reinitialized

Reported by: Alexander Korkov <korkov@…> Owned by: chris_kohlhoff
Milestone: To Be Determined Component: asio
Version: Boost 1.44.0 Severity: Problem
Keywords: Cc:

Description

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

gcc (Debian 4.3.2-1.1) 4.3.2
Debian 5.0.6
Linux version 2.6.26-2-amd64

Change History (2)

comment:1 by Alexander Korkov <korkov@…>, 12 years ago

may be it's not a bug...
after io_service.stop() run() doesn't work

comment:2 by chris_kohlhoff, 12 years ago

Resolution: invalid
Status: newclosed

You need to call io_service.reset():

http://www.boost.org/doc/libs/1_45_0/doc/html/boost_asio/reference/io_service/reset.html

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.

Note: See TracTickets for help on using tickets.