rclone: Don't panic after unexpected subprocess exit

As the connection to the rclone child process is now closed after an
unexpected subprocess exit, later requests will cause the http2
transport to try to reestablish a new connection. As previously this never
should have happened, the connection called panic in that case. This
panic is now replaced with a simple error message, as it no longer
indicates an internal problem.
This commit is contained in:
Michael Eischer 2020-08-01 12:06:30 +02:00
parent 48f97f3567
commit c81b122374
2 changed files with 9 additions and 6 deletions

View file

@ -173,7 +173,8 @@ func newBackend(cfg Config, lim limiter.Limiter) (*Backend, error) {
DialTLS: func(network, address string, cfg *tls.Config) (net.Conn, error) {
debug.Log("new connection requested, %v %v", network, address)
if dialCount > 0 {
panic("dial count > 0")
// the connection to the child process is already closed
return nil, errors.New("rclone stdio connection already closed")
}
dialCount++
return conn, nil

View file

@ -29,9 +29,11 @@ func TestRcloneExit(t *testing.T) {
rtest.OK(t, err)
t.Log("killed rclone")
_, err = be.Stat(context.TODO(), restic.Handle{
Name: "foo",
Type: restic.DataFile,
})
rtest.Assert(t, err != nil, "expected an error")
for i := 0; i < 10; i++ {
_, err = be.Stat(context.TODO(), restic.Handle{
Name: "foo",
Type: restic.DataFile,
})
rtest.Assert(t, err != nil, "expected an error")
}
}