Fixed the code, apparently there's nothing actually wrong with it

This commit is contained in:
techmetx11 2024-05-02 14:00:56 +01:00
parent 6bd9b67176
commit fda0eeb863
No known key found for this signature in database
GPG Key ID: 20E0C88A0E7E5AF2
2 changed files with 4 additions and 5 deletions

View File

@ -62,7 +62,7 @@ async fn main() {
Ok(x) => x,
Err(x) => {
if x.kind() == std::io::ErrorKind::AddrInUse {
remove_file(socket_url);
remove_file(socket_url).await;
UnixListener::bind(socket_url).unwrap()
} else {
println!("Error occurred while trying to bind: {}", x);
@ -89,12 +89,10 @@ async fn main() {
}
async fn process_socket(state: Arc<GlobalState>, socket: UnixStream) {
let (rd, wr) = socket.into_split();
let decoder = OpcodeDecoder {};
let str = Framed::new(socket, decoder);
let sink = FramedWrite::new(wr, decoder);
let mut stream = FramedRead::new(rd, decoder);
let (sink, mut stream) = str.split();
let arc_sink = Arc::new(Mutex::new(sink));
while let Some(opcode_res) = stream.next().await {

View File

@ -34,6 +34,7 @@ impl Decoder for OpcodeDecoder {
&mut self,
src: &mut tokio_util::bytes::BytesMut,
) -> Result<Option<Self::Item>, Self::Error> {
println!("Decoder length: {}", src.len());
if 5 > src.len() {
return Ok(None);
}