From 9383d7ea482986e20c537797e8f788c648fda756 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Tue, 2 Mar 2021 23:04:00 -0500 Subject: upgrade to tokio 1.2 --- src/bin/rbw-agent/agent.rs | 18 +++++++++--------- src/pinentry.rs | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/bin/rbw-agent/agent.rs b/src/bin/rbw-agent/agent.rs index 23f684b..760a1fc 100644 --- a/src/bin/rbw-agent/agent.rs +++ b/src/bin/rbw-agent/agent.rs @@ -1,5 +1,4 @@ use anyhow::Context as _; -use tokio::stream::StreamExt as _; #[derive(Debug)] pub enum TimeoutEvent { @@ -41,7 +40,7 @@ impl State { pub struct Agent { timeout_duration: tokio::time::Duration, - timeout: Option, + timeout: Option>>, timeout_chan: tokio::sync::mpsc::UnboundedReceiver, state: std::sync::Arc>, } @@ -65,7 +64,8 @@ impl Agent { } fn set_timeout(&mut self) { - self.timeout = Some(tokio::time::delay_for(self.timeout_duration)); + self.timeout = + Some(Box::pin(tokio::time::sleep(self.timeout_duration))); } fn clear_timeout(&mut self) { @@ -74,12 +74,12 @@ impl Agent { pub async fn run( &mut self, - mut listener: tokio::net::UnixListener, + listener: tokio::net::UnixListener, ) -> anyhow::Result<()> { // tokio only supports timeouts up to 2^36 milliseconds - let mut forever = tokio::time::delay_for( + let mut forever = Box::pin(tokio::time::sleep( tokio::time::Duration::from_secs(60 * 60 * 24 * 365 * 2), - ); + )); loop { let timeout = if let Some(timeout) = &mut self.timeout { timeout @@ -87,9 +87,9 @@ impl Agent { &mut forever }; tokio::select! { - Some(sock) = listener.next() => { + sock = listener.accept() => { let mut sock = crate::sock::Sock::new( - sock.context("failed to accept incoming connection")? + sock.context("failed to accept incoming connection")?.0 ); let state = self.state.clone(); tokio::spawn(async move { @@ -109,7 +109,7 @@ impl Agent { state.write().await.clear(); }); } - Some(ev) = &mut self.timeout_chan.next() => { + Some(ev) = self.timeout_chan.recv() => { match ev { TimeoutEvent::Set => self.set_timeout(), TimeoutEvent::Clear => self.clear_timeout(), diff --git a/src/pinentry.rs b/src/pinentry.rs index 9711585..683a880 100644 --- a/src/pinentry.rs +++ b/src/pinentry.rs @@ -64,7 +64,7 @@ pub async fn getpin( .await?; buf.truncate(len); - child.await.context(crate::error::PinentryWait)?; + child.wait().await.context(crate::error::PinentryWait)?; Ok(crate::locked::Password::new(buf)) } -- cgit v1.2.3-54-g00ecf