Skip to content

Commit 9eedcb4

Browse files
committed
fix: linux-386 support
1 parent 8b7d855 commit 9eedcb4

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

write_msg.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import (
66
"net"
77
"syscall"
88
"unsafe"
9+
10+
"golang.org/x/sys/unix"
911
)
1012

1113
// Go implementation of sendmsg (UnixConn.WriteMsgUnix) is not suitable
@@ -39,9 +41,10 @@ func writeMsgUnix(c *net.UnixConn, oob []byte, addr *net.UnixAddr) (oobn int, er
3941
}
4042
defer f.Close()
4143

42-
_, n, errno := syscall.Syscall(syscall.SYS_SENDMSG, f.Fd(), uintptr(unsafe.Pointer(&msg)), 0)
44+
_, n, errno := syscall.Syscall(unix.SYS_SENDMSG, f.Fd(), uintptr(unsafe.Pointer(&msg)), 0)
4345
if errno != 0 {
4446
return int(n), errno
4547
}
48+
4649
return int(n), nil
4750
}

write_msg_go1.9.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import (
66
"net"
77
"syscall"
88
"unsafe"
9+
10+
"golang.org/x/sys/unix"
911
)
1012

1113
// Check function description in write_msg.go
@@ -26,13 +28,14 @@ func writeMsgUnix(c *net.UnixConn, oob []byte, addr *net.UnixAddr) (oobn int, er
2628
var n uintptr
2729
var errno syscall.Errno
2830
err = rawConn.Write(func(fd uintptr) bool {
29-
_, n, errno = syscall.Syscall(syscall.SYS_SENDMSG, fd, uintptr(unsafe.Pointer(&msg)), 0)
31+
_, n, errno = syscall.Syscall(unix.SYS_SENDMSG, fd, uintptr(unsafe.Pointer(&msg)), 0)
3032
return true
3133
})
3234
if err == nil {
3335
if errno != 0 {
3436
err = errno
3537
}
3638
}
39+
3740
return int(n), err
3841
}

0 commit comments

Comments
 (0)