Skip to content

Commit

Permalink
Fix hanging test
Browse files Browse the repository at this point in the history
Signed-off-by: Zahari Dichev <zaharidichev@gmail.com>
  • Loading branch information
zaharidichev committed Aug 9, 2020
1 parent c52a1f7 commit e941ec9
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions linkerd/proxy/resolve/src/recover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ use std::net::SocketAddr;
use std::pin::Pin;
use std::task::{Context, Poll};

#[derive(Clone, Debug)]
pub struct Eos(());

#[derive(Clone, Debug)]
pub struct Resolve<E, R> {
resolve: R,
Expand Down Expand Up @@ -71,8 +74,6 @@ enum State<F, R: TryStream, B> {
backoff: Option<B>,
},

Eos,

Backoff(Option<B>),
}

Expand Down Expand Up @@ -216,8 +217,6 @@ where
None => return Poll::Ready(None),
}
}

State::Eos => return Poll::Ready(None),
// XXX(eliza): note that this match was originally an `if let`,
// but that doesn't work with `#[project]` for some kinda reason
_ => {}
Expand Down Expand Up @@ -319,10 +318,13 @@ where
initial: Some(initial),
}
}
None => State::Eos,
None => State::Recover {
error: Some(Eos(()).into()),
backoff: backoff.take(),
},
},

State::Connected { .. } | State::Eos => return Poll::Ready(Ok(())),
State::Connected { .. } => return Poll::Ready(Ok(())),

// If any stage failed, try to recover. If the error is
// recoverable, start (or continue) backing off...
Expand Down Expand Up @@ -402,6 +404,14 @@ fn reconcile_after_connect<E: PartialEq>(
}
}

impl std::fmt::Display for Eos {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "end of stream reached")
}
}

impl std::error::Error for Eos {}

#[cfg(test)]
mod tests {
use super::*;
Expand Down

0 comments on commit e941ec9

Please sign in to comment.