]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/boost/boost/process/detail/posix/async_out.hpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / boost / process / detail / posix / async_out.hpp
index 06fd92e1b1f6467d3dc2c4dde7b95e98e54918b6..bbf4179081786a020834c05abc4a2cf76cc8fbeb 100644 (file)
@@ -19,6 +19,8 @@
 #include <memory>
 #include <exception>
 #include <future>
+#include <array>
+#include <boost/process/detail/used_handles.hpp>
 
 namespace boost { namespace process { namespace detail { namespace posix {
 
@@ -45,12 +47,24 @@ inline int apply_out_handles(int handle, std::integral_constant<int, 1>, std::in
 
 template<int p1, int p2, typename Buffer>
 struct async_out_buffer : ::boost::process::detail::posix::handler_base_ext,
-                          ::boost::process::detail::posix::require_io_context
+                          ::boost::process::detail::posix::require_io_context,
+                          ::boost::process::detail::uses_handles
 {
     Buffer & buf;
 
     std::shared_ptr<boost::process::async_pipe> pipe;
 
+    std::array<int, 4> get_used_handles()
+    {
+        const auto pp1 = p1 != -1 ? p1 : p2;
+        const auto pp2 = p2 != -1 ? p2 : p1;
+
+        if (pipe)
+            return {pipe->native_source(), pipe->native_sink(), pp1, pp2};
+        else  //if pipe is not constructed, limit_ds is invoked before -> this also means on_exec_setup gets invoked before.
+            return {pp1, pp2, pp1, pp2};
+    }
+
 
     async_out_buffer(Buffer & buf) : buf(buf)
     {
@@ -61,7 +75,7 @@ struct async_out_buffer : ::boost::process::detail::posix::handler_base_ext,
     {
         auto  pipe              = this->pipe;
         boost::asio::async_read(*pipe, buf,
-                [pipe](const boost::system::error_code&, std::size_t size){});
+                [pipe](const boost::system::error_code&, std::size_t){});
 
         this->pipe = nullptr;
         std::move(*pipe).sink().close();
@@ -112,32 +126,32 @@ struct async_out_future : ::boost::process::detail::posix::handler_base_ext,
         fut = promise->get_future();
     }
     template <typename Executor>
-    inline void on_success(Executor &exec)
+    inline void on_success(Executor &)
     {
-        auto pipe = this->pipe;
+        auto pipe_ = this->pipe;
 
-        auto buffer  = this->buffer;
-        auto promise = this->promise;
+        auto buffer_  = this->buffer;
+        auto promise_ = this->promise;
 
-        boost::asio::async_read(*pipe, *buffer,
-                [pipe, buffer, promise](const boost::system::error_code& ec, std::size_t size)
+        boost::asio::async_read(*pipe_, *buffer_,
+                [pipe_, buffer_, promise_](const boost::system::error_code& ec, std::size_t)
                 {
                     if (ec && (ec.value() != ENOENT))
                     {
                         std::error_code e(ec.value(), std::system_category());
-                        promise->set_exception(std::make_exception_ptr(process_error(e)));
+                        promise_->set_exception(std::make_exception_ptr(process_error(e)));
                     }
                     else
                     {
-                        std::istream is (buffer.get());
+                        std::istream is (buffer_.get());
                         Type arg;
-                        arg.resize(buffer->size());
-                        is.read(&*arg.begin(), buffer->size());
-                        promise->set_value(std::move(arg));
+                        arg.resize(buffer_->size());
+                        is.read(&*arg.begin(), buffer_->size());
+                        promise_->set_value(std::move(arg));
                     }
                 });
 
-        std::move(*pipe).sink().close();
+        std::move(*pipe_).sink().close();
         this->pipe = nullptr;
     }