net: fix unix sockets (#8697)

pull/8707/head
bettafish04 2021-02-12 19:10:06 +01:00 committed by GitHub
parent 2781a2b923
commit 0b777c68c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View File

@ -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)

View File

@ -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 ? {