Skip to content

Commit 0557e4a

Browse files
author
Gleb Pomykalov
committed
Remove number of sent messages in sendmmsg, because it can be easily retrieved from Vec len. Improve docs
1 parent 9878123 commit 0557e4a

File tree

2 files changed

+21
-18
lines changed

2 files changed

+21
-18
lines changed

src/sys/socket/mod.rs

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -811,9 +811,9 @@ pub struct SendMmsgData<'a, I, C>
811811
pub _lt: std::marker::PhantomData<&'a I>,
812812
}
813813

814-
/// An extension of [`sendmsg`] that allows the caller to transmit multiple
815-
/// messages on a socket using a single system call. (This has performance
816-
/// benefits for some applications.).
814+
/// An extension of `sendmsg` that allows the caller to transmit multiple
815+
/// messages on a socket using a single system call. This has performance
816+
/// benefits for some applications.
817817
///
818818
/// Allocations are performed for cmsgs and to build `msghdr` buffer
819819
///
@@ -823,11 +823,11 @@ pub struct SendMmsgData<'a, I, C>
823823
/// * `data`: Struct that implements `IntoIterator` with `SendMmsgData` items
824824
/// * `flags`: Optional flags passed directly to the operating system.
825825
///
826-
/// Returns tuple, where the first value is number of sent messages, and the second one
827-
/// it a `Vec` with numbers of bytes sent on each appropriate message.
826+
/// # Returns
827+
/// `Vec` with numbers of sent bytes on each sent message.
828828
///
829-
///# References
830-
/// [`sendmmsg`](fn.sendmsg.html)
829+
/// # References
830+
/// [`sendmsg`](fn.sendmsg.html)
831831
#[cfg(any(
832832
target_os = "linux",
833833
target_os = "android",
@@ -839,7 +839,7 @@ pub fn sendmmsg<'a, I, C>(
839839
fd: RawFd,
840840
data: impl std::iter::IntoIterator<Item=&'a SendMmsgData<'a, I, C>>,
841841
flags: MsgFlags
842-
) -> Result<(usize, Vec<usize>)>
842+
) -> Result<Vec<usize>>
843843
where
844844
I: AsRef<[IoVec<&'a [u8]>]> + 'a,
845845
C: AsRef<[ControlMessage<'a>]> + 'a,
@@ -888,7 +888,7 @@ pub fn sendmmsg<'a, I, C>(
888888
sent_bytes[i] = initialized_data[i].msg_len as usize;
889889
}
890890

891-
Ok((sent_messages, sent_bytes))
891+
Ok(sent_bytes)
892892
}
893893

894894

@@ -902,11 +902,11 @@ pub struct RecvMmsgData<'a, I>
902902
pub cmsg_buffer: Option<&'a mut Vec<u8>>,
903903
}
904904

905-
/// An extension of [`recvmsg`] that allows the caller to receive multiple
906-
/// messages from a socket using a single system call. (This has
907-
/// performance benefits for some applications.)
905+
/// An extension of `recvmsg` that allows the caller to receive multiple
906+
/// messages from a socket using a single system call. This has
907+
/// performance benefits for some applications.
908908
///
909-
/// `iov` and `cmsg_buffer` should be constucted similarly to recvmsg
909+
/// `iov` and `cmsg_buffer` should be constructed similarly to `recvmsg`
910910
///
911911
/// Multiple allocations are performed
912912
///
@@ -922,8 +922,12 @@ pub struct RecvMmsgData<'a, I>
922922
/// * `cmsg_buffer`: Space to receive ancillary data. Should be created by
923923
/// [`cmsg_space!`](macro.cmsg_space.html)
924924
///
925+
/// # Returns
926+
/// A `Vec` with multiple `RecvMsg`, one per received message
927+
///
925928
/// # References
926-
/// [`recvmsg`](fn.recvmsg.html)
929+
/// - [`recvmsg`](fn.recvmsg.html)
930+
/// - [`RecvMsg`](struct.RecvMsg.html)
927931
#[cfg(any(
928932
target_os = "linux",
929933
target_os = "android",

test/sys/test_socket.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -282,13 +282,12 @@ mod recvfrom {
282282
);
283283
}
284284
sendmmsg(s, msgs.iter(), flags)
285-
.map(move |(sent_messages, sent_bytes)| {
286-
assert!(sent_messages >= 1);
287-
assert_eq!(sent_bytes.len(), sent_messages);
285+
.map(move |sent_bytes| {
286+
assert!(sent_bytes.len() >= 1);
288287
for sent in &sent_bytes {
289288
assert_eq!(*sent, m.len());
290289
}
291-
sent_messages
290+
sent_bytes.len()
292291
})
293292
});
294293
// UDP sockets should set the from address

0 commit comments

Comments
 (0)