Bump parking_lot to 0.11.1. Revert std mutex from #277 (#350)

This commit is contained in:
rakita 2021-04-27 13:12:19 +02:00 committed by GitHub
parent 392a909cb7
commit be9b16ab67
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
26 changed files with 207 additions and 179 deletions

220
Cargo.lock generated
View File

@ -1,5 +1,20 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
[[package]]
name = "addr2line"
version = "0.14.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a55f82cfe485775d02112886f4169bde0c5894d75e79ead7eafe7e40a25e45f7"
dependencies = [
"gimli",
]
[[package]]
name = "adler"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
[[package]]
name = "adler32"
version = "1.2.0"
@ -155,26 +170,18 @@ checksum = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d"
[[package]]
name = "backtrace"
version = "0.3.40"
version = "0.3.56"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "924c76597f0d9ca25d762c25a4d369d51267536465dc5064bdf0eb073ed477ea"
checksum = "9d117600f438b1707d4e4ae15d3595657288f8235a0eb593e80ecc98ab34e1bc"
dependencies = [
"backtrace-sys",
"cfg-if 0.1.10",
"addr2line",
"cfg-if 1.0.0",
"libc",
"miniz_oxide",
"object",
"rustc-demangle",
]
[[package]]
name = "backtrace-sys"
version = "0.1.32"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5d6575f128516de27e3ce99689419835fce9643a9b215a14d2b5b685be018491"
dependencies = [
"cc",
"libc",
]
[[package]]
name = "base64"
version = "0.9.3"
@ -278,7 +285,7 @@ dependencies = [
"byteorder",
"criterion 0.3.0",
"ethbloom",
"parking_lot 0.7.1",
"parking_lot 0.11.1",
"tempdir",
"tiny-keccak 1.5.0",
]
@ -922,7 +929,7 @@ dependencies = [
"keccak-hash",
"log",
"memmap",
"parking_lot 0.7.1",
"parking_lot 0.11.1",
"primal",
"rustc-hex 1.0.0",
"serde_json",
@ -998,7 +1005,7 @@ dependencies = [
"parity-runtime",
"parity-snappy",
"parity-util-mem",
"parking_lot 0.7.1",
"parking_lot 0.11.1",
"patricia-trie-ethereum",
"rand 0.7.3",
"rand_xorshift 0.2.0",
@ -1038,7 +1045,7 @@ dependencies = [
"ethstore",
"log",
"parity-crypto",
"parking_lot 0.7.1",
"parking_lot 0.11.1",
"serde",
"serde_derive",
"serde_json",
@ -1064,7 +1071,7 @@ dependencies = [
"parity-bytes",
"parity-crypto",
"parity-util-mem",
"parking_lot 0.7.1",
"parking_lot 0.11.1",
"rand 0.7.3",
"rayon",
"rlp",
@ -1124,7 +1131,7 @@ dependencies = [
"kvdb-memorydb",
"kvdb-rocksdb",
"parity-util-mem",
"parking_lot 0.7.1",
"parking_lot 0.11.1",
"rlp",
"rlp_derive",
"stats",
@ -1140,7 +1147,7 @@ dependencies = [
"log",
"mio",
"num_cpus",
"parking_lot 0.7.1",
"parking_lot 0.11.1",
"slab 0.4.2",
"time",
"timer",
@ -1157,7 +1164,7 @@ dependencies = [
"env_logger",
"lazy_static",
"log",
"parking_lot 0.7.1",
"parking_lot 0.11.1",
"regex 1.3.9",
"time",
]
@ -1186,7 +1193,7 @@ dependencies = [
"parity-crypto",
"parity-runtime",
"parity-util-mem",
"parking_lot 0.7.1",
"parking_lot 0.11.1",
"price-info",
"rlp",
"rustc-hex 1.0.0",
@ -1242,7 +1249,7 @@ dependencies = [
"parity-crypto",
"parity-path",
"parity-snappy",
"parking_lot 0.7.1",
"parking_lot 0.11.1",
"rand 0.7.3",
"rlp",
"rust-crypto",
@ -1284,7 +1291,7 @@ dependencies = [
"jsonrpc-tcp-server",
"keccak-hash",
"log",
"parking_lot 0.7.1",
"parking_lot 0.11.1",
"tokio",
"tokio-io",
]
@ -1316,7 +1323,7 @@ dependencies = [
"parity-bytes",
"parity-crypto",
"parity-util-mem",
"parking_lot 0.7.1",
"parking_lot 0.11.1",
"primitive-types",
"rand 0.7.3",
"rand_xorshift 0.2.0",
@ -1419,7 +1426,7 @@ dependencies = [
"matches",
"parity-crypto",
"parity-wordlist",
"parking_lot 0.7.1",
"parking_lot 0.11.1",
"rand 0.7.3",
"rustc-hex 1.0.0",
"serde",
@ -1440,7 +1447,7 @@ dependencies = [
"ethstore",
"num_cpus",
"panic_hook",
"parking_lot 0.7.1",
"parking_lot 0.11.1",
"rustc-hex 1.0.0",
"serde",
"serde_derive",
@ -1463,7 +1470,7 @@ dependencies = [
"num-bigint 0.2.3",
"parity-bytes",
"parity-util-mem",
"parking_lot 0.7.1",
"parking_lot 0.11.1",
"rustc-hex 1.0.0",
"vm",
]
@ -1589,9 +1596,9 @@ dependencies = [
[[package]]
name = "fixedbitset"
version = "0.1.9"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "86d4de0081402f5e88cdac65c8dcdcc73118c1a7a465e2a05f0da05843a8ea33"
checksum = "37ab347416e802de484e4d03c7316c48f1ecb56574dfd4a46a80f173ce1de04d"
[[package]]
name = "fnv"
@ -1704,6 +1711,12 @@ dependencies = [
"wasi 0.10.2+wasi-snapshot-preview1",
]
[[package]]
name = "gimli"
version = "0.23.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f6503fe142514ca4799d4c26297c4248239fe8838d827db6bd6065c6ed29a6ce"
[[package]]
name = "globset"
version = "0.4.5"
@ -2085,6 +2098,15 @@ dependencies = [
"adler32",
]
[[package]]
name = "instant"
version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "61124eeebbd69b8190558df225adf7e4caafce0d743919e5d6b19652314ec5ec"
dependencies = [
"cfg-if 1.0.0",
]
[[package]]
name = "interleaved-ordered"
version = "0.1.1"
@ -2156,7 +2178,7 @@ dependencies = [
"memory-db 0.11.0",
"parity-bytes",
"parity-util-mem",
"parking_lot 0.7.1",
"parking_lot 0.11.1",
"rlp",
]
@ -2381,14 +2403,14 @@ checksum = "b294d6fa9ee409a054354afc4352b0b9ef7ca222c69b8812cbea9e7d2bf3783f"
name = "len-caching-lock"
version = "0.1.1"
dependencies = [
"parking_lot 0.7.1",
"parking_lot 0.11.1",
]
[[package]]
name = "libc"
version = "0.2.65"
version = "0.2.89"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a31a0627fdf1f6a39ec0dd577e101440b7db22672c0901fe00a9a6fbb5c24e8"
checksum = "538c092e5586f4cdd7dd8078c4a79220e3e168880218124dcbce860f0ea938c6"
[[package]]
name = "libloading"
@ -2436,6 +2458,15 @@ dependencies = [
"scopeguard 1.1.0",
]
[[package]]
name = "lock_api"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a3c91c24eae6777794bb1997ad98bbb87daf92890acab859f7eaa4320333176"
dependencies = [
"scopeguard 1.1.0",
]
[[package]]
name = "log"
version = "0.4.8"
@ -2600,6 +2631,16 @@ version = "0.3.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd1d63acd1b78403cc0c325605908475dd9b9a3acbf65ed8bcab97e27014afcf"
[[package]]
name = "miniz_oxide"
version = "0.4.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a92518e98c078586bc6c934028adcca4c92a53d6a958196de835170a01d84e4b"
dependencies = [
"adler",
"autocfg 1.0.0",
]
[[package]]
name = "mio"
version = "0.6.22"
@ -2708,7 +2749,7 @@ dependencies = [
"kvdb-memorydb",
"log",
"lru-cache",
"parking_lot 0.7.1",
"parking_lot 0.11.1",
"tempdir",
]
@ -2811,6 +2852,12 @@ dependencies = [
"num-traits 0.2.8",
]
[[package]]
name = "object"
version = "0.23.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a9a7ab5d64814df0fe4a4b5ead45ed6c5f181ee3ff04ba344313a6c80446c5d4"
[[package]]
name = "ole32-sys"
version = "0.2.0"
@ -2886,7 +2933,7 @@ dependencies = [
"parity-rpc",
"parity-runtime",
"parity-version",
"parking_lot 0.7.1",
"parking_lot 0.11.1",
"pretty_assertions",
"prometheus",
"regex 1.3.9",
@ -2912,12 +2959,6 @@ version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "efa535d5117d3661134dbf1719b6f0ffe06f2375843b13935db186cd094105eb"
[[package]]
name = "ordermap"
version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a86ed3f5f244b372d6b1a00b72ef7f8876d0bc6a78a4c9985c53614041512063"
[[package]]
name = "owning_ref"
version = "0.4.0"
@ -3065,7 +3106,7 @@ dependencies = [
"parity-crypto",
"parity-runtime",
"parity-version",
"parking_lot 0.7.1",
"parking_lot 0.11.1",
"pretty_assertions",
"rand 0.7.3",
"rand_xorshift 0.2.0",
@ -3174,7 +3215,7 @@ dependencies = [
"parity-util-mem-derive",
"parking_lot 0.10.2",
"primitive-types",
"smallvec 1.4.2",
"smallvec 1.6.1",
"winapi 0.3.8",
]
@ -3248,16 +3289,6 @@ dependencies = [
"parking_lot_core 0.3.1",
]
[[package]]
name = "parking_lot"
version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ab41b4aed082705d1056416ae4468b6ea99d52599ecf3169b00088d43113e337"
dependencies = [
"lock_api 0.1.5",
"parking_lot_core 0.4.0",
]
[[package]]
name = "parking_lot"
version = "0.9.0"
@ -3279,6 +3310,17 @@ dependencies = [
"parking_lot_core 0.7.2",
]
[[package]]
name = "parking_lot"
version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6d7744ac029df22dca6284efe4e898991d28e3085c706c972bcd7da4a27a15eb"
dependencies = [
"instant",
"lock_api 0.4.3",
"parking_lot_core 0.8.3",
]
[[package]]
name = "parking_lot_core"
version = "0.3.1"
@ -3292,22 +3334,6 @@ dependencies = [
"winapi 0.3.8",
]
[[package]]
name = "parking_lot_core"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "94c8c7923936b28d546dfd14d4472eaf34c99b14e1c973a32b3e6d4eb04298c9"
dependencies = [
"backtrace",
"libc",
"petgraph",
"rand 0.6.5",
"rustc_version",
"smallvec 0.6.13",
"thread-id",
"winapi 0.3.8",
]
[[package]]
name = "parking_lot_core"
version = "0.6.2"
@ -3317,7 +3343,7 @@ dependencies = [
"cfg-if 0.1.10",
"cloudabi",
"libc",
"redox_syscall",
"redox_syscall 0.1.56",
"rustc_version",
"smallvec 0.6.13",
"winapi 0.3.8",
@ -3332,8 +3358,25 @@ dependencies = [
"cfg-if 0.1.10",
"cloudabi",
"libc",
"redox_syscall",
"smallvec 1.4.2",
"redox_syscall 0.1.56",
"smallvec 1.6.1",
"winapi 0.3.8",
]
[[package]]
name = "parking_lot_core"
version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fa7a782938e745763fe6907fc6ba86946d72f49fe7e21de074e08128a99fb018"
dependencies = [
"backtrace",
"cfg-if 1.0.0",
"instant",
"libc",
"petgraph",
"redox_syscall 0.2.5",
"smallvec 1.6.1",
"thread-id",
"winapi 0.3.8",
]
@ -3382,12 +3425,12 @@ checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e"
[[package]]
name = "petgraph"
version = "0.4.13"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c3659d1ee90221741f65dd128d9998311b0e40c5d3c23a62445938214abce4f"
checksum = "467d164a6de56270bd7c4d070df81d07beace25012d5103ced4e9ff08d6afdb7"
dependencies = [
"fixedbitset",
"ordermap",
"indexmap",
]
[[package]]
@ -3423,7 +3466,7 @@ dependencies = [
"futures",
"log",
"parity-runtime",
"parking_lot 0.7.1",
"parking_lot 0.11.1",
"serde_json",
]
@ -3850,6 +3893,15 @@ version = "0.1.56"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84"
[[package]]
name = "redox_syscall"
version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "94341e4e44e24f6b591b59e47a8a027df12e008d73fd5672dbea9cc22f4507d9"
dependencies = [
"bitflags 1.2.1",
]
[[package]]
name = "regex"
version = "0.2.11"
@ -4293,9 +4345,9 @@ dependencies = [
[[package]]
name = "smallvec"
version = "1.4.2"
version = "1.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fbee7696b84bbf3d89a1c2eccff0850e3047ed46bfcd2e92c29a2d074d57e252"
checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e"
[[package]]
name = "socket2"
@ -4305,7 +4357,7 @@ checksum = "e8b74de517221a2cb01a53349cf54182acdc31a074727d3079068448c0676d85"
dependencies = [
"cfg-if 0.1.10",
"libc",
"redox_syscall",
"redox_syscall 0.1.56",
"winapi 0.3.8",
]
@ -4436,7 +4488,7 @@ dependencies = [
"cfg-if 0.1.10",
"libc",
"rand 0.7.3",
"redox_syscall",
"redox_syscall 0.1.56",
"remove_dir_all",
"winapi 0.3.8",
]
@ -4506,7 +4558,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c7fbf4c9d56b320106cd64fd024dadfa0be7cb4706725fc44a7d7ce952d820c1"
dependencies = [
"libc",
"redox_syscall",
"redox_syscall 0.1.56",
"winapi 0.3.8",
]
@ -4544,7 +4596,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f"
dependencies = [
"libc",
"redox_syscall",
"redox_syscall 0.1.56",
"winapi 0.3.8",
]

View File

@ -22,7 +22,7 @@ number_prefix = "0.2"
rpassword = "1.0"
semver = "0.9"
ansi_term = "0.10"
parking_lot = "0.7"
parking_lot = "0.11.1"
regex = "1.0"
atty = "0.2.8"
toml = "0.4"

View File

@ -11,7 +11,7 @@ num_cpus = "1.6"
rustc-hex = "1.0"
serde = "1.0"
serde_derive = "1.0"
parking_lot = "0.7"
parking_lot = "0.11.1"
ethstore = { path = "../../crates/accounts/ethstore" }
dir = { path = '../../crates/util/dir' }
panic_hook = { path = "../../crates/util/panic-hook" }

View File

@ -12,6 +12,6 @@ atty = "0.2"
lazy_static = "1.0"
regex = "1.0"
time = "0.1"
parking_lot = "0.7"
parking_lot = "0.11.1"
arrayvec = "0.4"
ansi_term = "0.10"

View File

@ -13,7 +13,7 @@ ethkey = { path = "ethkey" }
ethstore = { path = "ethstore" }
log = "0.4"
parity-crypto = { version = "0.6.2", features = [ "publickey" ] }
parking_lot = "0.7"
parking_lot = "0.11.1"
serde = "1.0"
serde_derive = "1.0"
serde_json = "1.0"

View File

@ -15,7 +15,7 @@ serde_derive = "1.0"
rustc-hex = "1.0"
time = "0.1.34"
itertools = "0.5"
parking_lot = "0.7"
parking_lot = "0.11.1"
parity-crypto = { version = "0.6.2", features = [ "publickey"] }
ethereum-types = "0.9.2"
smallvec = "0.6"

View File

@ -12,7 +12,7 @@ keccak-hash = "0.5.0"
tiny-keccak = "2.0.2"
log = "0.4"
memmap = "0.6"
parking_lot = "0.7"
parking_lot = "0.11.1"
primal = "0.2.3"
[dev-dependencies]

View File

@ -29,7 +29,7 @@ log = "0.4"
parity-crypto = { version = "0.6.2", features = [ "publickey" ] }
parity-runtime = { path = "../../runtime/runtime" }
parity-util-mem = "0.7"
parking_lot = "0.7"
parking_lot = "0.11.1"
price-info = { path = "./price-info", optional = true }
rlp = { version = "0.4.6" }
serde = { version = "1.0", features = ["derive"] }

View File

@ -14,5 +14,5 @@ log = "0.4"
serde_json = "1.0"
[dev-dependencies]
parking_lot = "0.7"
parking_lot = "0.11.1"
fake-fetch = { path = "../../../net/fake-fetch" }

View File

@ -11,7 +11,7 @@ keccak-hash = "0.5.0"
jsonrpc-core = "15.0.0"
jsonrpc-tcp-server = "15.0.0"
log = "0.4"
parking_lot = "0.7"
parking_lot = "0.11.1"
[dev-dependencies]
env_logger = "0.5"

View File

@ -7,7 +7,7 @@ authors = ["Parity Technologies <admin@parity.io>"]
[dependencies]
byteorder = "1.2"
ethbloom = "0.9.1"
parking_lot = "0.7"
parking_lot = "0.11.1"
tiny-keccak = "1.4"
[dev-dependencies]

View File

@ -14,7 +14,7 @@ kvdb = "0.1"
kvdb-rocksdb = "0.1.3"
kvdb-memorydb = "0.1"
parity-util-mem = "0.7"
parking_lot = "0.7"
parking_lot = "0.11.1"
rlp = { version = "0.4.6" }
rlp_derive = { path = "../../util/rlp-derive" }
stats = { path = "../../util/stats" }

View File

@ -15,7 +15,7 @@ kvdb = "0.1"
log = "0.4"
memory-db = { path = "../memory-db" }
parity-util-mem = "0.7"
parking_lot = "0.7"
parking_lot = "0.11.1"
fastmap = { path = "../../util/fastmap" }
rlp = { version = "0.4.6" }

View File

@ -52,7 +52,7 @@ parity-bytes = "0.1"
parity-crypto = { version = "0.6.2", features = [ "publickey" ] }
parity-snappy = "0.1"
parity-util-mem = "0.7"
parking_lot = "0.7"
parking_lot = "0.11.1"
trie-db = "0.11.0"
patricia-trie-ethereum = { path = "../db/patricia-trie-ethereum" }
rand = "0.7.3"

View File

@ -20,7 +20,7 @@ log = "0.4"
parity-bytes = "0.1"
parity-crypto = { version = "0.6.2", features = [ "publickey" ] }
parity-util-mem = "0.7"
parking_lot = "0.7"
parking_lot = "0.11.1"
rand = "0.7.3"
rayon = "1.1"
rlp = { version = "0.4.6" }

View File

@ -30,7 +30,7 @@ macros = { path = "../../util/macros" }
parity-bytes = "0.1"
parity-crypto = { version = "0.6.2", features = [ "publickey" ] }
parity-util-mem = "0.7"
parking_lot = "0.7"
parking_lot = "0.11.1"
rand = "0.7.3"
rand_xorshift = "0.2.0"
rlp = { version = "0.4.6" }

View File

@ -108,17 +108,14 @@ use ethereum_types::{H256, U256};
use fastmap::{H256FastMap, H256FastSet};
use hash::keccak;
use network::{self, client_version::ClientVersion, PeerId};
use parking_lot::Mutex;
use parking_lot::{Mutex, RwLock, RwLockWriteGuard};
use rand::{seq::SliceRandom, Rng};
use rlp::{DecoderError, RlpStream};
use snapshot::Snapshot;
use std::{
cmp,
collections::{BTreeMap, HashMap, HashSet},
sync::{
atomic::{AtomicBool, Ordering},
mpsc, RwLock as StdRwLock, RwLockWriteGuard as StdRwLockWriteGuard,
},
sync::mpsc,
time::{Duration, Instant},
};
use sync_io::SyncIo;
@ -405,10 +402,8 @@ pub type Peers = HashMap<PeerId, PeerInfo>;
pub struct ChainSyncApi {
/// Priority tasks queue
priority_tasks: Mutex<mpsc::Receiver<PriorityTask>>,
/// Gate for executing only one priority timer.
priority_tasks_gate: AtomicBool,
/// The rest of sync data
sync: StdRwLock<ChainSync>,
sync: RwLock<ChainSync>,
}
impl ChainSyncApi {
@ -420,33 +415,31 @@ impl ChainSyncApi {
priority_tasks: mpsc::Receiver<PriorityTask>,
) -> Self {
ChainSyncApi {
sync: StdRwLock::new(ChainSync::new(config, chain, fork_filter)),
sync: RwLock::new(ChainSync::new(config, chain, fork_filter)),
priority_tasks: Mutex::new(priority_tasks),
priority_tasks_gate: AtomicBool::new(false),
}
}
/// Gives `write` access to underlying `ChainSync`
pub fn write(&self) -> StdRwLockWriteGuard<ChainSync> {
self.sync.write().unwrap()
pub fn write(&self) -> RwLockWriteGuard<ChainSync> {
self.sync.write()
}
/// Returns info about given list of peers
pub fn peer_info(&self, ids: &[PeerId]) -> Vec<Option<PeerInfoDigest>> {
let sync = self.sync.read().unwrap();
let sync = self.sync.read();
ids.iter().map(|id| sync.peer_info(id)).collect()
}
/// Returns synchonization status
pub fn status(&self) -> SyncStatus {
self.sync.read().unwrap().status()
self.sync.read().status()
}
/// Returns transactions propagation statistics
pub fn transactions_stats(&self) -> BTreeMap<H256, ::TransactionStats> {
self.sync
.read()
.unwrap()
.transactions_stats()
.iter()
.map(|(hash, stats)| (*hash, stats.into()))
@ -460,7 +453,7 @@ impl ChainSyncApi {
/// Process the queue with requests, that were delayed with response.
pub fn process_delayed_requests(&self, io: &mut dyn SyncIo) {
let requests = self.sync.write().unwrap().retrieve_delayed_requests();
let requests = self.sync.write().retrieve_delayed_requests();
if !requests.is_empty() {
debug!(target: "sync", "Processing {} delayed requests", requests.len());
for (peer_id, packet_id, packet_data) in requests {
@ -491,14 +484,6 @@ impl ChainSyncApi {
}
}
if self
.priority_tasks_gate
.compare_exchange(false, true, Ordering::SeqCst, Ordering::SeqCst)
.is_err()
{
return;
}
// deadline to get the task from the queue
let deadline = Instant::now() + ::api::PRIORITY_TIMER_INTERVAL;
let mut work = || {
@ -508,8 +493,9 @@ impl ChainSyncApi {
tasks.recv_timeout(left).ok()?
};
task.starting();
// wait for the sync lock
let mut sync = self.sync.write().unwrap();
// wait for the sync lock until deadline,
// note we might drop the task here if we won't manage to acquire the lock.
let mut sync = self.sync.try_write_until(deadline)?;
// since we already have everything let's use a different deadline
// to do the rest of the job now, so that previous work is not wasted.
let deadline = Instant::now() + PRIORITY_TASK_DEADLINE;
@ -556,7 +542,6 @@ impl ChainSyncApi {
// Process as many items as we can until the deadline is reached.
loop {
if work().is_none() {
self.priority_tasks_gate.store(false, Ordering::SeqCst);
return;
}
}

View File

@ -24,8 +24,9 @@ pub const PAYLOAD_SOFT_LIMIT: usize = 100_000;
use enum_primitive::FromPrimitive;
use ethereum_types::H256;
use network::{self, PeerId};
use parking_lot::RwLock;
use rlp::{Rlp, RlpStream};
use std::{cmp, sync::RwLock as StdRwLock};
use std::cmp;
use types::{ids::BlockId, BlockNumber};
use sync_io::SyncIo;
@ -53,7 +54,7 @@ impl SyncSupplier {
// Take a u8 and not a SyncPacketId because this is the entry point
// to chain sync from the outside world.
pub fn dispatch_packet(
sync: &StdRwLock<ChainSync>,
sync: &RwLock<ChainSync>,
io: &mut dyn SyncIo,
peer: PeerId,
packet_id: u8,
@ -101,12 +102,12 @@ impl SyncSupplier {
),
StatusPacket => {
sync.write().unwrap().on_packet(io, peer, packet_id, data);
sync.write().on_packet(io, peer, packet_id, data);
Ok(())
}
// Packets that require the peer to be confirmed
_ => {
if !sync.read().unwrap().peers.contains_key(&peer) {
if !sync.read().peers.contains_key(&peer) {
debug!(target:"sync", "Unexpected packet {} from unregistered peer: {}:{}", packet_id, peer, io.peer_version(peer));
return;
}
@ -116,17 +117,17 @@ impl SyncSupplier {
ConsensusDataPacket => SyncHandler::on_consensus_packet(io, peer, &rlp),
TransactionsPacket => {
let res = {
let sync_ro = sync.read().unwrap();
let sync_ro = sync.read();
SyncHandler::on_peer_transactions(&*sync_ro, io, peer, &rlp)
};
if res.is_err() {
// peer sent invalid data, disconnect.
io.disable_peer(peer);
sync.write().unwrap().deactivate_peer(io, peer);
sync.write().deactivate_peer(io, peer);
}
}
_ => {
sync.write().unwrap().on_packet(io, peer, packet_id, data);
sync.write().on_packet(io, peer, packet_id, data);
}
}
@ -138,10 +139,9 @@ impl SyncSupplier {
Err(PacketProcessError::Decoder(e)) => {
debug!(target:"sync", "{} -> Malformed packet {} : {}", peer, packet_id, e)
}
Err(PacketProcessError::ClientBusy) => sync
.write()
.unwrap()
.add_delayed_request(peer, packet_id, data),
Err(PacketProcessError::ClientBusy) => {
sync.write().add_delayed_request(peer, packet_id, data)
}
Ok(()) => {}
}
}
@ -150,7 +150,7 @@ impl SyncSupplier {
/// Dispatch delayed request
/// The main difference with dispatch packet is the direct send of the responses to the peer
pub fn dispatch_delayed_request(
sync: &StdRwLock<ChainSync>,
sync: &RwLock<ChainSync>,
io: &mut dyn SyncIo,
peer: PeerId,
packet_id: u8,
@ -178,10 +178,9 @@ impl SyncSupplier {
Err(PacketProcessError::Decoder(e)) => {
debug!(target:"sync", "{} -> Malformed packet {} : {}", peer, packet_id, e)
}
Err(PacketProcessError::ClientBusy) => sync
.write()
.unwrap()
.add_delayed_request(peer, packet_id, data),
Err(PacketProcessError::ClientBusy) => {
sync.write().add_delayed_request(peer, packet_id, data)
}
Ok(()) => {}
}
}
@ -421,7 +420,7 @@ mod test {
use ethereum_types::H256;
use parking_lot::RwLock;
use rlp::{Rlp, RlpStream};
use std::{collections::VecDeque, str::FromStr, sync::RwLock as StdRwLock};
use std::{collections::VecDeque, str::FromStr};
use tests::{helpers::TestIo, snapshot::TestSnapshotService};
#[test]
@ -649,7 +648,7 @@ mod test {
io.sender = Some(2usize);
SyncSupplier::dispatch_packet(
&StdRwLock::new(sync),
&RwLock::new(sync),
&mut io,
0usize,
GetReceiptsPacket.id(),

View File

@ -57,7 +57,7 @@ fn status_after_sync() {
net.peer(1).chain.add_blocks(1000, EachBlockWith::Uncle);
net.peer(2).chain.add_blocks(1000, EachBlockWith::Uncle);
net.sync();
let status = net.peer(0).sync.read().unwrap().status();
let status = net.peer(0).sync.read().status();
assert_eq!(status.state, SyncState::Idle);
}
@ -177,22 +177,19 @@ fn restart() {
assert!(net.peer(0).chain.chain_info().best_block_number > 100);
net.restart_peer(0);
let status = net.peer(0).sync.read().unwrap().status();
let status = net.peer(0).sync.read().status();
assert_eq!(status.state, SyncState::Idle);
}
#[test]
fn status_empty() {
let net = TestNet::new(2);
assert_eq!(
net.peer(0).sync.read().unwrap().status().state,
SyncState::Idle
);
assert_eq!(net.peer(0).sync.read().status().state, SyncState::Idle);
let mut config = SyncConfig::default();
config.warp_sync = WarpSync::Enabled;
let net = TestNet::new_with_config(2, config);
assert_eq!(
net.peer(0).sync.read().unwrap().status().state,
net.peer(0).sync.read().status().state,
SyncState::WaitingPeers
);
}

View File

@ -37,7 +37,7 @@ use network::{self, client_version::ClientVersion, PacketId, PeerId, ProtocolId,
use parking_lot::RwLock;
use std::{
collections::{HashMap, HashSet, VecDeque},
sync::{Arc, RwLock as StdRwLock},
sync::Arc,
};
use sync_io::SyncIo;
use tests::snapshot::*;
@ -249,7 +249,7 @@ where
pub chain: Arc<C>,
pub miner: Arc<Miner>,
pub snapshot_service: Arc<TestSnapshotService>,
pub sync: StdRwLock<ChainSync>,
pub sync: RwLock<ChainSync>,
pub queue: RwLock<VecDeque<TestPacket>>,
pub io_queue: RwLock<VecDeque<ChainMessageType>>,
new_blocks_queue: RwLock<VecDeque<NewBlockMessage>>,
@ -270,17 +270,15 @@ where
fn process_io_message(&self, message: ChainMessageType) {
let mut io = TestIo::new(&*self.chain, &self.snapshot_service, &self.queue, None);
match message {
ChainMessageType::Consensus(data) => self
.sync
.write()
.unwrap()
.propagate_consensus_packet(&mut io, data),
ChainMessageType::Consensus(data) => {
self.sync.write().propagate_consensus_packet(&mut io, data)
}
}
}
fn process_new_block_message(&self, message: NewBlockMessage) {
let mut io = TestIo::new(&*self.chain, &self.snapshot_service, &self.queue, None);
self.sync.write().unwrap().chain_new_blocks(
self.sync.write().chain_new_blocks(
&mut io,
&message.imported,
&message.invalid,
@ -296,8 +294,8 @@ impl<C: FlushingBlockChainClient> Peer for EthPeer<C> {
type Message = TestPacket;
fn on_connect(&self, other: PeerId) {
self.sync.write().unwrap().update_targets(&*self.chain);
self.sync.write().unwrap().on_peer_connected(
self.sync.write().update_targets(&*self.chain);
self.sync.write().on_peer_connected(
&mut TestIo::new(
&*self.chain,
&self.snapshot_service,
@ -315,7 +313,7 @@ impl<C: FlushingBlockChainClient> Peer for EthPeer<C> {
&self.queue,
Some(other),
);
self.sync.write().unwrap().on_peer_aborting(&mut io, other);
self.sync.write().on_peer_aborting(&mut io, other);
}
fn receive_message(&self, from: PeerId, msg: TestPacket) -> HashSet<PeerId> {
@ -342,17 +340,14 @@ impl<C: FlushingBlockChainClient> Peer for EthPeer<C> {
fn sync_step(&self) {
let mut io = TestIo::new(&*self.chain, &self.snapshot_service, &self.queue, None);
self.chain.flush();
self.sync.write().unwrap().maintain_peers(&mut io);
self.sync.write().unwrap().maintain_sync(&mut io);
self.sync.write().unwrap().continue_sync(&mut io);
self.sync
.write()
.unwrap()
.propagate_new_transactions(&mut io);
self.sync.write().maintain_peers(&mut io);
self.sync.write().maintain_sync(&mut io);
self.sync.write().continue_sync(&mut io);
self.sync.write().propagate_new_transactions(&mut io);
}
fn restart_sync(&self) {
self.sync.write().unwrap().restart(&mut TestIo::new(
self.sync.write().restart(&mut TestIo::new(
&*self.chain,
&self.snapshot_service,
&self.queue,
@ -405,7 +400,7 @@ impl TestNet<EthPeer<TestBlockChainClient>> {
let ss = Arc::new(TestSnapshotService::new());
let sync = ChainSync::new(config.clone(), &chain, ForkFilterApi::new_dummy(&chain));
net.peers.push(Arc::new(EthPeer {
sync: StdRwLock::new(sync),
sync: RwLock::new(sync),
snapshot_service: ss,
chain: Arc::new(chain),
miner: Arc::new(Miner::new_for_tests(&Spec::new_test(), None)),
@ -454,7 +449,7 @@ impl TestNet<EthPeer<EthcoreClient>> {
let ss = Arc::new(TestSnapshotService::new());
let sync = ChainSync::new(config, &*client, ForkFilterApi::new_dummy(&*client));
let peer = Arc::new(EthPeer {
sync: StdRwLock::new(sync),
sync: RwLock::new(sync),
snapshot_service: ss,
chain: client,
miner,
@ -563,7 +558,7 @@ where
impl<C: FlushingBlockChainClient> TestNet<EthPeer<C>> {
pub fn trigger_chain_new_blocks(&mut self, peer_id: usize) {
let peer = &mut self.peers[peer_id];
peer.sync.write().unwrap().chain_new_blocks(
peer.sync.write().chain_new_blocks(
&mut TestIo::new(&*peer.chain, &peer.snapshot_service, &peer.queue, None),
&[],
&[],

View File

@ -16,7 +16,7 @@ rust-crypto = "0.2.34"
slab = "0.2"
igd = "0.7"
libc = "0.2.7"
parking_lot = "0.7"
parking_lot = "0.11.1"
ansi_term = "0.10"
rustc-hex = "1.0"
ethcore-io = { path = "../../runtime/io", features = ["mio"] }

View File

@ -12,7 +12,7 @@ ethcore-network = { path = "../network" }
ethcore-network-devp2p = { path = "../network-devp2p" }
ethereum-types = "0.9.2"
log = "0.4"
parking_lot = "0.7"
parking_lot = "0.11.1"
ethabi = "12.0.0"
ethabi-derive = "12.0.0"
ethabi-contract = "11.0.0"

View File

@ -12,7 +12,7 @@ ansi_term = "0.10"
futures = "0.1.6"
log = "0.4"
order-stat = "0.1"
parking_lot = "0.7"
parking_lot = "0.11.1"
rand = "0.7.3"
rand_xorshift = "0.2.0"
rustc-hex = "1.0"

View File

@ -10,7 +10,7 @@ authors = ["Parity Technologies <admin@parity.io>"]
fnv = "1.0"
mio = { version = "0.6.8", optional = true }
crossbeam-deque = "0.6"
parking_lot = "0.7"
parking_lot = "0.11.1"
log = "0.4"
slab = "0.4"
num_cpus = "1.8"

View File

@ -7,4 +7,4 @@ version = "0.1.1"
authors = ["Parity Technologies <admin@parity.io>"]
[dependencies]
parking_lot = "0.7"
parking_lot = "0.11.1"

View File

@ -13,7 +13,7 @@ log = "0.4"
vm = { path = "../vm" }
keccak-hash = "0.5.0"
parity-util-mem = "0.7"
parking_lot = "0.7"
parking_lot = "0.11.1"
memory-cache = { path = "../../util/memory-cache" }
ethcore-builtin = { path = "../builtin" }
num-bigint = "0.2"