Fail loudly on a touch read, stop the workers before their sockets close, and file down the small edges

This commit is contained in:
flamingcow
2026-08-04 22:26:07 -07:00
parent 12cef6a89b
commit 7b2601a02e
5 changed files with 38 additions and 20 deletions
+14 -2
View File
@@ -640,6 +640,20 @@ func run(aName, bName string, nsPerM float64) error {
defer wg.Done()
samp.run(&done, startTx)
}()
// Every return from here on stops the workers before the deferred closes
// pull their sockets out from under them: otherwise the sampler panics on a
// closed fd and can mask the error that actually ended the run. An error
// before the gate opens closes it here, or the wait would hang on
// goroutines still parked at startTx.
defer func() {
done.Store(true)
select {
case <-startTx:
default:
close(startTx)
}
wg.Wait()
}()
rxReady.Wait()
sig := make(chan os.Signal, 1)
@@ -674,8 +688,6 @@ func run(aName, bName string, nsPerM float64) error {
for {
select {
case <-sig:
done.Store(true)
wg.Wait()
return nil
case <-space:
start = resetAll(dirs, stats)