Skip to content

Commit

Permalink
Add Parameter used by Command to allow connection timeouts to complet…
Browse files Browse the repository at this point in the history
…e the command

Fixes masterzen#161 where commands that cause the host to shut down never complete
and run forever.
  • Loading branch information
jpalermo committed Mar 21, 2024
1 parent e811dad commit df0e10c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion command.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
1 change: 1 addition & 0 deletions parameters.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit df0e10c

Please sign in to comment.