♻️ Use u16 instead of newline

This commit is contained in:
Lucy 2022-07-06 11:58:57 -04:00
parent dedfb57285
commit 5bf43a72af
No known key found for this signature in database
GPG key ID: EBC517FAD666BBF1

View file

@ -131,14 +131,14 @@ async fn send_fd(session_tx: &mut WriteHalf<'_>, stream: Vec<UnixStream>) -> Res
.wrap_err("failed to convert streams to file descriptors")?;
let json = serde_json::to_string(&Message::NewPrivilegedClient { count: fds.len() })
.wrap_err("failed to encode json")?;
session_tx
.write_all(&(json.len() as u16).to_le_bytes())
.await
.wrap_err("failed to write length")?;
session_tx
.write_all(json.as_bytes())
.await
.wrap_err("failed to write json")?;
session_tx
.write_all(b"\n")
.await
.wrap_err("failed to write newline")?;
tokio::time::sleep(std::time::Duration::from_micros(100)).await;
let tx: &UnixStream = session_tx.as_ref();
tx.send_with_fd(&[0], &fds).wrap_err("failed to send fd")?;