mirror of
https://git.proxmox.com/git/proxmox
synced 2025-05-30 11:10:20 +00:00
update to tokio 1.0
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
This commit is contained in:
parent
c65246e9bd
commit
0319030ed9
@ -16,7 +16,7 @@ use hyper::header::{
|
|||||||
SEC_WEBSOCKET_PROTOCOL, SEC_WEBSOCKET_VERSION, UPGRADE,
|
SEC_WEBSOCKET_PROTOCOL, SEC_WEBSOCKET_VERSION, UPGRADE,
|
||||||
};
|
};
|
||||||
use hyper::{Body, Response, StatusCode};
|
use hyper::{Body, Response, StatusCode};
|
||||||
use tokio::io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt};
|
use tokio::io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt, ReadBuf};
|
||||||
use tokio::sync::mpsc;
|
use tokio::sync::mpsc;
|
||||||
|
|
||||||
use futures::future::FutureExt;
|
use futures::future::FutureExt;
|
||||||
@ -528,10 +528,9 @@ impl<R: AsyncReadExt + Unpin + Send + 'static> AsyncRead for WebSocketReader<R>
|
|||||||
fn poll_read(
|
fn poll_read(
|
||||||
self: Pin<&mut Self>,
|
self: Pin<&mut Self>,
|
||||||
cx: &mut Context,
|
cx: &mut Context,
|
||||||
buf: &mut [u8],
|
buf: &mut ReadBuf,
|
||||||
) -> Poll<io::Result<usize>> {
|
) -> Poll<io::Result<()>> {
|
||||||
let this = Pin::get_mut(self);
|
let this = Pin::get_mut(self);
|
||||||
let mut offset = 0;
|
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
match &mut this.state {
|
match &mut this.state {
|
||||||
@ -569,7 +568,7 @@ impl<R: AsyncReadExt + Unpin + Send + 'static> AsyncRead for WebSocketReader<R>
|
|||||||
this.read_buffer = Some(buffer);
|
this.read_buffer = Some(buffer);
|
||||||
this.state = ReaderState::HaveData;
|
this.state = ReaderState::HaveData;
|
||||||
if len == 0 {
|
if len == 0 {
|
||||||
return Poll::Ready(Ok(0));
|
return Poll::Ready(Ok(()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(err) => return Poll::Ready(Err(err)),
|
Err(err) => return Poll::Ready(Err(err)),
|
||||||
@ -627,14 +626,13 @@ impl<R: AsyncReadExt + Unpin + Send + 'static> AsyncRead for WebSocketReader<R>
|
|||||||
}
|
}
|
||||||
|
|
||||||
let len = min(
|
let len = min(
|
||||||
buf.len() - offset,
|
buf.remaining(),
|
||||||
min(header.payload_len, read_buffer.len()),
|
min(header.payload_len, read_buffer.len()),
|
||||||
);
|
);
|
||||||
|
|
||||||
let mut data = read_buffer.remove_data(len);
|
let mut data = read_buffer.remove_data(len);
|
||||||
mask_bytes(header.mask, &mut data);
|
mask_bytes(header.mask, &mut data);
|
||||||
buf[offset..offset + len].copy_from_slice(&data);
|
buf.put_slice(&data);
|
||||||
offset += len;
|
|
||||||
|
|
||||||
header.payload_len -= len;
|
header.payload_len -= len;
|
||||||
|
|
||||||
@ -649,8 +647,8 @@ impl<R: AsyncReadExt + Unpin + Send + 'static> AsyncRead for WebSocketReader<R>
|
|||||||
};
|
};
|
||||||
this.read_buffer = Some(read_buffer);
|
this.read_buffer = Some(read_buffer);
|
||||||
|
|
||||||
if offset > 0 {
|
if len > 0 {
|
||||||
return Poll::Ready(Ok(offset));
|
return Poll::Ready(Ok(()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user