From bb70f967437279e49fb87df23ae567c276e4cc33 Mon Sep 17 00:00:00 2001 From: Andrew Gallant Date: Mon, 12 Dec 2016 06:55:49 -0500 Subject: [PATCH] Fix a non-termination bug. This was a very silly bug. Instead of creating a particular atomic once and cloning it, we created a new value for each worker. Fixes #279 --- ignore/src/walk.rs | 3 ++- tests/tests.rs | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/ignore/src/walk.rs b/ignore/src/walk.rs index 70846dc8..938cf46e 100644 --- a/ignore/src/walk.rs +++ b/ignore/src/walk.rs @@ -767,12 +767,13 @@ impl WalkParallel { // Create the workers and then wait for them to finish. let num_waiting = Arc::new(AtomicUsize::new(0)); let num_quitting = Arc::new(AtomicUsize::new(0)); + let quit_now = Arc::new(AtomicBool::new(false)); let mut handles = vec![]; for _ in 0..threads { let worker = Worker { f: mkf(), queue: queue.clone(), - quit_now: Arc::new(AtomicBool::new(false)), + quit_now: quit_now.clone(), is_waiting: false, is_quitting: false, num_waiting: num_waiting.clone(), diff --git a/tests/tests.rs b/tests/tests.rs index c21fffc9..e00da84e 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -968,6 +968,15 @@ clean!(regression_256_j1, "test", "foo", |wd: WorkDir, mut cmd: Command| { assert_eq!(lines, "foo/baz:test\n"); }); +// See: https://github.com/BurntSushi/ripgrep/issues/279 +clean!(regression_279, "test", ".", |wd: WorkDir, mut cmd: Command| { + wd.create("foo", "test"); + cmd.arg("-q"); + + let lines: String = wd.stdout(&mut cmd); + assert_eq!(lines, ""); +}); + // See: https://github.com/BurntSushi/ripgrep/issues/7 sherlock!(feature_7, "-fpat", "sherlock", |wd: WorkDir, mut cmd: Command| { wd.create("pat", "Sherlock\nHolmes");