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

[Merged by Bors] - Poll shutdown timeout in rpc handler #3153

Closed
wants to merge 2 commits into from
Closed
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
21 changes: 11 additions & 10 deletions beacon_node/lighthouse_network/src/rpc/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ enum HandlerState {
///
/// While in this state the handler rejects new requests but tries to finish existing ones.
/// Once the timer expires, all messages are killed.
ShuttingDown(Box<Sleep>),
ShuttingDown(Pin<Box<Sleep>>),
/// The handler is deactivated. A goodbye has been sent and no more messages are sent or
/// received.
Deactivated,
Expand Down Expand Up @@ -252,7 +252,7 @@ where
self.dial_queue.push((id, OutboundRequest::Goodbye(reason)));
}

self.state = HandlerState::ShuttingDown(Box::new(sleep_until(
self.state = HandlerState::ShuttingDown(Box::pin(sleep_until(
TInstant::now() + Duration::from_secs(SHUTDOWN_TIMEOUT_SECS as u64),
)));
}
Expand Down Expand Up @@ -539,14 +539,15 @@ where
}

// Check if we are shutting down, and if the timer ran out
if let HandlerState::ShuttingDown(delay) = &self.state {
if delay.is_elapsed() {
self.state = HandlerState::Deactivated;
debug!(self.log, "Handler deactivated");
return Poll::Ready(ConnectionHandlerEvent::Close(RPCError::InternalError(
"Shutdown timeout",
)));
}
if let HandlerState::ShuttingDown(delay) = &mut self.state {
match delay.as_mut().poll(cx) {
Poll::Ready(_) => {
self.state = HandlerState::Deactivated;
debug!(self.log, "Handler deactivated");
return Poll::Ready(ConnectionHandlerEvent::Close(RPCError::Disconnected));
}
Poll::Pending => {}
};
}

// purge expired inbound substreams and send an error
Expand Down