blocking fixup, and actually recvmsg on recvmsg
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
parent
8dd2698556
commit
1282264afc
@ -11,6 +11,7 @@ use std::panic::UnwindSafe;
|
||||
|
||||
use crate::io::pipe::{self, Pipe};
|
||||
use crate::syscall::SyscallStatus;
|
||||
use crate::tools::Fd;
|
||||
|
||||
pub async fn forking_syscall<F>(func: F) -> io::Result<SyscallStatus>
|
||||
where
|
||||
@ -54,9 +55,10 @@ impl Fork {
|
||||
let pid = c_try!(unsafe { libc::fork() });
|
||||
if pid == 0 {
|
||||
drop(pipe_r);
|
||||
let mut pipe_w = unsafe { std::fs::File::from_raw_fd(pipe_w.into_raw_fd()) };
|
||||
|
||||
let mut pipe_w = unsafe { Fd::from_raw_fd(pipe_w.into_raw_fd()) };
|
||||
let _ = std::panic::catch_unwind(move || {
|
||||
pipe_w.set_nonblocking(false).unwrap();
|
||||
let mut pipe_w = unsafe { std::fs::File::from_raw_fd(pipe_w.into_raw_fd()) };
|
||||
let out = match func() {
|
||||
Ok(SyscallStatus::Ok(val)) => Data {
|
||||
val,
|
||||
|
@ -171,7 +171,7 @@ impl IntoRawFd for PolledFd {
|
||||
}
|
||||
|
||||
impl PolledFd {
|
||||
pub fn new(fd: Fd) -> io::Result<Self> {
|
||||
pub fn new(mut fd: Fd) -> io::Result<Self> {
|
||||
fd.set_nonblocking(true).map_err(io_err_other)?;
|
||||
Self::new_with_reactor(fd, self::default_reactor())
|
||||
}
|
||||
|
@ -116,7 +116,7 @@ impl SeqPacketSocket {
|
||||
let fd = self.fd.as_raw_fd();
|
||||
|
||||
self.fd.wrap_read(cx, || {
|
||||
c_result!(unsafe { libc::sendmsg(fd, &mut msg.0 as *mut libc::msghdr, 0) })
|
||||
c_result!(unsafe { libc::recvmsg(fd, &mut msg.0 as *mut libc::msghdr, 0) })
|
||||
.map(|rc| rc as usize)
|
||||
})
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ impl FromRawFd for Fd {
|
||||
}
|
||||
|
||||
impl Fd {
|
||||
pub fn set_nonblocking(&self, nb: bool) -> nix::Result<libc::c_int> {
|
||||
pub fn set_nonblocking(&mut self, nb: bool) -> nix::Result<libc::c_int> {
|
||||
use nix::fcntl;
|
||||
let mut flags =
|
||||
fcntl::OFlag::from_bits(fcntl::fcntl(self.0, fcntl::FcntlArg::F_GETFL)?).unwrap();
|
||||
|
Loading…
Reference in New Issue
Block a user