Skip to content
This repository has been archived by the owner on Nov 1, 2023. It is now read-only.

Commit

Permalink
introduce delay between syncs
Browse files Browse the repository at this point in the history
  • Loading branch information
chkeita committed Oct 24, 2020
1 parent 982d424 commit 4369386
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/agent/onefuzz-agent/src/tasks/fuzz/libfuzzer_fuzz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use tokio::{
io::{AsyncBufReadExt, BufReader},
sync::mpsc,
task,
time::{self, Duration},
time::{self, Duration, Instant},
};
use uuid::Uuid;

Expand All @@ -36,6 +36,9 @@ const PROC_INFO_PERIOD: Duration = Duration::from_secs(30);
// Period of reporting fuzzer-generated runtime stats.
const RUNTIME_STATS_PERIOD: Duration = Duration::from_secs(60);

// minimum delay between input corpus sync
const SYNC_DELAY: Duration = Duration::from_secs(60);

#[derive(Debug, Deserialize, Clone)]
pub struct Config {
pub inputs: SyncedDir,
Expand Down Expand Up @@ -100,12 +103,15 @@ impl LibFuzzerFuzzTask {
let inputs = inputs.clone();
input_dirs.extend(inputs);
}

let mut last_sync = Instant::now() - SYNC_DELAY;

loop {
for dir in &input_dirs {
dir.sync(Pull).await?;
if Instant::now() - last_sync >= SYNC_DELAY {
for dir in &input_dirs {
dir.sync(Pull).await?;
}
last_sync = Instant::now() + SYNC_DELAY;
}

self.run_fuzzer(worker_id, stats_sender).await?;
}
}
Expand Down

0 comments on commit 4369386

Please sign in to comment.