diff --git a/src/agent/onefuzz-agent/src/tasks/fuzz/libfuzzer_fuzz.rs b/src/agent/onefuzz-agent/src/tasks/fuzz/libfuzzer_fuzz.rs index db882896d3c..3a1ed0b4274 100644 --- a/src/agent/onefuzz-agent/src/tasks/fuzz/libfuzzer_fuzz.rs +++ b/src/agent/onefuzz-agent/src/tasks/fuzz/libfuzzer_fuzz.rs @@ -23,7 +23,7 @@ use tokio::{ io::{AsyncBufReadExt, BufReader}, sync::mpsc, task, - time::{self, Duration}, + time::{self, Duration, Instant}, }; use uuid::Uuid; @@ -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, @@ -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?; } }