emersion / go-webdav

A Go library for WebDAV, CalDAV and CardDAV
MIT License
326 stars 71 forks source link

fix: Response body was not closed causing the goroutine leak #97

Closed myml closed 2 years ago

myml commented 2 years ago

Using webdav in juicefs server gives the error 'too many open files'

(pprof) top
Showing nodes accounting for 643, 99.69% of 645 total
Dropped 76 nodes (cum <= 3)
Showing top 10 nodes out of 46
      flat  flat%   sum%        cum   cum%
       640 99.22% 99.22%        640 99.22%  runtime.gopark
         3  0.47% 99.69%          3  0.47%  syscall.Syscall
         0     0% 99.69%         20  3.10%  bufio.(*Reader).Peek
         0     0% 99.69%         21  3.26%  bufio.(*Reader).fill
         0     0% 99.69%         20  3.10%  github.com/emersion/go-webdav.(*Client).Create.func1
         0     0% 99.69%         20  3.10%  github.com/emersion/go-webdav.(*fileWriter).Close
         0     0% 99.69%         20  3.10%  github.com/emersion/go-webdav/internal.(*Client).Do
         0     0% 99.69%         20  3.10%  github.com/juicedata/juicefs/pkg/chunk.(*cachedStore).put
         0     0% 99.69%         20  3.10%  github.com/juicedata/juicefs/pkg/chunk.(*cachedStore).put.func1
         0     0% 99.69%         20  3.10%  github.com/juicedata/juicefs/pkg/chunk.(*cachedStore).upload