From 9eedcb4271bb9933f1dcca53c2bdbde52beb1ebe Mon Sep 17 00:00:00 2001 From: Grigory Zubankov Date: Tue, 25 Dec 2018 11:09:08 +0300 Subject: [PATCH] fix: linux-386 support --- write_msg.go | 5 ++++- write_msg_go1.9.go | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/write_msg.go b/write_msg.go index 19eaad2..fe9e15e 100644 --- a/write_msg.go +++ b/write_msg.go @@ -6,6 +6,8 @@ import ( "net" "syscall" "unsafe" + + "golang.org/x/sys/unix" ) // 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 } defer f.Close() - _, n, errno := syscall.Syscall(syscall.SYS_SENDMSG, f.Fd(), uintptr(unsafe.Pointer(&msg)), 0) + _, n, errno := syscall.Syscall(unix.SYS_SENDMSG, f.Fd(), uintptr(unsafe.Pointer(&msg)), 0) if errno != 0 { return int(n), errno } + return int(n), nil } diff --git a/write_msg_go1.9.go b/write_msg_go1.9.go index ccc75c3..5e5e368 100644 --- a/write_msg_go1.9.go +++ b/write_msg_go1.9.go @@ -6,6 +6,8 @@ import ( "net" "syscall" "unsafe" + + "golang.org/x/sys/unix" ) // Check function description in write_msg.go @@ -26,7 +28,7 @@ func writeMsgUnix(c *net.UnixConn, oob []byte, addr *net.UnixAddr) (oobn int, er var n uintptr var errno syscall.Errno err = rawConn.Write(func(fd uintptr) bool { - _, n, errno = syscall.Syscall(syscall.SYS_SENDMSG, fd, uintptr(unsafe.Pointer(&msg)), 0) + _, n, errno = syscall.Syscall(unix.SYS_SENDMSG, fd, uintptr(unsafe.Pointer(&msg)), 0) return true }) if err == nil { @@ -34,5 +36,6 @@ func writeMsgUnix(c *net.UnixConn, oob []byte, addr *net.UnixAddr) (oobn int, er err = errno } } + return int(n), err }