Boost logo

Boost :

Subject: [boost] [asio]Proper way to restart io_service
From: Urberg, John (John-Urberg_at_[hidden])
Date: 2008-09-22 17:51:50


I have an application using boost::asio (v 1.35.0) that creates a udp
multicast socket and an acceptor using an io_service and then calls
io_service.run(). Additional sockets are created from
acceptor.async_accept. My code needs to stop all the sockets and then
restart them at a later point. When stopping the sockets, I close all
the sockets I opened before deleting them. I then call
io_service.stop(). When I restart things, I call io_service.reset(),
recreate the udp multicast and acceptor sockets on the io_service and
then call io_service.run(). When the io_service starts up again, it
seems to have old operations on the queue and it tries to process them.
I will usually get either a "vector iterator not dereferencable" error
from a buffer on a deleted class or an error in a deleted version of the
class that was processing async_accept before I stopped.

Is there something additional I should be doing to clear the queue in
the io_service?

Thanks,
John


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk