From ae502200c0f500ca9cfe2c96e650d4df6e846b83 Mon Sep 17 00:00:00 2001 From: Scott Lamb Date: Wed, 28 Sep 2022 22:19:35 -0700 Subject: [PATCH] upgrade various Rust dependencies This stops using parking_lot entirely. Since Rust 1.62, the std implementations on Linux are direct futexes, not the boxed pthread mutexes they used to be. No real reason to use parking_lot anymore, so shed this dependency. --- CHANGELOG.md | 3 +- server/Cargo.lock | 86 +++++++++++++++++++---------------- server/Cargo.toml | 17 ++++--- server/base/Cargo.toml | 1 - server/base/clock.rs | 8 ++-- server/base/shutdown.rs | 21 +++++---- server/db/Cargo.toml | 15 +++--- server/db/auth.rs | 6 +-- server/db/db.rs | 24 +++++----- server/db/testutil.rs | 2 +- server/db/upgrade/mod.rs | 2 +- server/db/upgrade/v1_to_v2.rs | 2 +- server/db/upgrade/v5_to_v6.rs | 2 +- server/db/writer.rs | 23 ++++++---- server/src/h264.rs | 2 +- server/src/mp4.rs | 2 +- server/src/streamer.rs | 8 ++-- 17 files changed, 117 insertions(+), 107 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2ecdd68..7ebbf14 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,8 @@ Each release is tagged in Git and on the Docker repository ## unreleased -* use Retina 0.4.1, which is compatible with rtsp-simple-server v0.19.3. +* use Retina 0.4.3, which is newly compatible with rtsp-simple-server v0.19.3 + and some TP-Link cameras. Fixes [#238](https://github.com/scottlamb/moonfire-nvr/issues/238). ## 0.7.5 (2022-05-09) diff --git a/server/Cargo.lock b/server/Cargo.lock index 9e3085d..40a7fad 100644 --- a/server/Cargo.lock +++ b/server/Cargo.lock @@ -115,13 +115,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] -name = "bitreader" -version = "0.3.5" +name = "bitstream-io" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd5bf8a17cdc06d475689f9e9226f4b5bf5610e93cf5c3010a518fe6fb0d97f5" -dependencies = [ - "cfg-if", -] +checksum = "97d524fdb78bf6dc6d2dc4c02043e4b4962ede0a17ae3e13f0ed211a7eda5897" [[package]] name = "blake3" @@ -296,9 +293,9 @@ dependencies = [ [[package]] name = "cursive" -version = "0.17.0" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca536d245342f6c005e7547ab640e444a3dc2fc0319a92124c8c1cbff025e775" +checksum = "f3dc950f7cbc2aeb48ba253623fcd21357b15170a0e7c5f6433081d95808b7fd" dependencies = [ "ahash", "cfg-if", @@ -657,11 +654,12 @@ dependencies = [ [[package]] name = "h264-reader" -version = "0.5.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8d87669bdeca3d51902f1bf1f2c71c8f514a8f3011d9b81e63719b374091da1" +checksum = "a3c095862f1b74a6021f766321767e64fbec34fa76503debbe1da2c04ce23c2c" dependencies = [ - "bitreader", + "bitstream-io", + "hex-slice", "log", "memchr", "rfc6381-codec", @@ -672,17 +670,23 @@ name = "hashbrown" version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" + +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" dependencies = [ "ahash", ] [[package]] name = "hashlink" -version = "0.7.0" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7249a3129cbc1ffccd74857f81464a323a152173cdb134e0fd81bc803b29facf" +checksum = "69fe1fcf8b4278d860ad0548329f892a3631fb63f82574df68275f34cdbe0ffa" dependencies = [ - "hashbrown", + "hashbrown 0.12.3", ] [[package]] @@ -709,6 +713,12 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +[[package]] +name = "hex-slice" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5491a308e0214554f07a81d8944abe45f552871c12e3c3c6e7e5d354039a6c4c" + [[package]] name = "hmac" version = "0.12.1" @@ -838,7 +848,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282a6247722caba404c065016bbfa522806e51714c34f5dfc3e4a3a46fcb4223" dependencies = [ "autocfg", - "hashbrown", + "hashbrown 0.11.2", ] [[package]] @@ -897,15 +907,15 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.119" +version = "0.2.133" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bf2e165bb3457c8e098ea76f3e3bc9db55f87aa90d52d0e6be741470916aaa4" +checksum = "c0f80d65747a3e43d1596c7c5492d95d5edddaabd45a7fcdb02b95f644164966" [[package]] name = "libsqlite3-sys" -version = "0.24.1" +version = "0.25.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb644c388dfaefa18035c12614156d285364769e818893da0dda9030c80ad2ba" +checksum = "9f0455f2c1bc9a7caa792907026e469c1d91761fb0ea37cbb16427c77280cf35" dependencies = [ "cc", "pkg-config", @@ -1021,7 +1031,6 @@ dependencies = [ "libc", "log", "nom", - "parking_lot", "serde", "serde_json", "slab", @@ -1051,7 +1060,6 @@ dependencies = [ "nix", "num-rational", "odds", - "parking_lot", "pretty-hex", "protobuf", "protobuf-codegen", @@ -1096,7 +1104,6 @@ dependencies = [ "nix", "nom", "num-rational", - "parking_lot", "password-hash", "protobuf", "reffers", @@ -1172,15 +1179,16 @@ dependencies = [ [[package]] name = "nix" -version = "0.23.1" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f866317acbd3a240710c63f065ffb1e4fd466259045ccb504130b7f668f35c6" +checksum = "e322c04a9e3440c327fca7b6c8a63e6890a32fa2ad689db972425f07e0d22abb" dependencies = [ + "autocfg", "bitflags", - "cc", "cfg-if", "libc", "memoffset", + "pin-utils", ] [[package]] @@ -1358,9 +1366,9 @@ dependencies = [ [[package]] name = "password-hash" -version = "0.3.2" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d791538a6dcc1e7cb7fe6f6b58aca40e7f79403c45b2bc274008b5e647af1d8" +checksum = "7676374caaee8a325c9e7a2ae557f216c5563a171d6997b0ef8a65af35147700" dependencies = [ "base64ct", "rand_core", @@ -1369,9 +1377,9 @@ dependencies = [ [[package]] name = "pbkdf2" -version = "0.10.1" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "271779f35b581956db91a3e55737327a03aa051e90b1c47aeb189508533adfd7" +checksum = "83a0692ec44e4cf1ef28ca317f14f8f07da2d95ec3fa01f86e4467b725e60917" dependencies = [ "digest", ] @@ -1655,12 +1663,12 @@ dependencies = [ [[package]] name = "retina" -version = "0.4.2" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b99f4f845f11c47edb36a1ac75198c5022eca34b179628d3a14afd7e1c3e7005" +checksum = "23d3ea4f2188bdf8136617a4b5e5827820107ce24407c6a977a45441f12edeb0" dependencies = [ "base64", - "bitreader", + "bitstream-io", "bytes", "futures", "h264-reader", @@ -1721,16 +1729,15 @@ dependencies = [ [[package]] name = "rusqlite" -version = "0.27.0" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85127183a999f7db96d1a976a309eebbfb6ea3b0b400ddd8340190129de6eb7a" +checksum = "01e213bc3ecb39ac32e81e51ebe31fd888a940515173e3a18a35f8c6e896422a" dependencies = [ "bitflags", "fallible-iterator", "fallible-streaming-iterator", "hashlink", "libsqlite3-sys", - "memchr", "smallvec", ] @@ -1763,9 +1770,9 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" [[package]] name = "scrypt" -version = "0.9.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba0aaf3911fff0d942c10a49779de7754699810fc7dbe3df515613b2ecc8195a" +checksum = "9f9e24d2b632954ded8ab2ef9fea0a0c769ea56ea98bddbafbad22caeeadf45d" dependencies = [ "hmac", "password-hash", @@ -2071,7 +2078,6 @@ dependencies = [ "mio", "num_cpus", "once_cell", - "parking_lot", "pin-project-lite", "signal-hook-registry", "socket2", @@ -2286,9 +2292,9 @@ checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" [[package]] name = "uuid" -version = "0.8.2" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" +checksum = "dd6469f4314d5f1ffec476e05f17cc9a78bc7a27a6a857842170bdf8d6f98d2f" dependencies = [ "getrandom", "serde", diff --git a/server/Cargo.toml b/server/Cargo.toml index d238b7b..1d8831c 100644 --- a/server/Cargo.toml +++ b/server/Cargo.toml @@ -11,7 +11,7 @@ rust-version = "1.60" # The nightly feature is used within moonfire-nvr itself to gate the # benchmarks. Also pass it along to crates that can benefit from it. -nightly = ["db/nightly", "parking_lot/nightly"] +nightly = ["db/nightly"] # The bundled feature includes bundled (aka statically linked) versions of # native libraries where possible. @@ -27,12 +27,12 @@ blake3 = "1.0.0" bytes = "1" byteorder = "1.0" clap = { version = "2.33.3", default-features = false, features = ["color", "wrap_help"] } -cursive = "0.17.0" +cursive = "0.19.0" db = { package = "moonfire-db", path = "db" } failure = "0.1.1" futures = "0.3" fnv = "1.0" -h264-reader = "0.5.0" +h264-reader = "0.6.0" http = "0.2.3" http-serve = { version = "0.3.1", features = ["dir"] } hyper = { version = "0.14.2", features = ["http1", "server", "stream", "tcp"] } @@ -41,28 +41,27 @@ libc = "0.2" log = { version = "0.4" } memchr = "2.0.2" mylog = { git = "https://github.com/scottlamb/mylog" } -nix = "0.23.0" +nix = "0.25.0" nom = "7.0.0" -parking_lot = "0.12.0" -password-hash = "0.3.2" +password-hash = "0.4.2" protobuf = "3.0" reffers = "0.7.0" retina = "0.4.0" ring = "0.16.2" -rusqlite = "0.27.0" +rusqlite = "0.28.0" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" smallvec = { version = "1.7", features = ["union"] } structopt = { version = "0.3.13", default-features = false } sync_wrapper = "0.1.0" time = "0.1" -tokio = { version = "1.0", features = ["macros", "parking_lot", "rt-multi-thread", "signal", "sync", "time"] } +tokio = { version = "1.0", features = ["macros", "rt-multi-thread", "signal", "sync", "time"] } tokio-stream = "0.1.5" tokio-tungstenite = "0.17.1" toml = "0.5" tracing = { version = "0.1", features = ["log"] } url = "2.1.1" -uuid = { version = "0.8", features = ["serde", "std", "v4"] } +uuid = { version = "1.1.2", features = ["serde", "std", "v4"] } [dev-dependencies] mp4 = { git = "https://github.com/scottlamb/mp4-rust", branch = "moonfire" } diff --git a/server/base/Cargo.toml b/server/base/Cargo.toml index aacba04..1339971 100644 --- a/server/base/Cargo.toml +++ b/server/base/Cargo.toml @@ -18,7 +18,6 @@ futures = "0.3" lazy_static = "1.0" libc = "0.2" log = "0.4" -parking_lot = "0.12.0" nom = "7.0.0" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" diff --git a/server/base/clock.rs b/server/base/clock.rs index 0354928..1ddb167 100644 --- a/server/base/clock.rs +++ b/server/base/clock.rs @@ -6,8 +6,8 @@ use failure::Error; use log::warn; -use parking_lot::Mutex; use std::mem; +use std::sync::Mutex; use std::sync::{mpsc, Arc}; use std::thread; use std::time::Duration as StdDuration; @@ -160,15 +160,15 @@ impl SimulatedClocks { impl Clocks for SimulatedClocks { fn realtime(&self) -> Timespec { - self.0.boot + *self.0.uptime.lock() + self.0.boot + *self.0.uptime.lock().unwrap() } fn monotonic(&self) -> Timespec { - Timespec::new(0, 0) + *self.0.uptime.lock() + Timespec::new(0, 0) + *self.0.uptime.lock().unwrap() } /// Advances the clock by the specified amount without actually sleeping. fn sleep(&self, how_long: Duration) { - let mut l = self.0.uptime.lock(); + let mut l = self.0.uptime.lock().unwrap(); *l = *l + how_long; } diff --git a/server/base/shutdown.rs b/server/base/shutdown.rs index 618d4c0..c744712 100644 --- a/server/base/shutdown.rs +++ b/server/base/shutdown.rs @@ -16,8 +16,8 @@ use std::sync::Arc; use std::task::{Context, Poll, Waker}; use futures::Future; -use parking_lot::{Condvar, Mutex}; use slab::Slab; +use std::sync::{Condvar, Mutex}; #[derive(Debug)] pub struct ShutdownError; @@ -47,6 +47,7 @@ impl Drop for Sender { .0 .wakers .lock() + .unwrap() .take() .expect("only the single Sender takes the slab"); for w in wakers.drain() { @@ -77,7 +78,7 @@ const NO_WAKER: usize = usize::MAX; impl Receiver { pub fn check(&self) -> Result<(), ShutdownError> { - if self.0.wakers.lock().is_none() { + if self.0.wakers.lock().unwrap().is_none() { Err(ShutdownError) } else { Ok(()) @@ -106,22 +107,22 @@ impl Receiver { } pub fn wait_for(&self, timeout: std::time::Duration) -> Result<(), ShutdownError> { - let mut l = self.0.wakers.lock(); - if l.is_none() { - return Err(ShutdownError); - } - if self.0.condvar.wait_for(&mut l, timeout).timed_out() { + let l = self.0.wakers.lock().unwrap(); + let result = self + .0 + .condvar + .wait_timeout_while(l, timeout, |wakers| wakers.is_some()) + .unwrap(); + if result.1.timed_out() { Ok(()) } else { - // parking_lot guarantees no spurious wakeups. - debug_assert!(l.is_none()); Err(ShutdownError) } } } fn poll_impl(inner: &Inner, waker_i: &mut usize, cx: &mut Context<'_>) -> Poll<()> { - let mut l = inner.wakers.lock(); + let mut l = inner.wakers.lock().unwrap(); let wakers = match &mut *l { None => return Poll::Ready(()), Some(w) => w, diff --git a/server/db/Cargo.toml b/server/db/Cargo.toml index 328a8a3..4b4c6a8 100644 --- a/server/db/Cargo.toml +++ b/server/db/Cargo.toml @@ -22,30 +22,29 @@ diff = "0.1.12" failure = "0.1.1" fnv = "1.0" futures = "0.3" -h264-reader = "0.5.0" -hashlink = "0.7.0" +h264-reader = "0.6.0" +hashlink = "0.8.1" lazy_static = "1.0" libc = "0.2" log = "0.4" mylog = { git = "https://github.com/scottlamb/mylog" } -nix = "0.23.0" +nix = "0.25.0" num-rational = { version = "0.4.0", default-features = false, features = ["std"] } odds = { version = "0.4.0", features = ["std-vec"] } -parking_lot = "0.12.0" pretty-hex = "0.3.0" protobuf = "3.0" ring = "0.16.2" -rusqlite = "0.27.0" -scrypt = "0.9.0" +rusqlite = "0.28.0" +scrypt = "0.10.0" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" #similar = "2.1.0" smallvec = "1.0" tempfile = "3.2.0" time = "0.1" -tokio = { version = "1.0", features = ["macros", "parking_lot", "rt-multi-thread", "sync"] } +tokio = { version = "1.0", features = ["macros", "rt-multi-thread", "sync"] } url = { version = "2.1.1", features = ["serde"] } -uuid = { version = "0.8", features = ["serde", "std", "v4"] } +uuid = { version = "1.1.2", features = ["serde", "std", "v4"] } itertools = "0.10.0" [build-dependencies] diff --git a/server/db/auth.rs b/server/db/auth.rs index 44bc2f8..179fff3 100644 --- a/server/db/auth.rs +++ b/server/db/auth.rs @@ -11,7 +11,6 @@ use failure::{bail, format_err, Error, Fail, ResultExt as _}; use fnv::FnvHashMap; use lazy_static::lazy_static; use log::info; -use parking_lot::Mutex; use protobuf::Message; use ring::rand::{SecureRandom, SystemRandom}; use rusqlite::{named_params, params, Connection, Transaction}; @@ -20,6 +19,7 @@ use std::collections::BTreeMap; use std::fmt; use std::net::IpAddr; use std::str::FromStr; +use std::sync::Mutex; lazy_static! { static ref PARAMS: Mutex = Mutex::new(scrypt::Params::recommended()); @@ -29,7 +29,7 @@ lazy_static! { /// Call via `testutil::init()`. pub(crate) fn set_test_config() { let params = scrypt::Params::new(8, 8, 1).unwrap(); - *PARAMS.lock() = params; + *PARAMS.lock().unwrap() = params; } #[derive(Debug)] @@ -92,7 +92,7 @@ impl UserChange { pub fn set_password(&mut self, pwd: String) { let salt = SaltString::generate(&mut scrypt::password_hash::rand_core::OsRng); - let params = *PARAMS.lock(); + let params = *PARAMS.lock().unwrap(); let hash = scrypt::Scrypt .hash_password_customized(pwd.as_bytes(), None, None, params, &salt) .unwrap(); diff --git a/server/db/db.rs b/server/db/db.rs index 83121a0..129588b 100644 --- a/server/db/db.rs +++ b/server/db/db.rs @@ -43,7 +43,6 @@ use hashlink::LinkedHashMap; use itertools::Itertools; use log::warn; use log::{error, info, trace}; -use parking_lot::{Mutex, MutexGuard}; use rusqlite::{named_params, params}; use smallvec::SmallVec; use std::cell::RefCell; @@ -57,6 +56,7 @@ use std::path::PathBuf; use std::str; use std::string::String; use std::sync::Arc; +use std::sync::{Mutex, MutexGuard}; use std::vec::Vec; use uuid::Uuid; @@ -547,7 +547,7 @@ impl Stream { pub fn days(&self) -> days::Map { let mut days = self.committed_days.clone(); for u in &self.uncommitted { - let l = u.lock(); + let l = u.lock().unwrap(); days.adjust( l.start..l.start + recording::Duration(i64::from(l.wall_duration_90k)), 1, @@ -850,7 +850,7 @@ impl LockedDatabase { ); match stream.uncommitted.back() { Some(s) => { - let l = s.lock(); + let l = s.lock().unwrap(); r.prev_media_duration = l.prev_media_duration + recording::Duration(l.media_duration_90k.into()); r.prev_runs = l.prev_runs + if l.run_offset == 0 { 1 } else { 0 }; @@ -884,7 +884,7 @@ impl LockedDatabase { if stream.synced_recordings == stream.uncommitted.len() { bail!("can't sync un-added recording {}", id); } - let l = stream.uncommitted[stream.synced_recordings].lock(); + let l = stream.uncommitted[stream.synced_recordings].lock().unwrap(); let bytes = i64::from(l.sample_file_bytes); stream.bytes_to_add += bytes; stream.fs_bytes_to_add += round_up(bytes); @@ -972,7 +972,7 @@ impl LockedDatabase { let mut new_duration = 0; let mut new_runs = 0; for i in 0..s.synced_recordings { - let l = s.uncommitted[i].lock(); + let l = s.uncommitted[i].lock().unwrap(); raw::insert_recording( &tx, o, @@ -1094,7 +1094,7 @@ impl LockedDatabase { let u = s.uncommitted.pop_front().unwrap(); log.added .push(CompositeId::new(stream_id, s.cum_recordings)); - let l = u.lock(); + let l = u.lock().unwrap(); s.cum_recordings += 1; let wall_dur = recording::Duration(l.wall_duration_90k.into()); let media_dur = recording::Duration(l.media_duration_90k.into()); @@ -1263,7 +1263,7 @@ impl LockedDatabase { raw::list_recordings_by_time(&self.conn, stream_id, desired_time.clone(), f)?; for (i, u) in s.uncommitted.iter().enumerate() { let row = { - let l = u.lock(); + let l = u.lock().unwrap(); if l.video_samples > 0 { let end = l.start + recording::Duration(l.wall_duration_90k as i64); if l.start > desired_time.end || end < desired_time.start { @@ -1304,7 +1304,7 @@ impl LockedDatabase { ); for i in start..end { let row = { - let l = s.uncommitted[i].lock(); + let l = s.uncommitted[i].lock().unwrap(); if l.video_samples > 0 { l.to_list_row( CompositeId::new(stream_id, s.cum_recordings + i as i32), @@ -1435,7 +1435,7 @@ impl LockedDatabase { s.cum_recordings + s.uncommitted.len() as i32 ); } - let l = s.uncommitted[i as usize].lock(); + let l = s.uncommitted[i as usize].lock().unwrap(); return f(&RecordingPlayback { video_index: &l.video_index, }); @@ -2241,7 +2241,7 @@ impl Drop for Database { return; // don't flush while panicking. } if let Some(m) = self.db.take() { - if let Err(e) = m.into_inner().flush(&self.clocks, "drop") { + if let Err(e) = m.into_inner().unwrap().flush(&self.clocks, "drop") { error!("Final database flush failed: {}", e); } } @@ -2340,7 +2340,7 @@ impl Database { /// operations. pub fn lock(&self) -> DatabaseGuard { let timer = clock::TimerGuard::new(&self.clocks, acquisition); - let db = self.db.as_ref().unwrap().lock(); + let db = self.db.as_ref().unwrap().lock().unwrap(); drop(timer); let _timer = clock::TimerGuard:: &'static str>::new( &self.clocks, @@ -2357,7 +2357,7 @@ impl Database { /// This allows verification that a newly opened database is in an acceptable state. #[cfg(test)] fn close(mut self) -> rusqlite::Connection { - self.db.take().unwrap().into_inner().conn + self.db.take().unwrap().into_inner().unwrap().conn } } diff --git a/server/db/testutil.rs b/server/db/testutil.rs index 9b29bfd..ae33c6d 100644 --- a/server/db/testutil.rs +++ b/server/db/testutil.rs @@ -16,7 +16,7 @@ use std::thread; use tempfile::TempDir; use uuid::Uuid; -static INIT: parking_lot::Once = parking_lot::Once::new(); +static INIT: std::sync::Once = std::sync::Once::new(); /// id of the camera created by `TestDb::new` below. pub const TEST_CAMERA_ID: i32 = 1; diff --git a/server/db/upgrade/mod.rs b/server/db/upgrade/mod.rs index 58d0690..495e5c2 100644 --- a/server/db/upgrade/mod.rs +++ b/server/db/upgrade/mod.rs @@ -126,7 +126,7 @@ struct UuidPath([u8; 37]); impl UuidPath { pub(crate) fn from(uuid: Uuid) -> Self { let mut buf = [0u8; 37]; - write!(&mut buf[..36], "{}", uuid.to_hyphenated_ref()) + write!(&mut buf[..36], "{}", uuid.as_hyphenated()) .expect("can't format uuid to pathname buf"); UuidPath(buf) } diff --git a/server/db/upgrade/v1_to_v2.rs b/server/db/upgrade/v1_to_v2.rs index 5d727b4..0a6ddf5 100644 --- a/server/db/upgrade/v1_to_v2.rs +++ b/server/db/upgrade/v1_to_v2.rs @@ -323,7 +323,7 @@ fn verify_dir_contents( Ok(u) => u, Err(_) => bail!("unexpected file {:?} in {:?}", f, sample_file_path), }; - if s != uuid.to_hyphenated_ref().to_string() { + if s != uuid.as_hyphenated().to_string() { // non-canonical form. bail!("unexpected file {:?} in {:?}", f, sample_file_path); } diff --git a/server/db/upgrade/v5_to_v6.rs b/server/db/upgrade/v5_to_v6.rs index b94a310..b00751e 100644 --- a/server/db/upgrade/v5_to_v6.rs +++ b/server/db/upgrade/v5_to_v6.rs @@ -108,7 +108,7 @@ pub fn run(_args: &super::Args, tx: &rusqlite::Transaction) -> Result<(), Error> if avcc.num_of_sequence_parameter_sets() != 1 { bail!("Multiple SPSs!"); } - let ctx = avcc.create_context(()).map_err(|e| { + let ctx = avcc.create_context().map_err(|e| { format_err!( "Can't load SPS+PPS for video_sample_entry_id {}: {:?}", id, diff --git a/server/db/writer.rs b/server/db/writer.rs index 18c6af8..7f39c1d 100644 --- a/server/db/writer.rs +++ b/server/db/writer.rs @@ -12,12 +12,12 @@ use base::shutdown::ShutdownError; use failure::{bail, format_err, Error}; use fnv::FnvHashMap; use log::{debug, trace, warn}; -use parking_lot::Mutex; use std::cmp::{self, Ordering}; use std::convert::TryFrom; use std::io; use std::mem; use std::path::PathBuf; +use std::sync::Mutex; use std::sync::{mpsc, Arc}; use std::thread; use std::time::Duration as StdDuration; @@ -860,7 +860,7 @@ impl InnerWriter { db: &db::Database, stream_id: i32, ) -> Result<(), Error> { - let mut l = self.r.lock(); + let mut l = self.r.lock().unwrap(); // design/time.md explains these time manipulations in detail. let prev_media_duration_90k = l.media_duration_90k; @@ -935,7 +935,7 @@ impl InnerWriter { // This always ends a live segment. let wall_duration; { - let mut l = self.r.lock(); + let mut l = self.r.lock().unwrap(); l.flags = flags; l.local_time_delta = self.local_start - l.start; l.sample_file_blake3 = Some(*blake3.as_bytes()); @@ -979,11 +979,11 @@ mod tests { use crate::testutil; use base::clock::{Clocks, SimulatedClocks}; use log::{trace, warn}; - use parking_lot::Mutex; use std::collections::VecDeque; use std::io; use std::sync::mpsc; use std::sync::Arc; + use std::sync::Mutex; #[derive(Clone)] struct MockDir(Arc>>); @@ -1005,10 +1005,10 @@ mod tests { MockDir(Arc::new(Mutex::new(VecDeque::new()))) } fn expect(&self, action: MockDirAction) { - self.0.lock().push_back(action); + self.0.lock().unwrap().push_back(action); } fn ensure_done(&self) { - assert_eq!(self.0.lock().len(), 0); + assert_eq!(self.0.lock().unwrap().len(), 0); } } @@ -1019,6 +1019,7 @@ mod tests { match self .0 .lock() + .unwrap() .pop_front() .expect("got create_file with no expectation") { @@ -1033,6 +1034,7 @@ mod tests { match self .0 .lock() + .unwrap() .pop_front() .expect("got sync with no expectation") { @@ -1044,6 +1046,7 @@ mod tests { match self .0 .lock() + .unwrap() .pop_front() .expect("got unlink_file with no expectation") { @@ -1059,7 +1062,7 @@ mod tests { impl Drop for MockDir { fn drop(&mut self) { if !::std::thread::panicking() { - assert_eq!(self.0.lock().len(), 0); + assert_eq!(self.0.lock().unwrap().len(), 0); } } } @@ -1077,10 +1080,10 @@ mod tests { MockFile(Arc::new(Mutex::new(VecDeque::new()))) } fn expect(&self, action: MockFileAction) { - self.0.lock().push_back(action); + self.0.lock().unwrap().push_back(action); } fn ensure_done(&self) { - assert_eq!(self.0.lock().len(), 0); + assert_eq!(self.0.lock().unwrap().len(), 0); } } @@ -1089,6 +1092,7 @@ mod tests { match self .0 .lock() + .unwrap() .pop_front() .expect("got sync_all with no expectation") { @@ -1100,6 +1104,7 @@ mod tests { match self .0 .lock() + .unwrap() .pop_front() .expect("got write with no expectation") { diff --git a/server/src/h264.rs b/server/src/h264.rs index e3c23ae..f55fa19 100644 --- a/server/src/h264.rs +++ b/server/src/h264.rs @@ -68,7 +68,7 @@ pub fn parse_extra_data(extradata: &[u8]) -> Result Result, Error> { assert_eq!(&url, &self.expected_url); - let mut l = self.streams.lock(); + let mut l = self.streams.lock().unwrap(); match l.pop() { Some(stream) => { trace!("MockOpener returning next stream"); @@ -393,7 +393,7 @@ mod tests { } None => { trace!("MockOpener shutting down"); - self.shutdown_tx.lock().take(); + self.shutdown_tx.lock().unwrap().take(); bail!("done") } } @@ -472,7 +472,7 @@ mod tests { .unwrap(); } stream.run(); - assert!(opener.streams.lock().is_empty()); + assert!(opener.streams.lock().unwrap().is_empty()); db.syncer_channel.flush(); let db = db.db.lock();