From eaeb5c15ad704753a93bc8f8c7fc422d2a189581 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Thu, 11 Jul 2024 17:56:03 +0200 Subject: vm/vmimpl: don't wait commands that have not failed The sleep in Multiplex is unconditional and it sleeps idle even for commands that has nothting to do with executor, and for executor in other modes that has nothing to do with fuzzing. Since the original reason for the sleep was related to failing executor, sleep only when the command fails. This allows to at least run successful commands fast. --- vm/vmimpl/vmimpl.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/vm/vmimpl/vmimpl.go b/vm/vmimpl/vmimpl.go index fa2719f5f..ce2a0dfb6 100644 --- a/vm/vmimpl/vmimpl.go +++ b/vm/vmimpl/vmimpl.go @@ -191,14 +191,6 @@ func Multiplex(cmd *exec.Cmd, merger *OutputMerger, timeout time.Duration, confi signal(fmt.Errorf("instance closed")) case err := <-merger.Err: cmd.Process.Kill() - // Once the command has exited, we might want to let the full console - // output accumulate before we abort the console connection too. - time.Sleep(WaitForOutputTimeout * config.Scale) - if config.Console != nil { - // Only wait for the merger if we're able to control the console stream. - config.Console.Close() - merger.Wait() - } if cmdErr := cmd.Wait(); cmdErr == nil { // If the command exited successfully, we got EOF error from merger. // But in this case no error has happened and the EOF is expected. @@ -206,6 +198,16 @@ func Multiplex(cmd *exec.Cmd, merger *OutputMerger, timeout time.Duration, confi } else if config.IgnoreError != nil && config.IgnoreError(err) { err = ErrTimeout } + // Once the command has failed, we might want to let the full console + // output accumulate before we abort the console connection too. + if err != nil { + time.Sleep(WaitForOutputTimeout * config.Scale) + } + if config.Console != nil { + // Only wait for the merger if we're able to control the console stream. + config.Console.Close() + merger.Wait() + } signal(err) return } -- cgit mrf-deployment