Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

read the enitre message in one go without copies #108

Merged
merged 4 commits into from
Feb 27, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
reuse cmsgspace
MaxVerevkin committed Feb 25, 2024
commit 5e44e8fb9235707ed278c502d15a4958c5abeed3
6 changes: 4 additions & 2 deletions rustbus/src/connection/ll_conn.rs
Original file line number Diff line number Diff line change
@@ -35,6 +35,7 @@ pub struct RecvConn {
msg_buf_in: Vec<u8>,
msg_buf_filled: usize,
cmsgs_in: Vec<ControlMessageOwned>,
cmsgspace: Vec<u8>,
}

pub struct DuplexConn {
@@ -63,7 +64,7 @@ impl RecvConn {

let iovec = IoSliceMut::new(&mut self.msg_buf_in[self.msg_buf_filled..max_buffer_size]);

let mut cmsgspace = cmsg_space!([RawFd; 10]);
self.cmsgspace.clear();
let flags = MsgFlags::empty();

let old_timeout = self.stream.read_timeout()?;
@@ -82,7 +83,7 @@ impl RecvConn {
let msg = recvmsg::<SockaddrStorage>(
self.stream.as_raw_fd(),
iovec_mut,
Some(&mut cmsgspace),
Some(&mut self.cmsgspace),
flags,
)
.map_err(|e| match e {
@@ -483,6 +484,7 @@ impl DuplexConn {
msg_buf_in: Vec::new(),
msg_buf_filled: 0,
cmsgs_in: Vec::new(),
cmsgspace: cmsg_space!([RawFd; 10]),
stream,
},
})