Skip to content

Commit

Permalink
Write handling improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
fafhrd91 committed Sep 4, 2024
1 parent 4a498b0 commit c991fce
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions ntex-compio/src/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,21 +225,23 @@ async fn write<T: AsyncWrite>(io: &mut T, state: &WriteContext) -> io::Result<()
let BufResult(result, buf1) = io.write(buf).await;
buf = buf1;

match result {
return match result {
Ok(0) => Err(io::Error::new(
io::ErrorKind::WriteZero,
"failed to write frame to transport",
)),

Check warning on line 232 in ntex-compio/src/io.rs

View check run for this annotation

Codecov / codecov/patch

ntex-compio/src/io.rs#L228-L232

Added lines #L228 - L232 were not covered by tests
Ok(size) => {
if buf.0.len() == size {
return io.flush().await;
// return io.flush().await;
state.memory_pool().release_write_buf(buf.0);
Ok(())

Check warning on line 237 in ntex-compio/src/io.rs

View check run for this annotation

Codecov / codecov/patch

ntex-compio/src/io.rs#L236-L237

Added lines #L236 - L237 were not covered by tests
} else {
buf.0.advance(size);
continue;

Check warning on line 240 in ntex-compio/src/io.rs

View check run for this annotation

Codecov / codecov/patch

ntex-compio/src/io.rs#L239-L240

Added lines #L239 - L240 were not covered by tests
}
if size == 0 {
return Err(io::Error::new(
io::ErrorKind::WriteZero,
"failed to write frame to transport",
));
}
buf.0.advance(size);
}
Err(e) => return Err(e),
}
Err(e) => Err(e),

Check warning on line 243 in ntex-compio/src/io.rs

View check run for this annotation

Codecov / codecov/patch

ntex-compio/src/io.rs#L243

Added line #L243 was not covered by tests
};
}
})
.await
Expand Down

0 comments on commit c991fce

Please sign in to comment.