Commit 6fff2d19 authored by Tommy Hudson's avatar Tommy Hudson

sendfd: Add a received fd to receiver's read queue

Should have remembered to do this the first time round.
parent 6b563519
......@@ -114,8 +114,8 @@ impl Scheme for SendFdScheme {
match connection {
Connection::Listener { .. } => return Err(Error::new(EINVAL)),
Connection::Sender { other_end } => {
let listeners = self.listeners.read();
let listener = listeners.get(other_end).ok_or(Error::new(EBADF))?;
let listeners = self.listeners.write();
let mut listener = listeners.get_mut(other_end).ok_or(Error::new(EBADF))?;
let mut buf = unsafe {
core::slice::from_raw_parts(
......@@ -125,7 +125,8 @@ impl Scheme for SendFdScheme {
};
let fd_count = buf.len();
let contexts = contexts_mut();
let current = contexts.get(context_id()).ok_or(Error::new(ESRCH))?.write();
let current_ctx_id = context_id();
let current = contexts.get(current_ctx_id).ok_or(Error::new(ESRCH))?.write();
let target = contexts.get(listener.context_id).ok_or(Error::new(ESRCH))?.write();
for &fd in buf {
let desc = current.remove_file(FileHandle::from(fd))
......@@ -145,7 +146,11 @@ impl Scheme for SendFdScheme {
}
}
}
target.add_file(desc);
let target_fd = target.add_file(desc).ok_or(Error::new(EMFILE))?;
listener.read_queue.send(ReceivedFd {
fd: target_fd.into(),
from_pid: current_ctx_id.into(),
});
}
crate::event::trigger(self.scheme_id, id, EVENT_READ);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment