diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 12:36:04 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 12:36:04 +0000 |
commit | b09c6d56832eb1718c07d74abf3bc6ae3fe4e030 (patch) | |
tree | d2caec2610d4ea887803ec9e9c3cd77136c448ba /dependencies/pkg/mod/github.com/ssgreg/journald@v1.0.0/write_msg_go1.9.go | |
parent | Initial commit. (diff) | |
download | icingadb-b09c6d56832eb1718c07d74abf3bc6ae3fe4e030.tar.xz icingadb-b09c6d56832eb1718c07d74abf3bc6ae3fe4e030.zip |
Adding upstream version 1.1.0.upstream/1.1.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dependencies/pkg/mod/github.com/ssgreg/journald@v1.0.0/write_msg_go1.9.go')
-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 +} |