aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2022-12-06 21:30:16 +0100
committerbptato <nincsnevem662@gmail.com>2022-12-06 21:30:42 +0100
commitf7ab539bfd798c3aed0997c986bd669a9096e1d6 (patch)
treeda323d061b1295479909e142e3fe088f0b41b34e /src
parent198674cd29e809e55713c3275904ad4121420049 (diff)
downloadchawan-f7ab539bfd798c3aed0997c986bd669a9096e1d6.tar.gz
Fix stupid cmsg_len hack
It's still stupid, but now it also does what it should've in the first place...
Diffstat (limited to 'src')
-rw-r--r--src/ips/socketstream.nim6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/ips/socketstream.nim b/src/ips/socketstream.nim
index d3b262ed..1fe99c3b 100644
--- a/src/ips/socketstream.nim
+++ b/src/ips/socketstream.nim
@@ -43,11 +43,11 @@ proc sendFileHandle*(s: SocketStream, fd: FileHandle) =
hdr.msg_iov = addr iov
hdr.msg_iovlen = 1
hdr.msg_control = cmsgbuf
+ hdr.msg_controllen = CMSG_LEN(csize_t(sizeof(FileHandle)))
+ let cmsg = CMSG_FIRSTHDR(addr hdr)
# ...this is stupid.
var xl = CMSG_LEN(csize_t(sizeof(FileHandle)))
- cast[ptr uint16](addr hdr.msg_controllen)[] = cast[ptr uint16](addr xl)[]
- let cmsg = CMSG_FIRSTHDR(addr hdr)
- cmsg.cmsg_len = CMSG_LEN(csize_t(sizeof(FileHandle)))
+ cast[ptr uint16](addr cmsg.cmsg_len)[] = cast[ptr uint16](addr xl)[]
cmsg.cmsg_level = SOL_SOCKET
cmsg.cmsg_type = SCM_RIGHTS
cast[ptr FileHandle](CMSG_DATA(cmsg))[] = fd