Skip to content

Commit

Permalink
Remove remnants of shutdown process (#1020)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaka authored Mar 28, 2019
1 parent d618b7b commit ebbe197
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 19 deletions.
12 changes: 5 additions & 7 deletions core/src/protocols_handler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,20 +138,18 @@ pub trait ProtocolsHandler {

/// Returns until when the connection should be kept alive.
///
/// If returns `Until`, that indicates that this connection may invoke `shutdown()` after the
/// returned `Instant` has elapsed if they think that they will no longer need the connection
/// in the future. Returning `Forever` is equivalent to "infinite". Returning `Now` is
/// equivalent to `Until(Instant::now())`.
/// If returns `Until`, that indicates that this connection may be closed and this handler
/// destroyed after the returned `Instant` has elapsed if they think that they will no longer
/// need the connection in the future. Returning `Forever` is equivalent to "infinite".
/// Returning `Now` is equivalent to `Until(Instant::now())`.
///
/// On the other hand, the return value is only an indication and doesn't mean that the user
/// will not call `shutdown()`.
/// will not close the connection.
///
/// When multiple `ProtocolsHandler` are combined together, the largest `KeepAlive` should be
/// used.
///
/// The result of this method should be checked every time `poll()` is invoked.
///
/// After `shutdown()` is called, the result of this method doesn't matter anymore.
fn connection_keep_alive(&self) -> KeepAlive;

/// Should behave like `Stream::poll()`.
Expand Down
13 changes: 1 addition & 12 deletions core/src/protocols_handler/one_shot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ where TOutProto: OutboundUpgrade<TSubstream>
{
/// The upgrade for inbound substreams.
listen_protocol: TInProto,
/// If true, we should return as soon as possible.
shutting_down: bool,
/// If `Some`, something bad happened and we should shut down the handler with an error.
pending_error: Option<ProtocolsHandlerUpgrErr<<TOutProto as OutboundUpgrade<TSubstream>>::Error>>,
/// Queue of events to produce in `poll()`.
Expand Down Expand Up @@ -63,7 +61,6 @@ where TOutProto: OutboundUpgrade<TSubstream>
pub fn new(listen_protocol: TInProto) -> Self {
OneShotHandler {
listen_protocol,
shutting_down: false,
pending_error: None,
events_out: SmallVec::new(),
dial_queue: SmallVec::new(),
Expand Down Expand Up @@ -146,10 +143,6 @@ where
&mut self,
out: <Self::InboundProtocol as InboundUpgrade<Self::Substream>>::Output
) {
if self.shutting_down {
return;
}

// If we're shutting down the connection for inactivity, reset the timeout.
if !self.keep_alive.is_forever() {
self.keep_alive = KeepAlive::Until(Instant::now() + self.inactive_timeout);
Expand All @@ -170,10 +163,6 @@ where
self.keep_alive = KeepAlive::Until(Instant::now() + self.inactive_timeout);
}

if self.shutting_down {
return;
}

self.events_out.push(out.into());
}

Expand Down Expand Up @@ -206,7 +195,7 @@ where
}

if !self.dial_queue.is_empty() {
if !self.shutting_down && self.dial_negotiated < self.max_dial_negotiated {
if self.dial_negotiated < self.max_dial_negotiated {
self.dial_negotiated += 1;
return Ok(Async::Ready(ProtocolsHandlerEvent::OutboundSubstreamRequest {
upgrade: self.dial_queue.remove(0),
Expand Down

0 comments on commit ebbe197

Please sign in to comment.