Skip to content

Commit

Permalink
fix(net): close of closed channel
Browse files Browse the repository at this point in the history
  • Loading branch information
hshpy committed Nov 29, 2024
1 parent 94915b2 commit e4e05f4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
5 changes: 1 addition & 4 deletions internal/net/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,7 @@ func (d *downloader) sendChunkTask() *chunk {

// when the final reader Close, we interrupt
func (d *downloader) interrupt() error {
if d.chunkChannel == nil {
return nil
}

d.cancel()
if d.written != d.params.Range.Length {
log.Debugf("Downloader interrupt before finish")
Expand All @@ -181,7 +179,6 @@ func (d *downloader) interrupt() error {
}
defer func() {
close(d.chunkChannel)
d.chunkChannel = nil
for _, buf := range d.bufs {
buf.Close()
}
Expand Down
2 changes: 1 addition & 1 deletion internal/net/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ func ServeHTTP(w http.ResponseWriter, r *http.Request, name string, modTime time
pw.Close()
}()
}
defer sendContent.Close()
//defer sendContent.Close()

w.Header().Set("Accept-Ranges", "bytes")
if w.Header().Get("Content-Encoding") == "" {
Expand Down

0 comments on commit e4e05f4

Please sign in to comment.