Skip to content

Commit

Permalink
draft: add close to body to prevent deadlock
Browse files Browse the repository at this point in the history
  • Loading branch information
superlinkx committed Oct 20, 2023
1 parent 1dd97b0 commit 773d377
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,14 +224,24 @@ func ingest(ctx context.Context, bheUrl url.URL, bheClient *http.Client, in <-ch
log.Error(ErrExceededRetryLimit, "")
hasErrors = true
}
if err := response.Body.Close(); err != nil {
log.Error(fmt.Errorf("failed to close ingest body: %w", err), unrecoverableErrMsg)
}
continue
} else if response.StatusCode != http.StatusAccepted {
if bodyBytes, err := io.ReadAll(response.Body); err != nil {
log.Error(fmt.Errorf("received unexpected response code from %v: %s; failure reading response body", endpoint, response.Status), unrecoverableErrMsg)
} else {
log.Error(fmt.Errorf("received unexpected response code from %v: %s %s", req.URL, response.Status, bodyBytes), unrecoverableErrMsg)
}
if err := response.Body.Close(); err != nil {
log.Error(fmt.Errorf("failed to close ingest body: %w", err), unrecoverableErrMsg)
}
return true
} else {
if err := response.Body.Close(); err != nil {
log.Error(fmt.Errorf("failed to close ingest body: %w", err), unrecoverableErrMsg)
}
}
}
}
Expand Down

0 comments on commit 773d377

Please sign in to comment.