Boost logo

Boost :

Subject: Re: [boost] [asio]Proper way to restart io_service
From: Urberg, John (John-Urberg_at_[hidden])
Date: 2008-09-23 11:12:37


> 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?

I think I've got this working now. I read the documentation some more
and noticed the run method will exit when there's no more work. So I
now close all the sockets I've opened and do a short timed_wait on the
thread to let run finish. I also have to catch operation_aborted errors
in my handlers as they get called after I close the sockets.

It looks like the issues I was having stopping and restarting an
io_service should be expected since the documentation states that
calling stop "will cause the io_service.run() call to return as soon as
possible, abandoning unfinished operations and without permitting ready
handlers to be dispatched." Would there be a way to modify the
io_service to give the user a way to clear those unfinished operations?

Also, I had a tough time figuring out what the error codes meant in my
handlers as they just come back as an integer value (i.e. 995 ==
operation_aborted). Is there a way to get more information on these?

Thanks,
John


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