fix(net): close of closed channel (#7580)
This commit is contained in:
parent
cf58ab3a78
commit
331885ed64
@ -169,9 +169,7 @@ func (d *downloader) sendChunkTask() *chunk {
|
|||||||
|
|
||||||
// when the final reader Close, we interrupt
|
// when the final reader Close, we interrupt
|
||||||
func (d *downloader) interrupt() error {
|
func (d *downloader) interrupt() error {
|
||||||
if d.chunkChannel == nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
d.cancel()
|
d.cancel()
|
||||||
if d.written != d.params.Range.Length {
|
if d.written != d.params.Range.Length {
|
||||||
log.Debugf("Downloader interrupt before finish")
|
log.Debugf("Downloader interrupt before finish")
|
||||||
@ -181,7 +179,6 @@ func (d *downloader) interrupt() error {
|
|||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
close(d.chunkChannel)
|
close(d.chunkChannel)
|
||||||
d.chunkChannel = nil
|
|
||||||
for _, buf := range d.bufs {
|
for _, buf := range d.bufs {
|
||||||
buf.Close()
|
buf.Close()
|
||||||
}
|
}
|
||||||
|
@ -174,7 +174,7 @@ func ServeHTTP(w http.ResponseWriter, r *http.Request, name string, modTime time
|
|||||||
pw.Close()
|
pw.Close()
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
defer sendContent.Close()
|
//defer sendContent.Close()
|
||||||
|
|
||||||
w.Header().Set("Accept-Ranges", "bytes")
|
w.Header().Set("Accept-Ranges", "bytes")
|
||||||
if w.Header().Get("Content-Encoding") == "" {
|
if w.Header().Get("Content-Encoding") == "" {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user