diff --git a/common/src/api/rest.rs b/common/src/api/rest.rs index 70e1f3055..08f035a88 100644 --- a/common/src/api/rest.rs +++ b/common/src/api/rest.rs @@ -67,9 +67,8 @@ where // Instead of giving the graceful shutduwn future to hyper directly, we // let the spawned task wait on it so that we can enforce a hyper timeout. let shutdown = ShutdownChannel::new(); - let mut shutdown_clone = shutdown.clone(); - let server_shutdown_fut = async move { shutdown_clone.recv().await }; - let graceful_server = server.with_graceful_shutdown(server_shutdown_fut); + let graceful_server = + server.with_graceful_shutdown(shutdown.clone().recv_owned()); let task = LxTask::spawn_named_with_span(task_name, span, async move { tokio::pin!(graceful_server); tokio::select! { diff --git a/common/src/shutdown.rs b/common/src/shutdown.rs index 02890d54a..e6021c533 100644 --- a/common/src/shutdown.rs +++ b/common/src/shutdown.rs @@ -70,6 +70,10 @@ impl ShutdownChannel { } } + pub async fn recv_owned(mut self) { + self.recv().await + } + /// Immediately returns whether a shutdown signal has been sent. pub fn try_recv(&self) -> bool { self.inner.is_closed() diff --git a/node/src/event_handler.rs b/node/src/event_handler.rs index 6d573c79c..a90b523c3 100644 --- a/node/src/event_handler.rs +++ b/node/src/event_handler.rs @@ -75,7 +75,7 @@ impl EventHandler for NodeEventHandler { debug!("Event details: {event:?}"); // TODO(max): Should be possible to remove all clone()s once async event - // handlilng is supported + // handling is supported let lsp = self.lsp.clone(); let wallet = self.wallet.clone(); let channel_manager = self.channel_manager.clone(); @@ -93,6 +93,7 @@ impl EventHandler for NodeEventHandler { // node handles events. So we hack around it by breaking the contract // and just handling the event in a detached task. The long term fix is // to move to async event handling, which should be straightforward. + #[allow(clippy::redundant_async_block)] LxTask::spawn(async move { handle_event( &lsp, diff --git a/node/src/run.rs b/node/src/run.rs index f47fd0354..9af81408d 100644 --- a/node/src/run.rs +++ b/node/src/run.rs @@ -371,14 +371,13 @@ impl UserNode { args.network, activity_tx, ); - let mut owner_shutdown = shutdown.clone(); let (owner_addr, owner_service_fut) = warp::serve(owner_routes) .tls() .preconfigured_tls(owner_tls) // A value of 0 indicates that the OS will assign a port for us .bind_with_graceful_shutdown( ([127, 0, 0, 1], args.owner_port.unwrap_or(0)), - async move { owner_shutdown.recv().await }, + shutdown.clone().recv_owned(), ); let owner_port = owner_addr.port(); info!("Owner service listening on port {}", owner_port); @@ -387,12 +386,11 @@ impl UserNode { // TODO(phlip9): authenticate host<->node // Start warp service for host let host_routes = server::host_routes(args.user_pk, shutdown.clone()); - let mut host_shutdown = shutdown.clone(); let (host_addr, host_service_fut) = warp::serve(host_routes) // A value of 0 indicates that the OS will assign a port for us .try_bind_with_graceful_shutdown( ([127, 0, 0, 1], args.host_port.unwrap_or(0)), - async move { host_shutdown.recv().await }, + shutdown.clone().recv_owned(), ) .context("Failed to bind warp")?; let host_port = host_addr.port(); diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 0f5128577..03d6c7c26 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,5 +1,5 @@ [toolchain] -channel = "nightly-2023-02-08" +channel = "nightly-2023-03-13" components = ["clippy", "rustfmt"] targets = [ # # Remote azure host target