[Boost-bugs] [Boost C++ Libraries] #12545: stream_socket_service forcibly takes responsibility for closing the native_handle

Subject: [Boost-bugs] [Boost C++ Libraries] #12545: stream_socket_service forcibly takes responsibility for closing the native_handle
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2016-10-24 09:06:19


#12545: stream_socket_service forcibly takes responsibility for closing the
native_handle
-------------------------------------------+----------------------------
 Reporter: Adrien CLERC <adrien.clerc@…> | Owner: chris_kohlhoff
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: asio
  Version: Boost 1.61.0 | Severity: Problem
 Keywords: native_handle close |
-------------------------------------------+----------------------------
 When using the `basic_stream_socket`
 [https://github.com/boostorg/asio/blob/36eef63a9cf8ae609716d76ccb3906ff9769d53a/include/boost/asio/basic_stream_socket.hpp#L130
 constructor with a native_handle_type], it seems that the service will
 call `close()` on it
 [https://github.com/boostorg/asio/blob/36eef63a9cf8ae609716d76ccb3906ff9769d53a/include/boost/asio/detail/impl/reactive_socket_service_base.ipp#L91
 upon destruction].

 I have no expectation on this behavior, but this should be stressed in the
 documentation. Using this constructor (or the `assign()` method) is very
 handy when dealing with third-parties, but those very same third-parties
 can have the same policy of auto-closing.

 This will lead to double closing, which is the best way for data
 corruption in a process that constantly opens and closes files.

 I will go for a call to `dup()` before using the `ip::tcp::socket` for
 now.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/12545>
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:20 UTC