diff options
| author | Will Hawkins <[email protected]> | 2021-12-16 18:03:00 -0500 |
|---|---|---|
| committer | Will Hawkins <[email protected]> | 2021-12-16 18:03:00 -0500 |
| commit | a1847cfe95e4fb73867cf2aeb5c41e332a7fef1e (patch) | |
| tree | 8019a5855388866340c9339c5c8baadc05fc8699 /lbc/lbc.go | |
| parent | bb48aa9f23d3b74aa3e31f395deaf6fdd1618391 (diff) | |
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.
Diffstat (limited to 'lbc/lbc.go')
| -rw-r--r-- | lbc/lbc.go | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -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") } |
