diff options
| author | Chris Lu <chrislusf@users.noreply.github.com> | 2022-03-24 12:21:44 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-03-24 12:21:44 -0700 |
| commit | 89d84e275bfef82b9de0090eb3052ec98b23493d (patch) | |
| tree | 498d72d4ea20d21b047dee85f083e67e70bc7936 | |
| parent | b0a6f6ab391f8455b16f4cd20aefed8c85753b8b (diff) | |
| parent | f43c6daeda4a6fd1b4a383c1ce147c130392f92d (diff) | |
| download | seaweedfs-89d84e275bfef82b9de0090eb3052ec98b23493d.tar.xz seaweedfs-89d84e275bfef82b9de0090eb3052ec98b23493d.zip | |
Merge pull request #2759 from kmlebedev/skip_wait_cancelled_request
Need to exit waiting if request is was canceled
| -rw-r--r-- | weed/server/volume_server_handlers.go | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/weed/server/volume_server_handlers.go b/weed/server/volume_server_handlers.go index 2dc7f6741..49bc297fb 100644 --- a/weed/server/volume_server_handlers.go +++ b/weed/server/volume_server_handlers.go @@ -40,8 +40,14 @@ func (vs *VolumeServer) privateStoreHandler(w http.ResponseWriter, r *http.Reque stats.ReadRequest() vs.inFlightDownloadDataLimitCond.L.Lock() for vs.concurrentDownloadLimit != 0 && atomic.LoadInt64(&vs.inFlightDownloadDataSize) > vs.concurrentDownloadLimit { - glog.V(4).Infof("wait because inflight download data %d > %d", vs.inFlightDownloadDataSize, vs.concurrentDownloadLimit) - vs.inFlightDownloadDataLimitCond.Wait() + select { + case <-r.Context().Done(): + glog.V(4).Infof("request cancelled from %s: %v", r.RemoteAddr, r.Context().Err()) + return + default: + glog.V(4).Infof("wait because inflight download data %d > %d", vs.inFlightDownloadDataSize, vs.concurrentDownloadLimit) + vs.inFlightDownloadDataLimitCond.Wait() + } } vs.inFlightDownloadDataLimitCond.L.Unlock() vs.GetOrHeadHandler(w, r) |
