paavohtl Claude Opus 4.6 (1M context) commited on
Commit
8e36bc6
·
1 Parent(s): 79ad64a

fix: scope MutexGuard in worker thread to not hold lock during test

Browse files

The original code held the work_rx mutex for the entire recv() call.
While harmless when items are pre-buffered, this is incorrect — scope
the guard so it drops after recv() returns but before running the test.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

crates/openwa-test-runner/src/main.rs CHANGED
@@ -419,14 +419,17 @@ fn run_tests_parallel(
419
 
420
  handles.push(thread::spawn(move || {
421
  loop {
422
- // Lock only long enough to recv, then drop the guard before running the test
423
- let item = rx.lock().unwrap().recv();
 
 
 
424
  match item {
425
  Ok((idx, test)) => {
426
  let result = run_test(&test, &launcher, &wa_exe, &run_dir);
427
  let _ = tx.send((idx, result));
428
  }
429
- Err(_) => break, // Channel closed, no more work
430
  }
431
  }
432
  }));
 
419
 
420
  handles.push(thread::spawn(move || {
421
  loop {
422
+ let item = {
423
+ let guard = rx.lock().unwrap();
424
+ guard.recv()
425
+ // MutexGuard drops here — lock released before running the test
426
+ };
427
  match item {
428
  Ok((idx, test)) => {
429
  let result = run_test(&test, &launcher, &wa_exe, &run_dir);
430
  let _ = tx.send((idx, result));
431
  }
432
+ Err(_) => break,
433
  }
434
  }
435
  }));