Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RTR: Flush socket after final write before waiting. #196

Merged
merged 1 commit into from
Feb 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/rtr/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use std::{error, fmt, io};
use std::future::Future;
use std::marker::Unpin;
use tokio::time::{timeout, timeout_at, Duration, Instant};
use tokio::io::{AsyncRead, AsyncWrite};
use tokio::io::{AsyncRead, AsyncWrite, AsyncWriteExt};
use super::payload::{Action, Payload, Timing};
use super::pdu;
use super::state::State;
Expand Down Expand Up @@ -273,6 +273,7 @@ where
pdu::SerialQuery::new(
self.version(), state,
).write(&mut self.sock).await?;
self.sock.flush().await?;
let start = match self.try_io(FirstReply::read).await? {
FirstReply::Response(start) => start,
FirstReply::Reset(_) => {
Expand Down Expand Up @@ -324,6 +325,7 @@ where
pdu::ResetQuery::new(
self.version()
).write(&mut self.sock).await?;
self.sock.flush().await?;
let start = self.try_io(|sock| {
pdu::CacheResponse::read(sock)
}).await?;
Expand Down
7 changes: 5 additions & 2 deletions src/rtr/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use futures_util::future;
use futures_util::pin_mut;
use futures_util::future::Either;
use log::debug;
use tokio::io::{AsyncRead, AsyncWrite};
use tokio::io::{AsyncRead, AsyncWrite, AsyncWriteExt};
use tokio::sync::broadcast;
use tokio::task::spawn;
use tokio_stream::{Stream, StreamExt};
Expand Down Expand Up @@ -401,6 +401,7 @@ impl<Sock: Socket, Source: PayloadSource> Connection<Sock, Source> {
pdu::EndOfData::new(
self.version(), state, timing
).write(&mut self.sock).await?;
self.sock.flush().await?;
self.sock.update(state, true);
Ok(())
}
Expand Down Expand Up @@ -436,6 +437,7 @@ impl<Sock: Socket, Source: PayloadSource> Connection<Sock, Source> {
pdu::EndOfData::new(
self.version(), state, timing
).write(&mut self.sock).await?;
self.sock.flush().await?;
self.sock.update(state, true);
Ok(())
}
Expand All @@ -444,7 +446,8 @@ impl<Sock: Socket, Source: PayloadSource> Connection<Sock, Source> {
async fn error(
&mut self, err: pdu::Error
) -> Result<(), io::Error> {
err.write(&mut self.sock).await
err.write(&mut self.sock).await?;
self.sock.flush().await
}

/// Sends a serial notify query.
Expand Down