Skip to content

Commit f781eee

Browse files
committed
scanning changes
1 parent 60c5f03 commit f781eee

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

crates/scanner-core/src/lib.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -917,9 +917,21 @@ impl<'a> Scanner<'a> {
917917
}
918918
}
919919

920-
// Send file to work queue
921-
if work_sender.send(path.to_path_buf()).is_err() {
922-
return ignore::WalkState::Quit;
920+
// Send file to work queue with blocking to handle backpressure
921+
// This ensures we don't drop files when the queue is full
922+
// The bounded channel will naturally throttle the producer when consumers are busy
923+
loop {
924+
match work_sender.try_send(path.to_path_buf()) {
925+
Ok(_) => break,
926+
Err(crossbeam_channel::TrySendError::Full(_)) => {
927+
// Channel is full, wait a bit for consumers to catch up
928+
std::thread::sleep(std::time::Duration::from_micros(100));
929+
}
930+
Err(crossbeam_channel::TrySendError::Disconnected(_)) => {
931+
// Receiver has been dropped, stop the walk
932+
return ignore::WalkState::Quit;
933+
}
934+
}
923935
}
924936

925937
// Update discovered files counter atomically (no lock!)

0 commit comments

Comments
 (0)