diff options
Diffstat (limited to '')
-rw-r--r-- | dependencies/pkg/mod/github.com/ssgreg/journald@v1.0.0/write_msg_go1.9.go | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/dependencies/pkg/mod/github.com/ssgreg/journald@v1.0.0/write_msg_go1.9.go b/dependencies/pkg/mod/github.com/ssgreg/journald@v1.0.0/write_msg_go1.9.go new file mode 100644 index 0000000..5e5e368 --- /dev/null +++ b/dependencies/pkg/mod/github.com/ssgreg/journald@v1.0.0/write_msg_go1.9.go @@ -0,0 +1,41 @@ +// +build go1.9 + +package journald + +import ( + "net" + "syscall" + "unsafe" + + "golang.org/x/sys/unix" +) + +// Check function description in write_msg.go +func writeMsgUnix(c *net.UnixConn, oob []byte, addr *net.UnixAddr) (oobn int, err error) { + ptr, salen := sockaddr(addr) + + var msg syscall.Msghdr + msg.Name = (*byte)(ptr) + msg.Namelen = uint32(salen) + msg.Control = (*byte)(unsafe.Pointer(&oob[0])) + msg.SetControllen(len(oob)) + + rawConn, err := c.SyscallConn() + if err != nil { + return 0, err + } + + var n uintptr + var errno syscall.Errno + err = rawConn.Write(func(fd uintptr) bool { + _, n, errno = syscall.Syscall(unix.SYS_SENDMSG, fd, uintptr(unsafe.Pointer(&msg)), 0) + return true + }) + if err == nil { + if errno != 0 { + err = errno + } + } + + return int(n), err +} |