]> git.proxmox.com Git - pve-lxc-syscalld.git/commitdiff
let SeqPacketSocket methods take immutable self
authorWolfgang Bumiller <w.bumiller@errno.eu>
Sun, 7 Jul 2019 15:28:42 +0000 (17:28 +0200)
committerWolfgang Bumiller <w.bumiller@errno.eu>
Sun, 7 Jul 2019 15:29:10 +0000 (17:29 +0200)
since we can share the socket across threads and still get
full packets sent and received as a whole

Signed-off-by: Wolfgang Bumiller <w.bumiller@errno.eu>
src/main.rs
src/socket.rs

index cbe12d504237916e29ef4c01f4a42f51f807bdf1..cfc1f6512402eaae6225db76417c24c43999a66d 100644 (file)
@@ -64,7 +64,7 @@ async fn handle_client(client: AsyncSeqPacketSocket) {
     }
 }
 
-async fn handle_client_do(mut client: AsyncSeqPacketSocket) -> Result<(), Error> {
+async fn handle_client_do(client: AsyncSeqPacketSocket) -> Result<(), Error> {
     let mut msgbuf = lxcseccomp::ProxyMessageBuffer::new(64)
         .map_err(|e| format_err!("failed to allocate proxy message buffer: {}", e))?;
 
index 137da4befd4ef12ce1f7de5793aca77763a04bfd..46ddb2e79dbbad5256766c7bae3766852a3d7f04 100644 (file)
@@ -26,7 +26,7 @@ impl SeqPacketSocket {
     }
 
     pub fn recv_fds_vectored(
-        &mut self,
+        &self,
         iov: &mut [IoVecMut],
         num_fds: usize,
     ) -> io::Result<(usize, Vec<Fd>)> {
@@ -77,7 +77,7 @@ impl SeqPacketSocket {
     ///
     /// Note that short writes are silently treated as success, since this is a `SOCK_SEQPACKET`,
     /// so neither continuing nor repeating a partial messages makes all that much sense.
-    pub fn sendmsg_vectored(&mut self, iov: &[IoVec]) -> io::Result<()> {
+    pub fn sendmsg_vectored(&self, iov: &[IoVec]) -> io::Result<()> {
         let mut msg: libc::msghdr = unsafe { mem::zeroed() };
         msg.msg_iov = iov.as_ptr() as *const libc::iovec as *mut libc::iovec;
         msg.msg_iovlen = iov.len();
@@ -206,7 +206,7 @@ impl AsyncSeqPacketSocket {
     }
 
     pub fn poll_recv_fds_vectored(
-        &mut self,
+        &self,
         iov: &mut [IoVecMut],
         num_fds: usize,
         cx: &mut Context,
@@ -226,7 +226,7 @@ impl AsyncSeqPacketSocket {
     }
 
     pub async fn recv_fds_vectored(
-        &mut self,
+        &self,
         iov: &mut [IoVecMut<'_>],
         num_fds: usize,
     ) -> io::Result<(usize, Vec<Fd>)> {
@@ -234,7 +234,7 @@ impl AsyncSeqPacketSocket {
     }
 
     pub fn poll_sendmsg_vectored(
-        &mut self,
+        &self,
         data: &[IoVec],
         cx: &mut Context,
     ) -> Poll<io::Result<()>> {
@@ -252,7 +252,7 @@ impl AsyncSeqPacketSocket {
         }
     }
 
-    pub async fn sendmsg_vectored(&mut self, data: &[IoVec<'_>]) -> io::Result<()> {
+    pub async fn sendmsg_vectored(&self, data: &[IoVec<'_>]) -> io::Result<()> {
         poll_fn(move |cx| self.poll_sendmsg_vectored(data, cx)).await
     }
 }