mirror of
https://github.com/minio/minio.git
synced 2025-11-20 09:56:07 -05:00
Add support for timeouts for locks (#4377)
This commit is contained in:
@@ -130,7 +130,9 @@ func (web *webAPIHandlers) MakeBucket(r *http.Request, args *MakeBucketArgs, rep
|
||||
}
|
||||
|
||||
bucketLock := globalNSMutex.NewNSLock(args.BucketName, "")
|
||||
bucketLock.Lock()
|
||||
if err := bucketLock.GetLock(globalObjectTimeout); err != nil {
|
||||
return toJSONError(errOperationTimedOut)
|
||||
}
|
||||
defer bucketLock.Unlock()
|
||||
|
||||
if err := objectAPI.MakeBucketWithLocation(args.BucketName, serverConfig.GetRegion()); err != nil {
|
||||
@@ -533,7 +535,10 @@ func (web *webAPIHandlers) Upload(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
// Lock the object.
|
||||
objectLock := globalNSMutex.NewNSLock(bucket, object)
|
||||
objectLock.Lock()
|
||||
if objectLock.GetLock(globalObjectTimeout) != nil {
|
||||
writeWebErrorResponse(w, errOperationTimedOut)
|
||||
return
|
||||
}
|
||||
defer objectLock.Unlock()
|
||||
|
||||
sha256sum := ""
|
||||
@@ -575,7 +580,10 @@ func (web *webAPIHandlers) Download(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
// Lock the object before reading.
|
||||
objectLock := globalNSMutex.NewNSLock(bucket, object)
|
||||
objectLock.RLock()
|
||||
if objectLock.GetRLock(globalObjectTimeout) != nil {
|
||||
writeWebErrorResponse(w, errOperationTimedOut)
|
||||
return
|
||||
}
|
||||
defer objectLock.RUnlock()
|
||||
|
||||
if err := objectAPI.GetObject(bucket, object, 0, -1, w); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user