diff options
author | Igor Matuszewski <igor@sequoia-pgp.org> | 2020-10-20 22:35:56 +0200 |
---|---|---|
committer | Igor Matuszewski <igor@sequoia-pgp.org> | 2020-10-23 12:05:54 +0200 |
commit | c034cee8ff87c2d8e96952eea073d33c8be80d51 (patch) | |
tree | af9ed3d4dec492a40454a354509a2effb60c7af1 /ffi/src/net.rs | |
parent | 3fd21d2f10b9d2946c7c6fd5af8cc38a69402996 (diff) |
ffi: Migrate to tokio 0.2
Diffstat (limited to 'ffi/src/net.rs')
-rw-r--r-- | ffi/src/net.rs | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/ffi/src/net.rs b/ffi/src/net.rs index 01263870..3a4abe2f 100644 --- a/ffi/src/net.rs +++ b/ffi/src/net.rs @@ -37,8 +37,6 @@ use native_tls::Certificate; use std::ptr; use std::slice; -use tokio_core; - use sequoia_net::KeyServer; use super::error::Status; @@ -125,8 +123,8 @@ fn sq_keyserver_get(ctx: *mut Context, let ks = ffi_param_ref_mut!(ks); let id = id.ref_raw(); - let mut core = ffi_try_or!(tokio_core::reactor::Core::new(), None); - core.run(ks.get(&id)).move_into_raw(Some(ctx.errp())) + let mut core = ffi_try_or!(basic_runtime(), None); + core.block_on(ks.get(&id)).move_into_raw(Some(ctx.errp())) } /// Sends the given key to the server. @@ -142,7 +140,16 @@ fn sq_keyserver_send(ctx: *mut Context, let ks = ffi_param_ref_mut!(ks); let cert = cert.ref_raw(); - ffi_try_status!(tokio_core::reactor::Core::new() + ffi_try_status!(basic_runtime() .map_err(|e| e.into()) - .and_then(|mut core| core.run(ks.send(cert)))) + .and_then(|mut rt| rt.block_on(ks.send(cert)))) +} + +/// Constructs a basic Tokio runtime. +fn basic_runtime() -> tokio::io::Result<tokio::runtime::Runtime> { + tokio::runtime::Builder::new() + .basic_scheduler() + .enable_io() + .enable_time() + .build() } |