From 17431a0c95558ed61f092fa019231df89677ca0f Mon Sep 17 00:00:00 2001 From: Claudius 'keldu' Holeksa Date: Fri, 9 Aug 2024 18:26:48 +0200 Subject: wip --- modules/io/c++/io_unix.cpp | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) (limited to 'modules/io') diff --git a/modules/io/c++/io_unix.cpp b/modules/io/c++/io_unix.cpp index 5a8da3a..2c6cf00 100644 --- a/modules/io/c++/io_unix.cpp +++ b/modules/io/c++/io_unix.cpp @@ -738,6 +738,10 @@ own unix_network::listen(network_address &addr) { return heap(event_port_, fd, 0); } +}} +#include +namespace saw { namespace unix { + conveyor> unix_network::connect(network_address &addr) { auto unix_addr_storage = translate_network_address_to_unix_network_address(addr); @@ -762,6 +766,7 @@ conveyor> unix_network::connect(network_address &addr) { socket_address &addr_iter = address.unix_address(i); int status = ::connect(fd, addr_iter.get_raw(), addr_iter.get_raw_length()); + if (status < 0) { int error = errno; /* @@ -772,16 +777,21 @@ conveyor> unix_network::connect(network_address &addr) { /// @todo Add limit node when implemented if (error == EINPROGRESS) { - /* - Conveyor write_ready = io_stream->writeReady(); - return write_ready.then( - [ios{std::move(io_stream)}]() mutable { - ios->write_ready = nullptr; - return std::move(ios); - }); - */ - success = true; - break; + conveyor write_rdy = io_str->write_ready(); + + return write_rdy.then([ios = std::move(io_str)] () mutable -> error_or> { + + if(!ios){ + return make_error("Limit node invalidated"); + } + own mov_ios = std::move(ios); + /** + * This guarantees the old async pipe to not be used anymore + */ + mov_ios->write_ready(); + + return std::move(mov_ios); + }); } else if (error != EINTR) { /// @todo Push error message from return conveyor>{make_error()}; -- cgit v1.2.3