1
0
Fork 0
mirror of https://github.com/chrislusf/seaweedfs synced 2024-06-03 09:10:10 +02:00

Merge pull request #2759 from kmlebedev/skip_wait_cancelled_request

Need to exit waiting if request is was canceled
This commit is contained in:
Chris Lu 2022-03-24 12:21:44 -07:00 committed by GitHub
commit 89d84e275b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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)