Boost logo

Boost Users :

Subject: Re: [Boost-users] ASIO cancel question
From: Igor R (boost.lists_at_[hidden])
Date: 2009-08-06 11:16:16


> In ASIO, when I execute a cancel() on a tcp::socket, does it remove all
> of the handlers associated with the socket from the handler queue?

No. Every async_XXX request must end with its handler invocation.

<...>
> Let's assume now that
> the object destructs before the handleRead is called

This is very bad and will cause crash/segfault. Parts of your handler
(incl. the bound object) must not cease before the async.operation is
complete.

> Also, as reading and writing operations are done in the IO service thread, would it be safe to call the tcp::socket cancel from another
thread (e.g. in the destructor of a class)?

No. You should post() the cancel operation to io_service thread.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net