Subject: [Boost-bugs] [Boost C++ Libraries] #13335: When using unix domain socket (boost::asio::local::stream_protocol), synchronous write may not respond sometimes on macOS
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2017-12-11 06:48:39
#13335: When using unix domain socket (boost::asio::local::stream_protocol),
synchronous write may not respond sometimes on macOS
------------------------------+----------------------------
Reporter: seungrye@⦠| Owner: chris_kohlhoff
Type: Bugs | Status: new
Milestone: To Be Determined | Component: asio
Version: Boost 1.65.0 | Severity: Problem
Keywords: UDS, poll |
------------------------------+----------------------------
In very intermittent situations, synchronous write does not wake up in the
following situations:
1. The server application uses a unix domain socket and accepts and reads
asynchronously.
2. The client application uses a unix domain socket, and there is a thread
that performs synchronous write repeatedly. Disconnect and reconnect at
any time.
There is no issue when checking on Windows / Mac with tcp socket.
UDS (boost::asio::local::stream_protocol) has issue when checking on Mac.
When testing with boost library 1.62.0 and 1.65.0 in macOS 10.12
environment, I confirmed that an issue occurred.
The source code of the function with no response is as follows.
{{{
int poll_write (socket_type s, state_type state, boost :: system ::
error_code & ec)
{
  if (s == invalid_socket)
  {
    ec = boost :: asio :: error :: bad_descriptor;
    return socket_error_retval;
  }
#if defined (BOOST_ASIO_WINDOWS) \
  || defined (__ CYGWIN__) \
  || defined (__ SYMBIAN32__)
...
#else // defined (BOOST_ASIO_WINDOWS)
      // || defined (__ CYGWIN__)
      // || defined (__ SYMBIAN32__)
  pollfd fds;
  fds.fd = s;
  FDS.Events = POLLOUT;
  FDS.revents = 0;
  int timeout = (state & user_set_non_blocking)? 0: -1;
  clear_last_error ();
  int result = error_wrapper (:: poll (& fds, 1, timeout), ec); //!!!
::poll is not wakeup even if socket cancelled and closed
#endif // defined (BOOST_ASIO_WINDOWS)
       // || defined (__ CYGWIN__)
       // || defined (__ SYMBIAN32__)
...
}
}}}
Attached test project. (xcode 8.3 project)
The following settings should be changed as appropriate.
* Modify the "Link Binary With Libraries" of "Build Phases" as appropriate
for both server / client projects.
* Modify the "Header Search Paths" and "Library Search Path" of the Build
Settings as appropriate for both server / client projects.
I do not speak English well so I used Google translation.
Therefore, the contents may be awkward. I hope you understand.
And, I hope this issue is resolved.
''Note. I used the compiled library.
Compilation builds version 1.65.0 using the ofxOSXBoost (on GitHub) script
(build-libc ++ withBitcode).''
-- Ticket URL: <https://svn.boost.org/trac10/boost/ticket/13335> 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-12-11 06:54:39 UTC