ipcd: implement SO_SNDBUF/SO_RCVBUF socket options

This commit is contained in:
Red Bear OS
2026-07-09 18:43:18 +03:00
parent ad1cf5e7ed
commit 9f3f77cb72
+18 -5
View File
@@ -184,6 +184,8 @@ pub struct Socket {
connection: Option<Connection>,
issued_token: Option<u64>,
ucred: ucred,
sndbuf: i32,
rcvbuf: i32,
}
impl Socket {
@@ -211,6 +213,8 @@ impl Socket {
uid: ctx.uid as _,
gid: ctx.gid as _,
},
sndbuf: 212992, // Linux default
rcvbuf: 212992, // Linux default
}
}
@@ -659,8 +663,14 @@ impl<'sock> UdsStreamScheme<'sock> {
Ok(value_slice.len())
}
libc::SO_SNDBUF => {
// FIXME: implement
Ok(0)
let value = read_num::<i32>(value_slice)?;
socket.sndbuf = value;
Ok(value_slice.len())
}
libc::SO_RCVBUF => {
let value = read_num::<i32>(value_slice)?;
socket.rcvbuf = value;
Ok(value_slice.len())
}
_ => {
eprintln!(
@@ -688,6 +698,8 @@ impl<'sock> UdsStreamScheme<'sock> {
payload[..value.len()].copy_from_slice(&value);
Ok(value.len())
};
let socket_rc = self.get_socket(id)?;
let socket = socket_rc.borrow();
match option {
libc::SO_DOMAIN => write_value(&AF_UNIX.to_le_bytes()),
libc::SO_PEERCRED => {
@@ -701,9 +713,10 @@ impl<'sock> UdsStreamScheme<'sock> {
})
}
libc::SO_SNDBUF => {
//TODO: default value on Linux, should we use something else?
let value: libc::c_int = 212992;
write_value(&value.to_le_bytes())
write_value(&socket.sndbuf.to_le_bytes())
}
libc::SO_RCVBUF => {
write_value(&socket.rcvbuf.to_le_bytes())
}
_ => {
eprintln!(