From a1847cfe95e4fb73867cf2aeb5c41e332a7fef1e Mon Sep 17 00:00:00 2001 From: Will Hawkins Date: Thu, 16 Dec 2021 18:03:00 -0500 Subject: Improve robustness Improve robustness of the client in the case(s) where a network goes away in the middle of the test. Report errors properly in these cases and gracefully end the test. --- lbc/lbc.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lbc/lbc.go') diff --git a/lbc/lbc.go b/lbc/lbc.go index d1cfdc8..4542676 100644 --- a/lbc/lbc.go +++ b/lbc/lbc.go @@ -133,9 +133,10 @@ func (s *syntheticCountingReader) Read(p []byte) (n int, err error) { func (lbu *LoadBearingConnectionUpload) doUpload(ctx context.Context) bool { lbu.uploaded = 0 s := &syntheticCountingReader{n: &lbu.uploaded, ctx: ctx} - resp, _ := lbu.client.Post(lbu.Path, "application/octet-stream", s) + if resp, err := lbu.client.Post(lbu.Path, "application/octet-stream", s); err == nil { + resp.Body.Close() + } lbu.valid = false - resp.Body.Close() if lbu.debug { fmt.Printf("Ending a load-bearing upload.\n") } -- cgit v1.2.3