| @@ -229,12 +229,12 @@ where | ||||
|     } | ||||
|  | ||||
|     #[inline] | ||||
|     fn bytes(&self) -> &[u8] { | ||||
|     fn chunk(&self) -> &[u8] { | ||||
|         match self.kind { | ||||
|             BufKind::Exact(ref b) => b.bytes(), | ||||
|             BufKind::Limited(ref b) => b.bytes(), | ||||
|             BufKind::Chunked(ref b) => b.bytes(), | ||||
|             BufKind::ChunkedEnd(ref b) => b.bytes(), | ||||
|             BufKind::Exact(ref b) => b.chunk(), | ||||
|             BufKind::Limited(ref b) => b.chunk(), | ||||
|             BufKind::Chunked(ref b) => b.chunk(), | ||||
|             BufKind::ChunkedEnd(ref b) => b.chunk(), | ||||
|         } | ||||
|     } | ||||
|  | ||||
| @@ -249,12 +249,12 @@ where | ||||
|     } | ||||
|  | ||||
|     #[inline] | ||||
|     fn bytes_vectored<'t>(&'t self, dst: &mut [IoSlice<'t>]) -> usize { | ||||
|     fn chunks_vectored<'t>(&'t self, dst: &mut [IoSlice<'t>]) -> usize { | ||||
|         match self.kind { | ||||
|             BufKind::Exact(ref b) => b.bytes_vectored(dst), | ||||
|             BufKind::Limited(ref b) => b.bytes_vectored(dst), | ||||
|             BufKind::Chunked(ref b) => b.bytes_vectored(dst), | ||||
|             BufKind::ChunkedEnd(ref b) => b.bytes_vectored(dst), | ||||
|             BufKind::Exact(ref b) => b.chunks_vectored(dst), | ||||
|             BufKind::Limited(ref b) => b.chunks_vectored(dst), | ||||
|             BufKind::Chunked(ref b) => b.chunks_vectored(dst), | ||||
|             BufKind::ChunkedEnd(ref b) => b.chunks_vectored(dst), | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @@ -295,7 +295,7 @@ impl Buf for ChunkSize { | ||||
|     } | ||||
|  | ||||
|     #[inline] | ||||
|     fn bytes(&self) -> &[u8] { | ||||
|     fn chunk(&self) -> &[u8] { | ||||
|         &self.bytes[self.pos.into()..self.len.into()] | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -186,7 +186,7 @@ where | ||||
|             self.read_buf.reserve(next); | ||||
|         } | ||||
|  | ||||
|         let dst = self.read_buf.bytes_mut(); | ||||
|         let dst = self.read_buf.chunk_mut(); | ||||
|         let dst = unsafe { &mut *(dst as *mut _ as *mut [MaybeUninit<u8>]) }; | ||||
|         let mut buf = ReadBuf::uninit(dst); | ||||
|         match Pin::new(&mut self.io).poll_read(cx, &mut buf) { | ||||
| @@ -231,10 +231,11 @@ where | ||||
|                 return self.poll_flush_flattened(cx); | ||||
|             } | ||||
|  | ||||
|             const MAX_WRITEV_BUFS: usize = 64; | ||||
|             loop { | ||||
|                 let n = { | ||||
|                     let mut iovs = [IoSlice::new(&[]); crate::common::io::MAX_WRITEV_BUFS]; | ||||
|                     let len = self.write_buf.bytes_vectored(&mut iovs); | ||||
|                     let mut iovs = [IoSlice::new(&[]); MAX_WRITEV_BUFS]; | ||||
|                     let len = self.write_buf.chunks_vectored(&mut iovs); | ||||
|                     ready!(Pin::new(&mut self.io).poll_write_vectored(cx, &iovs[..len]))? | ||||
|                 }; | ||||
|                 // TODO(eliza): we have to do this manually because | ||||
| @@ -262,7 +263,7 @@ where | ||||
|     /// that skips some bookkeeping around using multiple buffers. | ||||
|     fn poll_flush_flattened(&mut self, cx: &mut task::Context<'_>) -> Poll<io::Result<()>> { | ||||
|         loop { | ||||
|             let n = ready!(Pin::new(&mut self.io).poll_write(cx, self.write_buf.headers.bytes()))?; | ||||
|             let n = ready!(Pin::new(&mut self.io).poll_write(cx, self.write_buf.headers.chunk()))?; | ||||
|             debug!("flushed {} bytes", n); | ||||
|             self.write_buf.headers.advance(n); | ||||
|             if self.write_buf.headers.remaining() == 0 { | ||||
| @@ -433,7 +434,7 @@ impl<T: AsRef<[u8]>> Buf for Cursor<T> { | ||||
|     } | ||||
|  | ||||
|     #[inline] | ||||
|     fn bytes(&self) -> &[u8] { | ||||
|     fn chunk(&self) -> &[u8] { | ||||
|         &self.bytes.as_ref()[self.pos..] | ||||
|     } | ||||
|  | ||||
| @@ -487,7 +488,7 @@ where | ||||
|                 //but accomplishes the same result. | ||||
|                 loop { | ||||
|                     let adv = { | ||||
|                         let slice = buf.bytes(); | ||||
|                         let slice = buf.chunk(); | ||||
|                         if slice.is_empty() { | ||||
|                             return; | ||||
|                         } | ||||
| @@ -534,12 +535,12 @@ impl<B: Buf> Buf for WriteBuf<B> { | ||||
|     } | ||||
|  | ||||
|     #[inline] | ||||
|     fn bytes(&self) -> &[u8] { | ||||
|         let headers = self.headers.bytes(); | ||||
|     fn chunk(&self) -> &[u8] { | ||||
|         let headers = self.headers.chunk(); | ||||
|         if !headers.is_empty() { | ||||
|             headers | ||||
|         } else { | ||||
|             self.queue.bytes() | ||||
|             self.queue.chunk() | ||||
|         } | ||||
|     } | ||||
|  | ||||
| @@ -559,9 +560,9 @@ impl<B: Buf> Buf for WriteBuf<B> { | ||||
|     } | ||||
|  | ||||
|     #[inline] | ||||
|     fn bytes_vectored<'t>(&'t self, dst: &mut [IoSlice<'t>]) -> usize { | ||||
|         let n = self.headers.bytes_vectored(dst); | ||||
|         self.queue.bytes_vectored(&mut dst[n..]) + n | ||||
|     fn chunks_vectored<'t>(&'t self, dst: &mut [IoSlice<'t>]) -> usize { | ||||
|         let n = self.headers.chunks_vectored(dst); | ||||
|         self.queue.chunks_vectored(&mut dst[n..]) + n | ||||
|     } | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -257,8 +257,8 @@ impl<B: Buf> Buf for SendBuf<B> { | ||||
|     } | ||||
|  | ||||
|     #[inline] | ||||
|     fn bytes(&self) -> &[u8] { | ||||
|         self.0.as_ref().map(|b| b.bytes()).unwrap_or(&[]) | ||||
|     fn chunk(&self) -> &[u8] { | ||||
|         self.0.as_ref().map(|b| b.chunk()).unwrap_or(&[]) | ||||
|     } | ||||
|  | ||||
|     #[inline] | ||||
| @@ -268,7 +268,7 @@ impl<B: Buf> Buf for SendBuf<B> { | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     fn bytes_vectored<'a>(&'a self, dst: &mut [IoSlice<'a>]) -> usize { | ||||
|         self.0.as_ref().map(|b| b.bytes_vectored(dst)).unwrap_or(0) | ||||
|     fn chunks_vectored<'a>(&'a self, dst: &mut [IoSlice<'a>]) -> usize { | ||||
|         self.0.as_ref().map(|b| b.chunks_vectored(dst)).unwrap_or(0) | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -60,7 +60,7 @@ pub(super) fn channel(ping_pong: PingPong, config: Config) -> (Recorder, Ponger) | ||||
|         interval, | ||||
|         timeout: config.keep_alive_timeout, | ||||
|         while_idle: config.keep_alive_while_idle, | ||||
|         timer: tokio::time::sleep(interval), | ||||
|         timer: Box::pin(tokio::time::sleep(interval)), | ||||
|         state: KeepAliveState::Init, | ||||
|     }); | ||||
|  | ||||
| @@ -156,7 +156,7 @@ struct KeepAlive { | ||||
|     while_idle: bool, | ||||
|  | ||||
|     state: KeepAliveState, | ||||
|     timer: Sleep, | ||||
|     timer: Pin<Box<Sleep>>, | ||||
| } | ||||
|  | ||||
| #[cfg(feature = "runtime")] | ||||
| @@ -441,7 +441,7 @@ impl KeepAlive { | ||||
|  | ||||
|                 self.state = KeepAliveState::Scheduled; | ||||
|                 let interval = shared.last_read_at() + self.interval; | ||||
|                 self.timer.reset(interval); | ||||
|                 self.timer.as_mut().reset(interval); | ||||
|             } | ||||
|             KeepAliveState::PingSent => { | ||||
|                 if shared.is_ping_sent() { | ||||
| @@ -450,7 +450,7 @@ impl KeepAlive { | ||||
|  | ||||
|                 self.state = KeepAliveState::Scheduled; | ||||
|                 let interval = shared.last_read_at() + self.interval; | ||||
|                 self.timer.reset(interval); | ||||
|                 self.timer.as_mut().reset(interval); | ||||
|             } | ||||
|             KeepAliveState::Scheduled => (), | ||||
|         } | ||||
| @@ -472,7 +472,7 @@ impl KeepAlive { | ||||
|                 shared.send_ping(); | ||||
|                 self.state = KeepAliveState::PingSent; | ||||
|                 let timeout = Instant::now() + self.timeout; | ||||
|                 self.timer.reset(timeout); | ||||
|                 self.timer.as_mut().reset(timeout); | ||||
|             } | ||||
|             KeepAliveState::Init | KeepAliveState::PingSent => (), | ||||
|         } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user