|
Boost Users : |
Subject: Re: [Boost-users] [asio] SSL async_shutdown() never finishes if called when async_read_some() is in progress
From: Vinnie Falco (vinnie.falco_at_[hidden])
Date: 2018-04-06 18:37:00
On Fri, Apr 6, 2018 at 7:29 AM, Alexander D. via Boost-users
<boost-users_at_[hidden]> wrote:
>
> Yes, I do need the program to work on at least Windows XP.
This restriction described in the Boost.Asio documentation places
constrains on how your code may be designed:
"[CancelIO] will only cancel asynchronous operations that were
initiated in the current thread."
This means you must always use an implicit strand (only one thread
calling io_service::run), and always call initiating functions from
it, especially the call to the first initiating function (which is
often made from a foreign thread). The call to cancel() must of course
be made from the io_service thread (asio sockets are not thread safe),
which can be done by using boost::asio::post if you are on a foreign
thread. If you need your application service connections using more
than one thread you will need to use one io_service per thread.
> Why can't we shutdown a stream while reading from it (since we can close a socket while reading)?
If you insist on supporting a defective operating system, then do not
be surprised if things don't work the way you want. From the
Boost.Asio documentation (RE: CancelIO on Windows XP):
"[CancelIO] can appear to complete without error, but the request to
cancel the unfinished operations may be silently ignored by the
operating system. Whether it works or not seems to depend on the
drivers that are installed."
So, IF you make sure only one thread is used on each instance of
io_service , AND your user has cooperative drivers, then MAYBE your
program will function correctly.
Regards
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