aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2021-03-02 23:04:00 -0500
committerJesse Luehrs <doy@tozt.net>2021-03-02 23:04:00 -0500
commit9383d7ea482986e20c537797e8f788c648fda756 (patch)
tree0349dc74e89499f856ef2f5284ff4c9caecacd90 /src
parent791302bdb4f06e4a3d2052dbab243d5c18dd0ab0 (diff)
downloadrbw-9383d7ea482986e20c537797e8f788c648fda756.tar.gz
rbw-9383d7ea482986e20c537797e8f788c648fda756.zip
upgrade to tokio 1.2
Diffstat (limited to 'src')
-rw-r--r--src/bin/rbw-agent/agent.rs18
-rw-r--r--src/pinentry.rs2
2 files changed, 10 insertions, 10 deletions
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<tokio::time::Delay>,
+ timeout: Option<std::pin::Pin<Box<tokio::time::Sleep>>>,
timeout_chan: tokio::sync::mpsc::UnboundedReceiver<TimeoutEvent>,
state: std::sync::Arc<tokio::sync::RwLock<State>>,
}
@@ -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))
}