Opened 4 years ago
Last modified 4 years ago
#13581 new Bugs
`basic_stream_socket::read_some` on `non_blocked` socket returns `ec=would_block`
Reported by: | Owned by: | chris_kohlhoff | |
---|---|---|---|
Milestone: | To Be Determined | Component: | asio |
Version: | Boost Development Trunk | Severity: | Problem |
Keywords: | non-blocked | Cc: |
Description
In the boost\asio\detail\impl\socket_ops.ipp
file there is sync_recv
function which should block until some data is received.
Inside this function there is following if
block
if ((state & user_set_non_blocking) || (ec != boost::asio::error::would_block && ec != boost::asio::error::try_again)) return 0;
IMHO condition is wrong here. It should return 0 for all cases except socket is in non_blocking
mode and ec is one of [would_block, try_again]
In fact if socket is in 'non-blocked' mode and ec = would_block, it also returns 0.
If assumption is correct, code should look like
if (0 == (state & user_set_non_blocking) || (ec != boost::asio::error::would_block && ec != boost::asio::error::try_again)) return 0;
Note:
See TracTickets
for help on using tickets.
Probably, I read documentation wrong. It should block in case of
blocked
socket.