diff options
| author | Chris Lu <chris.lu@uber.com> | 2021-04-02 01:10:24 -0700 |
|---|---|---|
| committer | Chris Lu <chris.lu@uber.com> | 2021-04-02 01:10:24 -0700 |
| commit | 7e8edc3c4adaf1251f5c773cbeaf3a868269f97a (patch) | |
| tree | ba87171aee996af75425171db7fd60cae041a387 /weed/server | |
| parent | cc0df36a9e767b27e313885a79119e6b14c3cbad (diff) | |
| download | seaweedfs-7e8edc3c4adaf1251f5c773cbeaf3a868269f97a.tar.xz seaweedfs-7e8edc3c4adaf1251f5c773cbeaf3a868269f97a.zip | |
refactoring
Diffstat (limited to 'weed/server')
| -rw-r--r-- | weed/server/filer_server_handlers_write_upload.go | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/weed/server/filer_server_handlers_write_upload.go b/weed/server/filer_server_handlers_write_upload.go index 21af6a109..25275cf05 100644 --- a/weed/server/filer_server_handlers_write_upload.go +++ b/weed/server/filer_server_handlers_write_upload.go @@ -5,8 +5,8 @@ import ( "hash" "io" "io/ioutil" - "math/rand" "net/http" + "runtime" "strings" "sync" "time" @@ -20,6 +20,10 @@ import ( "github.com/chrislusf/seaweedfs/weed/util" ) +var ( + limitedUploadProcessor = util.NewLimitedOutOfOrderProcessor(int32(runtime.NumCPU())) +) + func (fs *FilerServer) uploadReaderToChunks(w http.ResponseWriter, r *http.Request, reader io.Reader, chunkSize int32, fileName, contentType string, contentLength int64, so *operation.StorageOption) (fileChunks []*filer_pb.FileChunk, md5Hash hash.Hash, dataSize int64, err error, smallContent []byte) { md5Hash = md5.New() @@ -58,7 +62,7 @@ func (fs *FilerServer) uploadReaderToChunks(w http.ResponseWriter, r *http.Reque for readErr == nil { wg.Add(1) - operation.AsyncOutOfOrderProcess(rand.Uint32(), func() { + limitedUploadProcessor.Execute(func() { defer wg.Done() var localOffset int64 |
