net: fix unix sockets (#8697)
parent
2781a2b923
commit
0b777c68c3
|
@ -3,6 +3,10 @@ module unix
|
||||||
import time
|
import time
|
||||||
import net
|
import net
|
||||||
|
|
||||||
|
const (
|
||||||
|
error_ewouldblock = C.EWOULDBLOCK
|
||||||
|
)
|
||||||
|
|
||||||
fn C.SUN_LEN(C.sockaddr_un) int
|
fn C.SUN_LEN(C.sockaddr_un) int
|
||||||
|
|
||||||
fn C.strncpy(charptr, charptr, int)
|
fn C.strncpy(charptr, charptr, int)
|
||||||
|
|
|
@ -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)
|
mut sent := C.send(c.sock.handle, ptr, remaining, unix.msg_nosignal)
|
||||||
if sent < 0 {
|
if sent < 0 {
|
||||||
code := error_code()
|
code := error_code()
|
||||||
if code == int(net.error_ewouldblock) {
|
if code == int(error_ewouldblock) {
|
||||||
c.wait_for_write() ?
|
c.wait_for_write() ?
|
||||||
continue
|
continue
|
||||||
} else {
|
} else {
|
||||||
|
@ -217,7 +217,7 @@ pub fn (mut c StreamConn) read_ptr(buf_ptr byteptr, len int) ?int {
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
code := error_code()
|
code := error_code()
|
||||||
if code == int(net.error_ewouldblock) {
|
if code == int(error_ewouldblock) {
|
||||||
c.wait_for_read() ?
|
c.wait_for_read() ?
|
||||||
res = wrap_read_result(C.recv(c.sock.handle, buf_ptr, len, 0)) ?
|
res = wrap_read_result(C.recv(c.sock.handle, buf_ptr, len, 0)) ?
|
||||||
$if trace_unix ? {
|
$if trace_unix ? {
|
||||||
|
|
Loading…
Reference in New Issue