From df0e10ca9199a646feefc2b7a8a58b6aa396498f Mon Sep 17 00:00:00 2001 From: Joseph Palermo Date: Thu, 21 Mar 2024 16:41:08 -0700 Subject: [PATCH] Add Parameter used by Command to allow connection timeouts to complete the command Fixes #161 where commands that cause the host to shut down never complete and run forever. --- command.go | 2 +- parameters.go | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/command.go b/command.go index f7c3551..a7cecb5 100644 --- a/command.go +++ b/command.go @@ -144,7 +144,7 @@ func (c *Command) slurpAllOutput() (bool, error) { response, err := c.client.sendRequest(request) if err != nil { var errWithTimeout *url.Error - if errors.As(err, &errWithTimeout) && errWithTimeout.Timeout() { + if !c.client.AllowTimeout && errors.As(err, &errWithTimeout) && errWithTimeout.Timeout() { // Operation timeout because the server didn't respond in time return false, err } diff --git a/parameters.go b/parameters.go index 08adcc9..d0c1c1a 100644 --- a/parameters.go +++ b/parameters.go @@ -8,6 +8,7 @@ type Parameters struct { Timeout string Locale string EnvelopeSize int + AllowTimeout bool // Allow Commands to finish if connection times out. Useful if the command causes the Host to shut down. TransportDecorator func() Transporter Dial func(network, addr string) (net.Conn, error) }