diff options
| author | chrislu <chris.lu@gmail.com> | 2022-03-02 20:15:28 -0800 |
|---|---|---|
| committer | chrislu <chris.lu@gmail.com> | 2022-03-02 20:15:28 -0800 |
| commit | a96d4254e9481596e7d719ec87fc4c92231aa73d (patch) | |
| tree | 44d02ebd56b85a194d956be98e3e5ad9360fe49f /weed/server/common.go | |
| parent | 6fbbc785745af3427028dfa78a26466bdfaed41f (diff) | |
| download | seaweedfs-a96d4254e9481596e7d719ec87fc4c92231aa73d.tar.xz seaweedfs-a96d4254e9481596e7d719ec87fc4c92231aa73d.zip | |
filer, s3, volume server: a bit memory optimization
Diffstat (limited to 'weed/server/common.go')
| -rw-r--r-- | weed/server/common.go | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/weed/server/common.go b/weed/server/common.go index ba4d13456..4bda31157 100644 --- a/weed/server/common.go +++ b/weed/server/common.go @@ -6,6 +6,7 @@ import ( "errors" "fmt" xhttp "github.com/chrislusf/seaweedfs/weed/s3api/http" + "github.com/chrislusf/seaweedfs/weed/util/mem" "io" "io/fs" "mime/multipart" @@ -361,7 +362,9 @@ func processRangeRequest(r *http.Request, w http.ResponseWriter, totalSize int64 w.Header().Set("Content-Length", strconv.FormatInt(sendSize, 10)) } w.WriteHeader(http.StatusPartialContent) - if _, err := io.CopyN(w, sendContent, sendSize); err != nil { + buf := mem.Allocate(128 * 1024) + defer mem.Free(buf) + if _, err := io.CopyBuffer(w, io.LimitReader(sendContent, sendSize), buf); err != nil { http.Error(w, "Internal Error", http.StatusInternalServerError) return } |
