diff options
author | Vincent Dagonneau <vincentdagonneau@gmail.com> | 2019-04-27 18:45:39 +0200 |
---|---|---|
committer | Vincent Dagonneau <vincentdagonneau@gmail.com> | 2019-04-29 18:52:51 +0200 |
commit | cffb4b33f584bcc1fa6249795cd9160ae95291d2 (patch) | |
tree | 99336681f8c43aa62e7adc772bf3c996014d4331 /src/sys/socket/mod.rs | |
parent | 71b35a07cc1cdd9a367773d391848a3cd314c388 (diff) | |
download | nix-cffb4b33f584bcc1fa6249795cd9160ae95291d2.zip |
Restored the bytes field on RecvMsg in order to know the amount of bytes received using recvmsg.
Diffstat (limited to 'src/sys/socket/mod.rs')
-rw-r--r-- | src/sys/socket/mod.rs | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/sys/socket/mod.rs b/src/sys/socket/mod.rs index 5a054b4b..0ba28358 100644 --- a/src/sys/socket/mod.rs +++ b/src/sys/socket/mod.rs @@ -417,6 +417,7 @@ impl CmsgBuffer for Vec<u8> { #[allow(missing_debug_implementations)] // msghdr isn't Debug pub struct RecvMsg<'a> { + pub bytes: usize, cmsghdr: Option<&'a cmsghdr>, pub address: Option<SockAddr>, pub flags: MsgFlags, @@ -970,7 +971,7 @@ pub fn recvmsg<'a>(fd: RawFd, iov: &[IoVec<&mut [u8]>], let ret = unsafe { libc::recvmsg(fd, &mut mhdr, flags.bits()) }; - Errno::result(ret).map(|_| { + Errno::result(ret).map(|r| { let cmsghdr = unsafe { if mhdr.msg_controllen > 0 { // got control message(s) @@ -986,6 +987,7 @@ pub fn recvmsg<'a>(fd: RawFd, iov: &[IoVec<&mut [u8]>], sockaddr_storage_to_addr(&address, mhdr.msg_namelen as usize).ok() }; RecvMsg { + bytes: r as usize, cmsghdr, address, flags: MsgFlags::from_bits_truncate(mhdr.msg_flags), |