Skip to content

Commit

Permalink
chore: fix clippy warning, and use less complex sync
Browse files Browse the repository at this point in the history
  • Loading branch information
ctron committed Feb 4, 2025
1 parent 6a1f36e commit fb52247
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ colored_json = "5"
csaf = { version = "0.5.0", default-features = false }
csv = "1"
cyclonedx-bom = "0.8.0"
deno_core = "0.323.0"
deno_core = "0.334.0"
digest = "0.10.6"
env_logger = "0.11"
filetime = "0.2"
Expand Down
1 change: 1 addition & 0 deletions csaf/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ hickory-resolver = { workspace = true, features = ["tokio-runtime"] }
html-escape = { workspace = true }
humantime = { workspace = true }
log = { workspace = true }
parking_lot = { workspace = true }
percent-encoding = { workspace = true }
reqwest = { workspace = true, features = ["json"] }
sectxtlib = { workspace = true }
Expand Down
30 changes: 17 additions & 13 deletions csaf/src/verification/check/csaf_validator_lib/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,18 @@ use deno_core::{
_ops::RustToV8NoScope, op2, serde_v8, v8, Extension, JsRuntime, OpDecl, PollEventLoopOptions,
RuntimeOptions, StaticModuleLoader,
};
use parking_lot::Mutex;
use serde::{Deserialize, Serialize};
use std::collections::HashSet;
use std::fmt::Debug;
use std::rc::Rc;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::{Arc, Condvar};
use std::time::Duration;
use tokio::sync::Mutex;
use std::{
collections::HashSet,
fmt::Debug,
rc::Rc,
sync::{
atomic::{AtomicBool, Ordering},
Arc, Condvar,
},
time::Duration,
};
use url::Url;

const MODULE_ID: &str = "internal://bundle.js";
Expand Down Expand Up @@ -180,7 +184,7 @@ impl InnerCheck {

let result = match result {
Err(err) if err.to_string().ends_with(": execution terminated") => return Ok(None),
Err(err) => return Err(err),
Err(err) => return Err(err.into()),
Ok(result) => result,
};

Expand Down Expand Up @@ -226,15 +230,15 @@ pub enum Profile {
}

pub struct CsafValidatorLib {
runtime: Arc<Mutex<Vec<InnerCheck>>>,
runtime: Rc<Mutex<Vec<InnerCheck>>>,
validations: Vec<ValidationSet>,
timeout: Option<Duration>,
ignore: HashSet<String>,
}

impl CsafValidatorLib {
pub fn new(profile: Profile) -> Self {
let runtime = Arc::new(Mutex::new(vec![]));
let runtime = Rc::new(Mutex::new(vec![]));

let validations = match profile {
Profile::Schema => vec![ValidationSet::Schema],
Expand Down Expand Up @@ -290,8 +294,8 @@ impl CsafValidatorLib {
impl Check for CsafValidatorLib {
async fn check(&self, csaf: &Csaf) -> anyhow::Result<Vec<CheckError>> {
let mut inner = {
let mut inner_lock = self.runtime.lock().await;
match inner_lock.pop() {
let inner = self.runtime.lock().pop();
match inner {
Some(inner) => inner,
None => InnerCheck::new().await?,
}
Expand All @@ -308,7 +312,7 @@ impl Check for CsafValidatorLib {
};

// not timed out, not failed, we can re-use it
self.runtime.lock().await.push(inner);
self.runtime.lock().push(inner);

let mut result = vec![];

Expand Down

0 comments on commit fb52247

Please sign in to comment.