fix: scope MutexGuard in worker thread to not hold lock during test
Browse filesThe 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 |
-
|
| 423 |
-
|
|
|
|
|
|
|
|
|
|
| 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,
|
| 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 |
}));
|