mirror of
https://github.com/scottlamb/moonfire-nvr.git
synced 2025-12-02 06:07:51 -05:00
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:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user