mirror of
https://github.com/ntex-rs/ntex.git
synced 2025-04-04 13:27:39 +03:00
remove unneeded unsafe blocks
This commit is contained in:
parent
4225e093cc
commit
40b0d5e4ab
2 changed files with 7 additions and 10 deletions
|
@ -263,8 +263,7 @@ where
|
||||||
|
|
||||||
// remove written data
|
// remove written data
|
||||||
if written == len {
|
if written == len {
|
||||||
// flushed same amount as in buffer, we dont need to reallocate
|
self.write_buf.clear()
|
||||||
unsafe { self.write_buf.set_len(0) }
|
|
||||||
} else {
|
} else {
|
||||||
self.write_buf.advance(written);
|
self.write_buf.advance(written);
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,9 +117,8 @@ where
|
||||||
Poll::Pending
|
Poll::Pending
|
||||||
}
|
}
|
||||||
IoWriteState::Shutdown(ref mut delay, ref mut st) => {
|
IoWriteState::Shutdown(ref mut delay, ref mut st) => {
|
||||||
// close io, closes WRITE side and wait for disconnect
|
// close WRITE side and wait for disconnect on read side.
|
||||||
// on read side. we have to use disconnect timeout, otherwise it
|
// use disconnect timeout, otherwise it could hang forever.
|
||||||
// could hang forever.
|
|
||||||
loop {
|
loop {
|
||||||
match st {
|
match st {
|
||||||
Shutdown::None => {
|
Shutdown::None => {
|
||||||
|
@ -128,7 +127,6 @@ where
|
||||||
let result = this
|
let result = this
|
||||||
.state
|
.state
|
||||||
.with_write_buf(|buf| flush(&mut *io, buf, cx));
|
.with_write_buf(|buf| flush(&mut *io, buf, cx));
|
||||||
|
|
||||||
match result {
|
match result {
|
||||||
Poll::Ready(Ok(_)) => {
|
Poll::Ready(Ok(_)) => {
|
||||||
*st = Shutdown::Flushed;
|
*st = Shutdown::Flushed;
|
||||||
|
@ -170,7 +168,7 @@ where
|
||||||
match Pin::new(&mut *io).poll_read(cx, &mut buf) {
|
match Pin::new(&mut *io).poll_read(cx, &mut buf) {
|
||||||
Poll::Ready(Ok(0)) | Poll::Ready(Err(_)) => {
|
Poll::Ready(Ok(0)) | Poll::Ready(Err(_)) => {
|
||||||
this.state.set_wr_shutdown_complete();
|
this.state.set_wr_shutdown_complete();
|
||||||
log::trace!("write task is closed");
|
log::trace!("write task is stopped");
|
||||||
return Poll::Ready(());
|
return Poll::Ready(());
|
||||||
}
|
}
|
||||||
Poll::Pending => break,
|
Poll::Pending => break,
|
||||||
|
@ -180,11 +178,12 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// disconnect timeout
|
||||||
if let Some(ref mut delay) = delay {
|
if let Some(ref mut delay) = delay {
|
||||||
futures::ready!(Pin::new(delay).poll(cx));
|
futures::ready!(Pin::new(delay).poll(cx));
|
||||||
}
|
}
|
||||||
this.state.set_wr_shutdown_complete();
|
this.state.set_wr_shutdown_complete();
|
||||||
log::trace!("write task is closed after delay");
|
log::trace!("write task is stopped after delay");
|
||||||
return Poll::Ready(());
|
return Poll::Ready(());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -231,8 +230,7 @@ where
|
||||||
|
|
||||||
// remove written data
|
// remove written data
|
||||||
if written == len {
|
if written == len {
|
||||||
// SAFETY: flushed same amount as in buffer, we dont need to reallocate
|
buf.clear()
|
||||||
unsafe { buf.set_len(0) }
|
|
||||||
} else {
|
} else {
|
||||||
buf.advance(written);
|
buf.advance(written);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue