rclone: Give rclone time to finish before closing stdin pipe

Calling `Close()` on the rclone backend sometimes failed during test
execution with 'signal: Broken pipe'. The stdio connection closed both
the stdin and stdout file descriptors at the same moment, therefore
giving rclone no chance to properly send any final http2 data frames.

Now the stdin connection to rclone is closed first and will only be
forcefully closed after a timeout. In case rclone exits before the
timeout then the stdio connection will be closed normally.
This commit is contained in:
Michael Eischer
2020-07-24 23:27:47 +02:00
parent bf7b1f12ea
commit 3cd927d180
2 changed files with 23 additions and 18 deletions

View File

@@ -197,7 +197,7 @@ func newBackend(cfg Config, lim limiter.Limiter) (*Backend, error) {
debug.Log("Wait returned %v", err)
be.waitResult = err
// close our side of the pipes to rclone
stdioConn.Close()
stdioConn.CloseAll()
close(waitCh)
}()
@@ -314,7 +314,7 @@ func (be *Backend) Close() error {
debug.Log("rclone exited")
case <-time.After(waitForExit):
debug.Log("timeout, closing file descriptors")
err := be.conn.Close()
err := be.conn.CloseAll()
if err != nil {
return err
}