forker: split protocol messages
This commit is contained in:
parent
08b37552e2
commit
e78e9bcd4c
3 changed files with 43 additions and 37 deletions
|
|
@ -1,10 +1,12 @@
|
|||
mod io;
|
||||
mod protocol;
|
||||
|
||||
use {
|
||||
crate::{
|
||||
async_engine::{AsyncEngine, SpawnedFuture},
|
||||
compositor::{DISPLAY, LIBEI_SOCKET, WAYLAND_DISPLAY},
|
||||
forker::io::{IoIn, IoOut},
|
||||
forker::protocol::{ForkerMessage, ServerMessage, bincode_ops},
|
||||
io_uring::IoUring,
|
||||
state::State,
|
||||
utils::{
|
||||
|
|
@ -23,7 +25,6 @@ use {
|
|||
ahash::AHashMap,
|
||||
bincode::Options,
|
||||
log::Level,
|
||||
serde::{Deserialize, Serialize},
|
||||
std::{
|
||||
cell::{Cell, RefCell},
|
||||
env,
|
||||
|
|
@ -37,13 +38,6 @@ use {
|
|||
uapi::{Errno, Fd, IntoUstr, OwnedFd, UstrPtr, c},
|
||||
};
|
||||
|
||||
pub fn bincode_ops() -> impl Options {
|
||||
bincode::DefaultOptions::new()
|
||||
.with_fixint_encoding()
|
||||
.with_little_endian()
|
||||
.with_no_limit()
|
||||
}
|
||||
|
||||
pub struct ForkerProxy {
|
||||
pidfd: Rc<OwnedFd>,
|
||||
socket: Rc<OwnedFd>,
|
||||
|
|
@ -299,34 +293,6 @@ impl ForkerProxy {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
enum ServerMessage {
|
||||
SetEnv {
|
||||
var: Vec<u8>,
|
||||
val: Option<Vec<u8>>,
|
||||
},
|
||||
Spawn {
|
||||
prog: String,
|
||||
args: Vec<String>,
|
||||
env: Vec<(String, Option<String>)>,
|
||||
fds: Vec<i32>,
|
||||
pidfd_id: Option<u32>,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
enum ForkerMessage {
|
||||
Log {
|
||||
level: usize,
|
||||
msg: String,
|
||||
},
|
||||
PidFd {
|
||||
id: u32,
|
||||
success: bool,
|
||||
pid: c::pid_t,
|
||||
},
|
||||
}
|
||||
|
||||
struct Forker {
|
||||
socket: Rc<OwnedFd>,
|
||||
ae: Rc<AsyncEngine>,
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use {
|
|||
|
||||
use {
|
||||
crate::{
|
||||
forker::{ForkerError, bincode_ops},
|
||||
forker::{ForkerError, protocol::bincode_ops},
|
||||
io_uring::IoUring,
|
||||
utils::{
|
||||
buf::DynamicBuf,
|
||||
|
|
|
|||
40
src/forker/protocol.rs
Normal file
40
src/forker/protocol.rs
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
use {
|
||||
bincode::Options,
|
||||
serde::{Deserialize, Serialize},
|
||||
uapi::c,
|
||||
};
|
||||
|
||||
pub(super) fn bincode_ops() -> impl Options {
|
||||
bincode::DefaultOptions::new()
|
||||
.with_fixint_encoding()
|
||||
.with_little_endian()
|
||||
.with_no_limit()
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub(super) enum ServerMessage {
|
||||
SetEnv {
|
||||
var: Vec<u8>,
|
||||
val: Option<Vec<u8>>,
|
||||
},
|
||||
Spawn {
|
||||
prog: String,
|
||||
args: Vec<String>,
|
||||
env: Vec<(String, Option<String>)>,
|
||||
fds: Vec<i32>,
|
||||
pidfd_id: Option<u32>,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub(super) enum ForkerMessage {
|
||||
Log {
|
||||
level: usize,
|
||||
msg: String,
|
||||
},
|
||||
PidFd {
|
||||
id: u32,
|
||||
success: bool,
|
||||
pid: c::pid_t,
|
||||
},
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue