diff --git a/snix/nix-compat/src/nix_daemon/framing/framed_read.rs b/snix/nix-compat/src/nix_daemon/framing/framed_read.rs index 333924e07..62e584e6d 100644 --- a/snix/nix-compat/src/nix_daemon/framing/framed_read.rs +++ b/snix/nix-compat/src/nix_daemon/framing/framed_read.rs @@ -70,6 +70,12 @@ impl AsyncRead for NixFramedReader { State::Eof => { return Ok(()).into(); } + State::Length { buf, filled: 8 } => { + *this.state = match NonZeroU64::new(u64::from_le_bytes(*buf)) { + None => State::Eof, + Some(remaining) => State::Chunk { remaining }, + }; + } State::Length { buf, filled } => { let bytes_read = { let mut b = ReadBuf::new(&mut buf[*filled as usize..]); @@ -82,13 +88,6 @@ impl AsyncRead for NixFramedReader { } *filled += bytes_read; - - if *filled == 8 { - *this.state = match NonZeroU64::new(u64::from_le_bytes(*buf)) { - None => State::Eof, - Some(remaining) => State::Chunk { remaining }, - }; - } } State::Chunk { remaining } => { let bytes_read = ready!(with_limited(buf, remaining.get(), |buf| {