melib: update smol to 1.0.0

jmap-eventsource
Manos Pitsidianakis 2020-09-18 13:49:09 +03:00
parent 40b63cc3e0
commit 05e4dbcd5a
Signed by: Manos Pitsidianakis
GPG Key ID: 73627C2F690DF710
7 changed files with 196 additions and 52 deletions

194
Cargo.lock generated
View File

@ -24,6 +24,16 @@ version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cff77d8686867eceff3105329d4698d96c2391c176d5d03adc90c7389162b5b8" checksum = "cff77d8686867eceff3105329d4698d96c2391c176d5d03adc90c7389162b5b8"
[[package]]
name = "async-barrier"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c06293698675eb72e1155867e5982f199d6b6c230dca35bc5ffd9852f470c22a"
dependencies = [
"async-mutex",
"event-listener",
]
[[package]] [[package]]
name = "async-channel" name = "async-channel"
version = "1.4.2" version = "1.4.2"
@ -35,6 +45,114 @@ dependencies = [
"futures-core", "futures-core",
] ]
[[package]]
name = "async-executor"
version = "1.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a831e74aa1937d3bbd3a356f34c23dbc6b6f0abc5160bd5484a9f75d5e76aea8"
dependencies = [
"async-task",
"concurrent-queue",
"fastrand",
"futures-lite",
"once_cell",
]
[[package]]
name = "async-fs"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e3572236ba37147ca2b674a0bd5afd20aec0cd925ab125ab6fad6543960f9002"
dependencies = [
"blocking",
"futures-lite",
]
[[package]]
name = "async-io"
version = "1.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "64c629684e697f58c0e99e5e2d84a840e3b336afbcfdbac7b44c3b1e222c2fd8"
dependencies = [
"concurrent-queue",
"fastrand",
"futures-lite",
"log",
"nb-connect",
"once_cell",
"parking",
"polling",
"vec-arena",
"waker-fn",
]
[[package]]
name = "async-lock"
version = "2.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ab3ad7fb4345397e57c19566844b0eba274b92e5d2d2791bb0664cc441697b95"
dependencies = [
"async-barrier",
"async-mutex",
"async-rwlock",
"async-semaphore",
]
[[package]]
name = "async-mutex"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "66941c2577c4fa351e4ce5fdde8f86c69b88d623f3b955be1bc7362a23434632"
dependencies = [
"event-listener",
]
[[package]]
name = "async-net"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a48af5438be856056bdeb6c5d895148a715be5915fccee49d1e5b50851dc9b8b"
dependencies = [
"async-io",
"blocking",
"futures-lite",
]
[[package]]
name = "async-process"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0bb915df28b8309139bd9c9c700d84c20e5c21385d05378caa84912332d0f6a1"
dependencies = [
"async-io",
"blocking",
"cfg-if",
"event-listener",
"futures-lite",
"once_cell",
"signal-hook",
"winapi 0.3.9",
]
[[package]]
name = "async-rwlock"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6f8978b5ae008b5177da07a1bf1bfbe428f9bdb970c3fca0e92ed1c1930d7f34"
dependencies = [
"async-mutex",
"event-listener",
]
[[package]]
name = "async-semaphore"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "66d2be5973230861689460806b8db059bbd8bcb507cabaa71646ae89f5b2f2ee"
dependencies = [
"event-listener",
]
[[package]] [[package]]
name = "async-stream" name = "async-stream"
version = "0.2.1" version = "0.2.1"
@ -121,15 +239,15 @@ checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a"
[[package]] [[package]]
name = "blocking" name = "blocking"
version = "0.4.7" version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d2468ff7bf85066b4a3678fede6fe66db31846d753ff0adfbfab2c6a6e81612b" checksum = "2640778f8053e72c11f621b0a5175a0560a269282aa98ed85107773ab8e2a556"
dependencies = [ dependencies = [
"async-channel", "async-channel",
"atomic-waker", "atomic-waker",
"fastrand",
"futures-lite", "futures-lite",
"once_cell", "once_cell",
"parking 1.0.6",
"waker-fn", "waker-fn",
] ]
@ -595,15 +713,15 @@ checksum = "de27142b013a8e869c14957e6d2edeef89e97c289e69d042ee3a49acd8b51789"
[[package]] [[package]]
name = "futures-lite" name = "futures-lite"
version = "0.1.11" version = "1.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "97999970129b808f0ccba93211201d431fcc12d7e1ffae03a61b5cedd1a7ced2" checksum = "5b77e08e656f472d8ea84c472fa8b0a7a917883048e1cf2d4e34a323cd0aaf63"
dependencies = [ dependencies = [
"fastrand", "fastrand",
"futures-core", "futures-core",
"futures-io", "futures-io",
"memchr", "memchr",
"parking 2.0.0", "parking",
"pin-project-lite", "pin-project-lite",
"waker-fn", "waker-fn",
] ]
@ -1111,6 +1229,16 @@ dependencies = [
"tempfile", "tempfile",
] ]
[[package]]
name = "nb-connect"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e847c76b390f44529c2071ef06d0b52fbb4bdb04cc8987a5cfa63954c000abca"
dependencies = [
"libc",
"winapi 0.3.9",
]
[[package]] [[package]]
name = "net2" name = "net2"
version = "0.2.35" version = "0.2.35"
@ -1278,12 +1406,6 @@ dependencies = [
"vcpkg", "vcpkg",
] ]
[[package]]
name = "parking"
version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6cb300f271742d4a2a66c01b6b2fa0c83dfebd2e0bf11addb879a3547b4ed87c"
[[package]] [[package]]
name = "parking" name = "parking"
version = "2.0.0" version = "2.0.0"
@ -1351,6 +1473,19 @@ version = "0.3.18"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d36492546b6af1463394d46f0c834346f31548646f6ba10849802c9c9a27ac33" checksum = "d36492546b6af1463394d46f0c834346f31548646f6ba10849802c9c9a27ac33"
[[package]]
name = "polling"
version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0307b8c7f438902536321f63c28cab0362f6ee89f1c7da47e3642ff956641c8b"
dependencies = [
"cfg-if",
"libc",
"log",
"wepoll-sys-stjepang",
"winapi 0.3.9",
]
[[package]] [[package]]
name = "ppv-lite86" name = "ppv-lite86"
version = "0.2.9" version = "0.2.9"
@ -1578,12 +1713,6 @@ dependencies = [
"winapi 0.3.9", "winapi 0.3.9",
] ]
[[package]]
name = "scoped-tls"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ea6a9290e3c9cf0f18145ef7ffa62d68ee0bf5fcd651017e586dc7fd5da448c2"
[[package]] [[package]]
name = "scopeguard" name = "scopeguard"
version = "1.1.0" version = "1.1.0"
@ -1708,23 +1837,20 @@ dependencies = [
[[package]] [[package]]
name = "smol" name = "smol"
version = "0.1.18" version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "620cbb3c6e34da57d3a248cda0cd01cd5848164dc062e764e65d06fe3ea7aed5" checksum = "712d02afa6ac9e7b8c777fd181aff476d009280b54b8c28703d10fa5d7e80d83"
dependencies = [ dependencies = [
"async-task", "async-channel",
"async-executor",
"async-fs",
"async-io",
"async-lock",
"async-net",
"async-process",
"blocking", "blocking",
"concurrent-queue", "futures-lite",
"fastrand",
"futures-io",
"futures-util",
"libc",
"once_cell", "once_cell",
"scoped-tls",
"slab",
"socket2",
"wepoll-sys-stjepang",
"winapi 0.3.9",
] ]
[[package]] [[package]]
@ -1977,6 +2103,12 @@ version = "0.2.10"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6454029bf181f092ad1b853286f23e2c507d8e8194d01d92da4a55c274a5508c" checksum = "6454029bf181f092ad1b853286f23e2c507d8e8194d01d92da4a55c274a5508c"
[[package]]
name = "vec-arena"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eafc1b9b2dfc6f5529177b62cf806484db55b32dc7c9658a118e11bbeb33061d"
[[package]] [[package]]
name = "version_check" name = "version_check"
version = "0.9.2" version = "0.9.2"

View File

@ -44,7 +44,7 @@ rusqlite = {version = "0.24.0", optional = true }
libloading = "0.6.2" libloading = "0.6.2"
futures = "0.3.5" futures = "0.3.5"
smol = "0.1.18" smol = "1.0.0"
async-stream = "0.2.1" async-stream = "0.2.1"
base64 = { version = "0.12.3", optional = true } base64 = { version = "0.12.3", optional = true }
flate2 = { version = "1.0.16", optional = true } flate2 = { version = "1.0.16", optional = true }

View File

@ -50,7 +50,11 @@
* require_auth: true, * require_auth: true,
* }, * },
*}; *};
*std::thread::spawn(|| smol::run(futures::future::pending::<()>())); *
*std::thread::Builder::new().spawn(move || {
* let ex = smol::Executor::new();
* futures::executor::block_on(ex.run(futures::future::pending::<()>()));
*}).unwrap();
* *
*let mut conn = futures::executor::block_on(SmtpConnection::new_connection(conf)).unwrap(); *let mut conn = futures::executor::block_on(SmtpConnection::new_connection(conf)).unwrap();
*futures::executor::block_on(conn.mail_transaction(r#"To: l10@mail.gr *futures::executor::block_on(conn.mail_transaction(r#"To: l10@mail.gr
@ -73,7 +77,7 @@ use crate::error::{MeliError, Result, ResultIntoMeliError};
use futures::io::{AsyncReadExt, AsyncWriteExt}; use futures::io::{AsyncReadExt, AsyncWriteExt};
use native_tls::TlsConnector; use native_tls::TlsConnector;
use smallvec::SmallVec; use smallvec::SmallVec;
use smol::blocking; use smol::unblock;
use smol::Async as AsyncWrapper; use smol::Async as AsyncWrapper;
use std::borrow::Cow; use std::borrow::Cow;
use std::convert::TryFrom; use std::convert::TryFrom;
@ -310,7 +314,9 @@ impl SmtpConnection {
let _path = path.clone(); let _path = path.clone();
socket.set_nonblocking(false)?; socket.set_nonblocking(false)?;
let conn_result = blocking!(connector.connect(&_path, socket)); let conn = unblock(move || connector.connect(&_path, socket))
.await
.chain_err_kind(crate::error::ErrorKind::Network)?;
/* /*
if let Err(native_tls::HandshakeError::WouldBlock(midhandshake_stream)) = if let Err(native_tls::HandshakeError::WouldBlock(midhandshake_stream)) =
conn_result conn_result
@ -332,10 +338,8 @@ impl SmtpConnection {
} }
} }
*/ */
AsyncWrapper::new(Connection::Tls( AsyncWrapper::new(Connection::Tls(conn))
conn_result.chain_err_kind(crate::error::ErrorKind::Network)?, .chain_err_kind(crate::error::ErrorKind::Network)?
))
.chain_err_kind(crate::error::ErrorKind::Network)?
}; };
ret.write_all(b"EHLO meli.delivery\r\n") ret.write_all(b"EHLO meli.delivery\r\n")
.await .await
@ -418,12 +422,15 @@ impl SmtpConnection {
Password::CommandEval(command) => { Password::CommandEval(command) => {
let _command = command.clone(); let _command = command.clone();
let mut output = blocking!(Command::new("sh") let mut output = unblock(move || {
.args(&["-c", &_command]) Command::new("sh")
.stdin(std::process::Stdio::piped()) .args(&["-c", &_command])
.stdout(std::process::Stdio::piped()) .stdin(std::process::Stdio::piped())
.stderr(std::process::Stdio::piped()) .stdout(std::process::Stdio::piped())
.output())?; .stderr(std::process::Stdio::piped())
.output()
})
.await?;
if !output.status.success() { if !output.status.success() {
return Err(MeliError::new(format!( return Err(MeliError::new(format!(
"SMTP password evaluation command `{}` returned {}: {}", "SMTP password evaluation command `{}` returned {}: {}",

View File

@ -132,7 +132,9 @@ impl JobExecutor {
thread::Builder::new() thread::Builder::new()
.name("meli-reactor".to_string()) .name("meli-reactor".to_string())
.spawn(move || { .spawn(move || {
smol::run(futures::future::pending::<()>()); let ex = smol::Executor::new();
futures::executor::block_on(ex.run(futures::future::pending::<()>()));
}) })
.unwrap(); .unwrap();
@ -223,7 +225,7 @@ impl JobExecutor {
F: Future<Output = R> + Send + 'static, F: Future<Output = R> + Send + 'static,
R: Send + 'static, R: Send + 'static,
{ {
self.spawn_specialized(smol::Task::blocking(async move { future.await })) self.spawn_specialized(smol::unblock(move || futures::executor::block_on(future)))
} }
} }

View File

@ -48,7 +48,10 @@ fn main() -> Result<()> {
BackendEventConsumer::new(std::sync::Arc::new(|_, _| ())), BackendEventConsumer::new(std::sync::Arc::new(|_, _| ())),
)?; )?;
std::thread::spawn(|| smol::run(futures::future::pending::<()>())); std::thread::spawn(move || {
let ex = smol::Executor::new();
futures::executor::block_on(ex.run(futures::future::pending::<()>()));
});
(imap.as_any_mut()) (imap.as_any_mut())
.downcast_mut::<ImapType>() .downcast_mut::<ImapType>()
.unwrap() .unwrap()

View File

@ -21,7 +21,6 @@
extern crate melib; extern crate melib;
use melib::Result; use melib::Result;
use melib::*;
/// Parses e-mail from files and prints the debug information of the parsed `Envelope` /// Parses e-mail from files and prints the debug information of the parsed `Envelope`
/// ///

View File

@ -20,9 +20,10 @@ fn main() -> Result<()> {
}, },
envelope_from: String::new(), envelope_from: String::new(),
}; };
for _ in 0..1 { std::thread::spawn(move || {
std::thread::spawn(|| smol::run(futures::future::pending::<()>())); let ex = smol::Executor::new();
} futures::executor::block_on(ex.run(futures::future::pending::<()>()));
});
let mut conn = futures::executor::block_on(SmtpConnection::new_connection(conf)).unwrap(); let mut conn = futures::executor::block_on(SmtpConnection::new_connection(conf)).unwrap();
futures::executor::block_on(conn.mail_transaction( futures::executor::block_on(conn.mail_transaction(