From 3e1717e53b5a5c93d815212ec3260d2bdf1af633 Mon Sep 17 00:00:00 2001 From: tottoto Date: Tue, 9 May 2023 12:44:41 +0900 Subject: [PATCH] Remove parity-tokio-ipc (#1759) * Remove parity-tokio-ipc * refactor --- Cargo.lock | 113 +++++++++--------------------------------------- Cargo.toml | 3 -- src/commands.rs | 27 ++++++++++-- 3 files changed, 44 insertions(+), 99 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 44f1b84a..62278821 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -14,7 +14,7 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" dependencies = [ - "getrandom 0.2.8", + "getrandom", "once_cell", "version_check", ] @@ -138,7 +138,7 @@ checksum = "f34fac4d7cdaefa2deded0eda2d5d59dbfd43370ff3f856209e72340ae84c294" dependencies = [ "futures", "pin-project", - "rand 0.8.5", + "rand", "tokio", ] @@ -876,17 +876,6 @@ dependencies = [ "version_check", ] -[[package]] -name = "getrandom" -version = "0.1.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" -dependencies = [ - "cfg-if 1.0.0", - "libc", - "wasi 0.9.0+wasi-snapshot-preview1", -] - [[package]] name = "getrandom" version = "0.2.8" @@ -896,7 +885,7 @@ dependencies = [ "cfg-if 1.0.0", "js-sys", "libc", - "wasi 0.11.0+wasi-snapshot-preview1", + "wasi", "wasm-bindgen", ] @@ -1374,7 +1363,7 @@ checksum = "e5d732bc30207a6423068df043e3d02e0735b155ad7ce1a6f76fe2baa5b158de" dependencies = [ "libc", "log", - "wasi 0.11.0+wasi-snapshot-preview1", + "wasi", "windows-sys 0.42.0", ] @@ -1390,7 +1379,7 @@ dependencies = [ "mime", "mime_guess", "quick-error", - "rand 0.8.5", + "rand", "safemem", "tempfile", "twoway", @@ -1402,7 +1391,7 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a51313c5820b0b02bd422f4b44776fbf47961755c74ce64afc73bfad10226c3" dependencies = [ - "getrandom 0.2.8", + "getrandom", ] [[package]] @@ -1479,7 +1468,7 @@ dependencies = [ "num-integer", "num-iter", "num-traits", - "rand 0.8.5", + "rand", "smallvec", "zeroize", ] @@ -1652,20 +1641,6 @@ version = "6.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b7820b9daea5457c9f21c69448905d723fbd21136ccf521748f23fd49e723ee" -[[package]] -name = "parity-tokio-ipc" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9981e32fb75e004cc148f5fb70342f393830e0a4aa62e3cc93b50976218d42b6" -dependencies = [ - "futures", - "libc", - "log", - "rand 0.7.3", - "tokio", - "winapi", -] - [[package]] name = "parking_lot" version = "0.12.1" @@ -1878,19 +1853,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "rand" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" -dependencies = [ - "getrandom 0.1.16", - "libc", - "rand_chacha 0.2.2", - "rand_core 0.5.1", - "rand_hc", -] - [[package]] name = "rand" version = "0.8.5" @@ -1898,18 +1860,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ "libc", - "rand_chacha 0.3.1", - "rand_core 0.6.4", -] - -[[package]] -name = "rand_chacha" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" -dependencies = [ - "ppv-lite86", - "rand_core 0.5.1", + "rand_chacha", + "rand_core", ] [[package]] @@ -1919,16 +1871,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" dependencies = [ "ppv-lite86", - "rand_core 0.6.4", -] - -[[package]] -name = "rand_core" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" -dependencies = [ - "getrandom 0.1.16", + "rand_core", ] [[package]] @@ -1937,16 +1880,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom 0.2.8", -] - -[[package]] -name = "rand_hc" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" -dependencies = [ - "rand_core 0.5.1", + "getrandom", ] [[package]] @@ -1986,7 +1920,7 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" dependencies = [ - "getrandom 0.2.8", + "getrandom", "redox_syscall", "thiserror", ] @@ -2034,7 +1968,7 @@ dependencies = [ "once_cell", "percent-encoding", "quick-xml 0.28.1", - "rand 0.8.5", + "rand", "rsa", "rust-ini", "serde", @@ -2108,7 +2042,7 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9166d72162de3575f950507683fac47e30f6f2c3836b71b7fbc61aa517c9c5f4" dependencies = [ - "rand 0.8.5", + "rand", ] [[package]] @@ -2138,7 +2072,7 @@ dependencies = [ "multipart", "num_cpus", "percent-encoding", - "rand 0.8.5", + "rand", "serde", "serde_derive", "serde_json", @@ -2163,7 +2097,7 @@ dependencies = [ "num-traits", "pkcs1", "pkcs8", - "rand_core 0.6.4", + "rand_core", "sha2", "signature", "subtle", @@ -2304,9 +2238,8 @@ dependencies = [ "once_cell", "opendal", "openssl", - "parity-tokio-ipc", "predicates", - "rand 0.8.5", + "rand", "regex", "reqsign", "reqwest", @@ -2527,7 +2460,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8fe458c98333f9c8152221191a77e2a44e8325d0193484af2e9421a53019e57d" dependencies = [ "digest", - "rand_core 0.6.4", + "rand_core", ] [[package]] @@ -3033,7 +2966,7 @@ dependencies = [ "idna 0.2.3", "ipnet", "lazy_static", - "rand 0.8.5", + "rand", "ring", "rustls", "rustls-pemfile", @@ -3174,7 +3107,7 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1674845326ee10d37ca60470760d4288a6f80f304007d92e5c53bab78c9cfd79" dependencies = [ - "getrandom 0.2.8", + "getrandom", "serde", ] @@ -3253,12 +3186,6 @@ dependencies = [ "try-lock", ] -[[package]] -name = "wasi" -version = "0.9.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" - [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" diff --git a/Cargo.toml b/Cargo.toml index 8dfc0329..ad88a1f0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -104,9 +104,6 @@ daemonize = "0.5" optional = true version = "0.1.10" -[target.'cfg(windows)'.dependencies] -parity-tokio-ipc = "0.9" - [target.'cfg(windows)'.dependencies.winapi] version = "0.3" features = [ diff --git a/src/commands.rs b/src/commands.rs index b09a50c2..30aedb4c 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -164,6 +164,7 @@ fn run_server_process(startup_timeout: Option) -> Result) -> Result) -> Result io::Result { + named_pipe::ServerOptions::new() + .first_pipe_instance(is_first) + .reject_remote_clients(true) + .access_inbound(true) + .access_outbound(true) + .in_buffer_size(65536) + .out_buffer_size(65536) + .create(pipe_name) + } + let startup = async move { - let listener = parity_tokio_ipc::Endpoint::new(pipe_name); - let incoming = listener.incoming()?; + let pipe = create_named_pipe(pipe_name, true)?; + + let incoming = futures::stream::try_unfold(pipe, |listener| async move { + listener.connect().await?; + let new_listener = create_named_pipe(pipe_name, false)?; + Ok::<_, io::Error>(Some((listener, new_listener))) + }); + futures::pin_mut!(incoming); let socket = incoming.next().await; let socket = socket.unwrap(); // incoming() never returns None