fix(net): goroutine deadlock

This commit is contained in:
j2rong4cn
2025-07-04 12:50:04 +08:00
parent 2ec9dad3db
commit f3920b02f7
2 changed files with 32 additions and 30 deletions

View File

@ -120,7 +120,7 @@ func ServeHTTP(w http.ResponseWriter, r *http.Request, name string, modTime time
reader, err := RangeReadCloser.RangeRead(ctx, http_range.Range{Length: -1})
if err != nil {
code = http.StatusRequestedRangeNotSatisfiable
if err == ErrExceedMaxConcurrency {
if errors.Is(err, ErrExceedMaxConcurrency) {
code = http.StatusTooManyRequests
}
http.Error(w, err.Error(), code)
@ -143,7 +143,7 @@ func ServeHTTP(w http.ResponseWriter, r *http.Request, name string, modTime time
sendContent, err = RangeReadCloser.RangeRead(ctx, ra)
if err != nil {
code = http.StatusRequestedRangeNotSatisfiable
if err == ErrExceedMaxConcurrency {
if errors.Is(err, ErrExceedMaxConcurrency) {
code = http.StatusTooManyRequests
}
http.Error(w, err.Error(), code)
@ -205,7 +205,7 @@ func ServeHTTP(w http.ResponseWriter, r *http.Request, name string, modTime time
log.Warnf("Maybe size incorrect or reader not giving correct/full data, or connection closed before finish. written bytes: %d ,sendSize:%d, ", written, sendSize)
}
code = http.StatusInternalServerError
if err == ErrExceedMaxConcurrency {
if errors.Is(err, ErrExceedMaxConcurrency) {
code = http.StatusTooManyRequests
}
w.WriteHeader(code)