312393e825
The previous implementation had some slightly questionable memory safety properties (older versions of PyO3 didn't uphold the Rust aliasing rules and would thus create multiple &mut references to #[pyclass] objects). This explains why Backend has internal Mutex<T>s even though all of its methods took &mut self. The solution is to simply make all methods take &self, which luckily doesn't pose too make issues -- most of the code inside Backend already has sufficient locking. The only two things which needed to be explicitly handled where: 1. "self.runtime" which was fairly easy to handle. All usages of the Runtime only require an immutable reference to create a new Handle, so we could switch to OnceCell which provides lazy-initialisation semantics without needing a more heavy-handed Mutex<tokio::runtime::Handle>. 2. "self.sync_abort" was simply wrapped in a Mutex<>, though some of the odd semantics of sync_abort (not being able to handle multiple processes synchronising at the same time) become pretty obvious with this change (for now we just log a warning in that case). In addition, switch to an RAII-style guard to make sure we don't forget to clear the abort_handle. As a result, we now no longer break Rust's aliasing rules and we can build with newer versions of PyO3 which have runtime checks for these things (and build on stable Rust). Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
82 lines
2.3 KiB
TOML
82 lines
2.3 KiB
TOML
[package]
|
|
name = "anki"
|
|
version = "2.1.34" # automatically updated
|
|
edition = "2018"
|
|
authors = ["Ankitects Pty Ltd and contributors"]
|
|
license = "AGPL-3.0-or-later"
|
|
description = "Anki's Rust library code"
|
|
readme = "README.md"
|
|
|
|
[dependencies]
|
|
# pinned as any changes could invalidate sqlite indexes
|
|
unicase = "=2.6.0"
|
|
|
|
nom = "5.1.2"
|
|
failure = "0.1.8"
|
|
prost = "0.6.1"
|
|
bytes = "0.5.5"
|
|
chrono = "0.4.13"
|
|
lazy_static = "1.4.0"
|
|
regex = "1.3.9"
|
|
hex = "0.4.2"
|
|
blake3 = "0.3.5"
|
|
htmlescape = "0.3.1"
|
|
sha1 = "0.6.0"
|
|
unicode-normalization = "0.1.13"
|
|
tempfile = "3.1.0"
|
|
serde = "1.0.114"
|
|
serde_json = "1.0.56"
|
|
tokio = { version = "0.2.21", features = ["fs", "rt-threaded"] }
|
|
serde_derive = "1.0.114"
|
|
zip = "0.5.6"
|
|
serde_tuple = "0.5.0"
|
|
coarsetime = { git = "https://github.com/ankitects/rust-coarsetime.git", branch="old-mac-compat" }
|
|
utime = "0.3.1"
|
|
serde-aux = "0.6.1"
|
|
unic-langid = { version = "0.8.0", features = ["macros"] }
|
|
fluent = { git = "https://github.com/ankitects/fluent-rs.git", branch="32bit-panic" }
|
|
intl-memoizer = { git = "https://github.com/ankitects/fluent-rs.git", branch="32bit-panic" }
|
|
num-format = "0.4.0"
|
|
slog = { version = "2.5.2", features = ["max_level_trace", "release_max_level_debug"] }
|
|
slog-term = "2.6.0"
|
|
slog-async = "2.5.0"
|
|
slog-envlogger = "2.2.0"
|
|
serde_repr = "0.1.6"
|
|
num_enum = "0.5.0"
|
|
futures = "0.3.5"
|
|
rand = "0.7.3"
|
|
num-integer = "0.1.43"
|
|
itertools = "0.9.0"
|
|
flate2 = "1.0.16"
|
|
pin-project = "0.4.22"
|
|
async-compression = { version = "0.3.5", features = ["stream", "gzip"] }
|
|
askama = "0.10.1"
|
|
hyper = "0.13.7"
|
|
once_cell = "1.4.1"
|
|
scopeguard = "1.1.0"
|
|
|
|
[target.'cfg(target_vendor="apple")'.dependencies.rusqlite]
|
|
version = "0.23.1"
|
|
features = ["trace", "functions", "collation"]
|
|
|
|
[target.'cfg(not(target_vendor="apple"))'.dependencies.rusqlite]
|
|
version = "0.23.1"
|
|
features = ["trace", "functions", "collation", "bundled"]
|
|
|
|
[target.'cfg(linux)'.dependencies.reqwest]
|
|
git = "https://github.com/ankitects/reqwest.git"
|
|
rev = "57665e2c2a39db85723ba860f1b570a608bb73f9"
|
|
features = ["json", "socks", "stream", "native-tls-vendored"]
|
|
|
|
[target.'cfg(not(linux))'.dependencies.reqwest]
|
|
git = "https://github.com/ankitects/reqwest.git"
|
|
rev = "57665e2c2a39db85723ba860f1b570a608bb73f9"
|
|
features = ["json", "socks", "stream"]
|
|
|
|
[build-dependencies]
|
|
prost-build = "0.6.1"
|
|
fluent-syntax = "0.9.3"
|
|
|
|
[dev-dependencies]
|
|
env_logger = "0.7.1"
|