Skip to content

Commit

Permalink
Merge pull request #57 from BloodHoundAD/fix-deadlock-with-close
Browse files Browse the repository at this point in the history
Add close to body to prevent deadlock
  • Loading branch information
superlinkx authored Oct 20, 2023
2 parents 1dd97b0 + 773d377 commit 207d9ad
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 207d9ad

Please sign in to comment.