Subject: Re: [Boost-bugs] [Boost C++ Libraries] #8967: Spurious zero bytes written and eof notifications highlight ASIO IOCP issues
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2013-08-10 07:06:48
#8967: Spurious zero bytes written and eof notifications highlight ASIO IOCP
issues
-------------------------+-------------------------------------------------
Reporter: | Owner: chris_kohlhoff
simoncperkins@⦠| Status: new
Type: Bugs | Component: asio
Milestone: To Be | Severity: Problem
Determined | Keywords: eof GetQueuedCompletionStatus
Version: Boost | WSARecv WSASend overlapped
1.54.0 |
Resolution: |
-------------------------+-------------------------------------------------
Comment (by Shane Powell <killerbee@â¦>):
Hi,
I found and fixed the same problem:
https://svn.boost.org/trac/boost/ticket/8933
I disagree with your patch tho as I think it's dangerous removing how the
on_pending works. It's there to delay the calling of the complete handler
until after the returning of the winsock functions as they are not
reentrant for a single socket. Removing the it completely would result in
existing asio programs not working correctly in all situations.
The ASIO documentation says the the complete handler is not called until
after the call to the sockets function has returned. This means that it's
safe to call the next read/write cycle again. Taking away how the
on_pending works will mean that it's possible that you can call back into
the read/write functions before you are allowed to, which can caused
undefined behaviour.
Quote from MSDN:
WSARecv should not be called on the same socket simultaneously from
different threads, because it can result in an unpredictable buffer order.
Check out my patch, it's much simpler (basically it reverts the code back
to how it used to work), as the actual bug is that on_pending should be
calling PostQueuedCompletionStatus with the 'overlapped_contains_result'
value so that the io completion routine knows that it's a delayed result
rather than a real result. Because it got changed from
'overlapped_contains_result' to zero, the io completion routine thinks
it's a result from a winsock type function rather than a delayed result
where the result is stored in the overlapped structure.
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/8967#comment:1> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:13 UTC