aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Lebedev <9497591+kmlebedev@users.noreply.github.com>2022-03-15 19:55:22 +0500
committerKonstantin Lebedev <9497591+kmlebedev@users.noreply.github.com>2022-03-15 19:55:22 +0500
commitf43c6daeda4a6fd1b4a383c1ce147c130392f92d (patch)
treeae26adc7a57e678a33e7682d0cf7cf4e7f106b28
parent2eda3a686ffc1707e67a45ff39c5852f02e5ec7b (diff)
downloadseaweedfs-f43c6daeda4a6fd1b4a383c1ce147c130392f92d.tar.xz
seaweedfs-f43c6daeda4a6fd1b4a383c1ce147c130392f92d.zip
Need to exit waiting if request is was canceled
-rw-r--r--weed/server/volume_server_handlers.go10
1 files changed, 8 insertions, 2 deletions
diff --git a/weed/server/volume_server_handlers.go b/weed/server/volume_server_handlers.go
index 510902cf0..8393138f2 100644
--- a/weed/server/volume_server_handlers.go
+++ b/weed/server/volume_server_handlers.go
@@ -39,8 +39,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)