File tree Expand file tree Collapse file tree 1 file changed +15
-3
lines changed
Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Original file line number Diff line number Diff 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!)
You can’t perform that action at this time.
0 commit comments