
On 2014-04-07, 5:12 PM, Igor R wrote:
Does it still crash if you remove the call to service.stop()? Because in the code below, that should be redundant.
Also, starting the threads should occur *after* you post all the tasks. Otherwise there is a chance that none of them will actually execute.
Thanks for your comments.
As Igor pointed out in another email, without a call to service.stop(), the io_service will continue to wait for more handlers which means the group.join_all() will continue to wait uninterrupted until the Sun finally explodes.
Just out if curiosity, if you create io_service::work dynamically and destroy it instead of stopping io_service, does it crash? Like this: auto work = make_shared<io_service::work>(service); //.... // at the point where you want to stop the service: work.reset();
With this change, it crashes once every two runs of the test app so it crashes less often, but still crashes reliably. Seems like a bug to me and not the PEBKAC for which I am infamous. Anyone familiar enough with the asio library to say that I should file a bug? Thanks, Sohail