Use AsyncReadExt::read_exact, not just read (#6977)

This commit is contained in:
Pierre Krieger
2020-08-31 10:55:43 +02:00
committed by GitHub
parent d0a58a7360
commit e9d446a4ce
@@ -148,7 +148,7 @@ where TSubstream: AsyncRead + AsyncWrite + Unpin + Send + 'static,
let mut initial_message = vec![0u8; initial_message_len]; let mut initial_message = vec![0u8; initial_message_len];
if !initial_message.is_empty() { if !initial_message.is_empty() {
socket.read(&mut initial_message).await?; socket.read_exact(&mut initial_message).await?;
} }
let substream = NotificationsInSubstream { let substream = NotificationsInSubstream {
@@ -300,7 +300,7 @@ where TSubstream: AsyncRead + AsyncWrite + Unpin + Send + 'static,
let mut handshake = vec![0u8; handshake_len]; let mut handshake = vec![0u8; handshake_len];
if !handshake.is_empty() { if !handshake.is_empty() {
socket.read(&mut handshake).await?; socket.read_exact(&mut handshake).await?;
} }
Ok((handshake, NotificationsOutSubstream { Ok((handshake, NotificationsOutSubstream {