From 0b777c68c3363001866ecb1b44b12c3350f210b9 Mon Sep 17 00:00:00 2001 From: bettafish04 <55953095+bettafish04@users.noreply.github.com> Date: Fri, 12 Feb 2021 19:10:06 +0100 Subject: [PATCH] net: fix unix sockets (#8697) --- vlib/net/unix/common.v | 4 ++++ vlib/net/unix/stream_nix.v | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/vlib/net/unix/common.v b/vlib/net/unix/common.v index f9c5904697..c2779a5cb8 100644 --- a/vlib/net/unix/common.v +++ b/vlib/net/unix/common.v @@ -3,6 +3,10 @@ module unix import time import net +const ( + error_ewouldblock = C.EWOULDBLOCK +) + fn C.SUN_LEN(C.sockaddr_un) int fn C.strncpy(charptr, charptr, int) diff --git a/vlib/net/unix/stream_nix.v b/vlib/net/unix/stream_nix.v index 98a2484469..50a3ea1cc2 100644 --- a/vlib/net/unix/stream_nix.v +++ b/vlib/net/unix/stream_nix.v @@ -185,7 +185,7 @@ pub fn (mut c StreamConn) write_ptr(b byteptr, len int) ? { mut sent := C.send(c.sock.handle, ptr, remaining, unix.msg_nosignal) if sent < 0 { code := error_code() - if code == int(net.error_ewouldblock) { + if code == int(error_ewouldblock) { c.wait_for_write() ? continue } else { @@ -217,7 +217,7 @@ pub fn (mut c StreamConn) read_ptr(buf_ptr byteptr, len int) ?int { return res } code := error_code() - if code == int(net.error_ewouldblock) { + if code == int(error_ewouldblock) { c.wait_for_read() ? res = wrap_read_result(C.recv(c.sock.handle, buf_ptr, len, 0)) ? $if trace_unix ? {