[Boost-bugs] [Boost C++ Libraries] #13581: `basic_stream_socket::read_some` on `non_blocked` socket returns `ec=would_block`

Subject: [Boost-bugs] [Boost C++ Libraries] #13581: `basic_stream_socket::read_some` on `non_blocked` socket returns `ec=would_block`
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2018-05-29 14:52:30


#13581: `basic_stream_socket::read_some` on `non_blocked` socket returns
`ec=would_block`
-------------------------------------------------+-------------------------
 Reporter: Dmytro Ovdiienko | Owner:
  <dmitriyovdienko@…> | chris_kohlhoff
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: asio
  Version: Boost Development Trunk | Severity: Problem
 Keywords: non-blocked |
-------------------------------------------------+-------------------------
 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;
 }}}

-- 
Ticket URL: <https://svn.boost.org/trac10/ticket/13581>
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 : 2018-05-29 14:58:03 UTC