commit 7894dc4ab32dd4ace7e92686e2511c590816a089
parent d6e2a7e42554debce01c6e2b5b36fcd706991786
Author: Drew DeVault <sir@cmpwn.com>
Date: Fri, 16 Dec 2022 11:21:58 +0100
net::tcp::connect: handle NONBLOCK
Diffstat:
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/net/tcp/+freebsd.ha b/net/tcp/+freebsd.ha
@@ -48,7 +48,10 @@ export fn connect(
const sz = ip::native_addrlen(addr);
match (rt::connect(sockfd, &sockaddr, sz)) {
case let err: rt::errno =>
- return errors::errno(err);
+ if (err: int != rt::EINPROGRESS) {
+ return errors::errno(err);
+ };
+ assert(f & rt::SOCK_NONBLOCK == rt::SOCK_NONBLOCK);
case int => void;
};
return io::fdopen(sockfd);
diff --git a/net/tcp/+linux.ha b/net/tcp/+linux.ha
@@ -48,7 +48,10 @@ export fn connect(
const sz = size(rt::sockaddr): u32;
match (rt::connect(sockfd, &sockaddr, sz)) {
case let err: rt::errno =>
- return errors::errno(err);
+ if (err: int != rt::EINPROGRESS) {
+ return errors::errno(err);
+ };
+ assert(f & rt::SOCK_NONBLOCK == rt::SOCK_NONBLOCK);
case int => void;
};
return io::fdopen(sockfd);