Boost logo

Boost Users :

Subject: Re: [Boost-users] Boost.ASIO calling handler guarantees
From: Niall Douglas (s_sourceforge_at_[hidden])
Date: 2014-08-22 08:30:28


On 22 Aug 2014 at 16:20, wrote:

> I'm playing with Boost.ASIO framework and failed to find a complete
> answer on the following question.
> [snip]
> Looking at least at async_write() implementation, it cannot be relied upon:
> - async_write executes a chain of boost::asio::detail::write_op() operations:
> - if asio_handler_allocate() may throw then
> - write_op::stream_.async_write_some() may throw then
> - write_op.handler_() might never be called
>
> So, either we should never rely on this assumption, or there's a bug in async_write().
> Not relying on this assumption what is the reliable way of building applications with Boost.Asio?

I can't speak for ASIO, but AFIO explicitly makes no guarantees if a
bad_alloc exception is ever thrown. Otherwise it guarantees exception
safety.

I would be highly surprised if ASIO can do any better than AFIO here.
Handling bad_alloc is extremely tough when your exception handling
paths have no choice but to allocate memory, which for something
involving async i/o they must.

The traditional solution is to feed the code an allocator which will
never, ever run out of memory. That may be useful for ASIO too.

Niall

-- 
ned Productions Limited Consulting
http://www.nedproductions.biz/ 
http://ie.linkedin.com/in/nialldouglas/



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