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.
This commit is contained in:
Scott Lamb
2022-09-28 22:19:35 -07:00
parent d8ff02ab8b
commit ae502200c0
17 changed files with 117 additions and 107 deletions

View File

@@ -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]

View File

@@ -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<scrypt::Params> = 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();

View File

@@ -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<days::StreamValue> {
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<C: Clocks + Clone> Drop for Database<C> {
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<C: Clocks + Clone> Database<C> {
/// operations.
pub fn lock(&self) -> DatabaseGuard<C> {
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::<C, &'static str, fn() -> &'static str>::new(
&self.clocks,
@@ -2357,7 +2357,7 @@ impl<C: Clocks + Clone> Database<C> {
/// 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
}
}

View File

@@ -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;

View File

@@ -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)
}

View File

@@ -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);
}

View File

@@ -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,

View File

@@ -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<F: FileWriter> InnerWriter<F> {
db: &db::Database<C>,
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<F: FileWriter> InnerWriter<F> {
// 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<Mutex<VecDeque<MockDirAction>>>);
@@ -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")
{